本文整理了Java中org.vertexium.Vertex.getProperties()
方法的一些代码示例,展示了Vertex.getProperties()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex.getProperties()
方法的具体详情如下:
包路径:org.vertexium.Vertex
类名称:Vertex
方法名:getProperties
暂无
代码示例来源:origin: org.vertexium/vertexium-cypher
private String columnVertexToString(VertexiumCypherQueryContext ctx, Vertex vertex) {
StringBuilder result = new StringBuilder();
result.append("(");
int propertyCount = 0;
for (Property property : vertex.getProperties()) {
if (property.getName().equals(ctx.getLabelPropertyName())) {
result.append(":");
result.append(property.getValue());
} else {
propertyCount++;
}
}
if (propertyCount > 0) {
if (result.length() > "(".length()) {
result.append(" ");
}
result.append(elementPropertiesToString(ctx, vertex));
}
result.append(")");
return result.toString();
}
代码示例来源:origin: org.vertexium/vertexium-core
@Override
public Map<Object, Long> getVertexPropertyCountByValue(String propertyName, Authorizations authorizations) {
Map<Object, Long> countsByValue = new HashMap<>();
for (Vertex v : getVertices(authorizations)) {
for (Property p : v.getProperties()) {
if (propertyName.equals(p.getName())) {
Object mapKey = p.getValue();
if (mapKey instanceof String) {
mapKey = ((String) mapKey).toLowerCase();
}
Long currentValue = countsByValue.get(mapKey);
if (currentValue == null) {
countsByValue.put(mapKey, 1L);
} else {
countsByValue.put(mapKey, currentValue + 1);
}
}
}
}
return countsByValue;
}
代码示例来源:origin: visallo/vertexium
@Override
public Map<Object, Long> getVertexPropertyCountByValue(String propertyName, Authorizations authorizations) {
Map<Object, Long> countsByValue = new HashMap<>();
for (Vertex v : getVertices(authorizations)) {
for (Property p : v.getProperties()) {
if (propertyName.equals(p.getName())) {
Object mapKey = p.getValue();
if (mapKey instanceof String) {
mapKey = ((String) mapKey).toLowerCase();
}
Long currentValue = countsByValue.get(mapKey);
if (currentValue == null) {
countsByValue.put(mapKey, 1L);
} else {
countsByValue.put(mapKey, currentValue + 1);
}
}
}
}
return countsByValue;
}
代码示例来源:origin: org.visallo/visallo-model-vertexium
public VertexiumUser(Vertex userVertex) {
this.userId = userVertex.getId();
for (Property property : userVertex.getProperties()) {
this.properties.put(property.getName(), property.getValue());
}
}
代码示例来源:origin: org.visallo/visallo-model-vertexium
private void deleteChangeableProperties(Vertex vertex, Authorizations authorizations) {
for (Property property : vertex.getProperties()) {
if (OntologyProperties.CHANGEABLE_PROPERTY_IRI.contains(property.getName())) {
vertex.softDeleteProperty(property.getKey(), property.getName(), authorizations);
}
}
graph.flush();
}
代码示例来源:origin: org.visallo/visallo-core
private void publishGlyphIconProperties(Edge hasImageEdge, String workspaceId, Authorizations authorizations) {
Vertex entityVertex = hasImageEdge.getVertex(Direction.OUT, authorizations);
checkNotNull(entityVertex, "Could not find has image source vertex " + hasImageEdge.getVertexId(Direction.OUT));
ExistingElementMutation elementMutation = entityVertex.prepareMutation();
Iterable<Property> glyphIconProperties = entityVertex.getProperties(VisalloProperties.ENTITY_IMAGE_VERTEX_ID.getPropertyName());
for (Property glyphIconProperty : glyphIconProperties) {
if (publishNewProperty(elementMutation, glyphIconProperty, workspaceId)) {
elementMutation.save(authorizations);
return;
}
}
LOGGER.warn("new has image edge without a glyph icon property being set on vertex %s", entityVertex.getId());
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testAddVertexWithPropertiesWithTwoDifferentVisibilities() {
Vertex v = graph.prepareVertex("v1", VISIBILITY_EMPTY)
.setProperty("prop1", "value1a", VISIBILITY_A)
.setProperty("prop1", "value1b", VISIBILITY_B)
.save(AUTHORIZATIONS_A_AND_B);
Assert.assertEquals(2, count(v.getProperties("prop1")));
graph.flush();
v = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B);
Assert.assertEquals(2, count(v.getProperties("prop1")));
v = graph.getVertex("v1", AUTHORIZATIONS_A);
Assert.assertEquals(1, count(v.getProperties("prop1")));
assertEquals("value1a", v.getPropertyValue("prop1"));
v = graph.getVertex("v1", AUTHORIZATIONS_B);
Assert.assertEquals(1, count(v.getProperties("prop1")));
assertEquals("value1b", v.getPropertyValue("prop1"));
}
代码示例来源:origin: visallo/vertexium
@Test
public void testAddVertexWithPropertiesWithTwoDifferentVisibilities() {
Vertex v = graph.prepareVertex("v1", VISIBILITY_EMPTY)
.setProperty("prop1", "value1a", VISIBILITY_A)
.setProperty("prop1", "value1b", VISIBILITY_B)
.save(AUTHORIZATIONS_A_AND_B);
Assert.assertEquals(2, count(v.getProperties("prop1")));
graph.flush();
v = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B);
Assert.assertEquals(2, count(v.getProperties("prop1")));
v = graph.getVertex("v1", AUTHORIZATIONS_A);
Assert.assertEquals(1, count(v.getProperties("prop1")));
assertEquals("value1a", v.getPropertyValue("prop1"));
v = graph.getVertex("v1", AUTHORIZATIONS_B);
Assert.assertEquals(1, count(v.getProperties("prop1")));
assertEquals("value1b", v.getPropertyValue("prop1"));
}
代码示例来源:origin: org.visallo/visallo-web
@Handle
public ClientApiDetectedObjects handle(
@Required(name = "graphVertexId") String graphVertexId,
@Required(name = "propertyName") String propertyName,
@Required(name = "workspaceId") String workspaceId,
Authorizations authorizations
) throws Exception {
Vertex vertex = graph.getVertex(graphVertexId, authorizations);
if (vertex == null) {
throw new VisalloResourceNotFoundException(String.format("vertex %s not found", graphVertexId));
}
ClientApiDetectedObjects detectedObjects = new ClientApiDetectedObjects();
Iterable<Property> detectedObjectProperties = vertex.getProperties(propertyName);
if (detectedObjectProperties == null || IterableUtils.count(detectedObjectProperties) == 0) {
throw new VisalloResourceNotFoundException(String.format("property %s not found on vertex %s", propertyName, vertex.getId()));
}
detectedObjects.addDetectedObjects(ClientApiConverter.toClientApiProperties(detectedObjectProperties, workspaceId));
return detectedObjects;
}
代码示例来源:origin: visallo/vertexium
@Test
public void testConcurrentModificationOfProperties() {
Vertex v = graph.prepareVertex("v1", VISIBILITY_EMPTY)
.setProperty("prop1", "value1", VISIBILITY_A)
.setProperty("prop2", "value2", VISIBILITY_A)
.save(AUTHORIZATIONS_A_AND_B);
int i = 0;
for (Property p : v.getProperties()) {
assertNotNull(p.toString());
if (i == 0) {
v.setProperty("prop3", "value3", VISIBILITY_A, AUTHORIZATIONS_A_AND_B);
}
i++;
}
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testConcurrentModificationOfProperties() {
Vertex v = graph.prepareVertex("v1", VISIBILITY_EMPTY)
.setProperty("prop1", "value1", VISIBILITY_A)
.setProperty("prop2", "value2", VISIBILITY_A)
.save(AUTHORIZATIONS_A_AND_B);
int i = 0;
for (Property p : v.getProperties()) {
assertNotNull(p.toString());
if (i == 0) {
v.setProperty("prop3", "value3", VISIBILITY_A, AUTHORIZATIONS_A_AND_B);
}
i++;
}
}
代码示例来源:origin: org.visallo/visallo-web-structured-ingest-core
@Test
public void testAddRowMultipleTimes() throws Exception {
String[] row = new String[]{"John Smith", "3/13/2015", "yes"};
doParse(false, true, 0, row);
Iterable<Vertex> vertices = getGraph().getVertices(authorizations);
assertEquals("Expected new vertices to be created", 3, Iterables.size(vertices));
List<Vertex> generated = getGenerated();
assertEquals("Should have created 2 entities", 2, generated.size());
Predicate<? super Vertex> hasOneConceptType = vertex -> {
List<Property> properties = Lists.newArrayList(vertex.getProperties(VisalloProperties.CONCEPT_TYPE.getPropertyName()));
return properties.size() == 1;
};
assertTrue("All have one concept type", generated.stream().allMatch(hasOneConceptType));
parserHandler.cleanUpExistingImport();
assertEquals("No linked entities after cleaning", 0, getGenerated().size());
doParse(false, true, 0, row);
assertTrue("All have one concept type after reimport", getGenerated().stream().allMatch(hasOneConceptType));
}
代码示例来源:origin: visallo/vertexium
@Test
public void testElementMutationDoesntChangeObjectUntilSave() {
Vertex v = graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_ALL);
v.setProperty("prop1", "value1-1", VISIBILITY_A, AUTHORIZATIONS_ALL);
graph.flush();
ElementMutation<Vertex> m = v.prepareMutation()
.setProperty("prop1", "value1-2", VISIBILITY_A)
.setProperty("prop2", "value2-2", VISIBILITY_A);
Assert.assertEquals(1, count(v.getProperties()));
assertEquals("value1-1", v.getPropertyValue("prop1"));
v = m.save(AUTHORIZATIONS_A_AND_B);
Assert.assertEquals(2, count(v.getProperties()));
assertEquals("value1-2", v.getPropertyValue("prop1"));
assertEquals("value2-2", v.getPropertyValue("prop2"));
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testElementMutationDoesntChangeObjectUntilSave() {
Vertex v = graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_ALL);
v.setProperty("prop1", "value1-1", VISIBILITY_A, AUTHORIZATIONS_ALL);
graph.flush();
ElementMutation<Vertex> m = v.prepareMutation()
.setProperty("prop1", "value1-2", VISIBILITY_A)
.setProperty("prop2", "value2-2", VISIBILITY_A);
Assert.assertEquals(1, count(v.getProperties()));
assertEquals("value1-1", v.getPropertyValue("prop1"));
v = m.save(AUTHORIZATIONS_A_AND_B);
Assert.assertEquals(2, count(v.getProperties()));
assertEquals("value1-2", v.getPropertyValue("prop1"));
assertEquals("value2-2", v.getPropertyValue("prop2"));
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testSoftDeletePropertyWithVisibility() {
Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A)
.addPropertyValue("key1", "name1", "value1", VISIBILITY_A)
.addPropertyValue("key1", "name1", "value2", VISIBILITY_B)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
assertEquals(2, count(graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getProperties()));
org.vertexium.test.util.IterableUtils.assertContains("value1", v1.getPropertyValues("name1"));
org.vertexium.test.util.IterableUtils.assertContains("value2", v1.getPropertyValues("name1"));
graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).softDeleteProperty("key1", "name1", VISIBILITY_A, AUTHORIZATIONS_A_AND_B);
graph.flush();
assertEquals(1, count(graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getProperties()));
assertEquals(1, count(graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getPropertyValues("key1", "name1")));
org.vertexium.test.util.IterableUtils.assertContains("value2", graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getPropertyValues("name1"));
}
代码示例来源:origin: visallo/vertexium
@Test
public void testSoftDeletePropertyWithVisibility() {
Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A)
.addPropertyValue("key1", "name1", "value1", VISIBILITY_A)
.addPropertyValue("key1", "name1", "value2", VISIBILITY_B)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
assertEquals(2, count(graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getProperties()));
org.vertexium.test.util.IterableUtils.assertContains("value1", v1.getPropertyValues("name1"));
org.vertexium.test.util.IterableUtils.assertContains("value2", v1.getPropertyValues("name1"));
graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).softDeleteProperty("key1", "name1", VISIBILITY_A, AUTHORIZATIONS_A_AND_B);
graph.flush();
assertEquals(1, count(graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getProperties()));
assertEquals(1, count(graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getPropertyValues("key1", "name1")));
org.vertexium.test.util.IterableUtils.assertContains("value2", graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getPropertyValues("name1"));
}
代码示例来源:origin: visallo/vertexium
@Test
public void testSoftDeletePropertyThroughMutationWithVisibility() {
Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A)
.addPropertyValue("key1", "name1", "value1", VISIBILITY_A)
.addPropertyValue("key1", "name1", "value2", VISIBILITY_B)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
assertEquals(2, count(graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getProperties()));
org.vertexium.test.util.IterableUtils.assertContains("value1", v1.getPropertyValues("name1"));
org.vertexium.test.util.IterableUtils.assertContains("value2", v1.getPropertyValues("name1"));
v1 = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B)
.prepareMutation()
.softDeleteProperty("key1", "name1", VISIBILITY_A)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
assertEquals(1, count(v1.getProperties()));
assertEquals(1, count(v1.getPropertyValues("key1", "name1")));
org.vertexium.test.util.IterableUtils.assertContains("value2", v1.getPropertyValues("name1"));
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testSoftDeletePropertyThroughMutationWithVisibility() {
Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A)
.addPropertyValue("key1", "name1", "value1", VISIBILITY_A)
.addPropertyValue("key1", "name1", "value2", VISIBILITY_B)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
assertEquals(2, count(graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getProperties()));
org.vertexium.test.util.IterableUtils.assertContains("value1", v1.getPropertyValues("name1"));
org.vertexium.test.util.IterableUtils.assertContains("value2", v1.getPropertyValues("name1"));
v1 = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B)
.prepareMutation()
.softDeleteProperty("key1", "name1", VISIBILITY_A)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
assertEquals(1, count(v1.getProperties()));
assertEquals(1, count(v1.getPropertyValues("key1", "name1")));
org.vertexium.test.util.IterableUtils.assertContains("value2", v1.getPropertyValues("name1"));
}
代码示例来源:origin: visallo/vertexium
@Override
public void softDeleteVertex(Vertex vertex, Long timestamp, Authorizations authorizations) {
if (!((InMemoryVertex) vertex).canRead(authorizations)) {
return;
}
if (timestamp == null) {
timestamp = IncreasingTime.currentTimeMillis();
}
for (Property property : vertex.getProperties()) {
vertex.softDeleteProperty(property.getKey(), property.getName(), property.getVisibility(), authorizations);
}
List<Edge> edgesToSoftDelete = IterableUtils.toList(vertex.getEdges(Direction.BOTH, authorizations));
for (Edge edgeToSoftDelete : edgesToSoftDelete) {
softDeleteEdge(edgeToSoftDelete, timestamp, authorizations);
}
this.vertices.getTableElement(vertex.getId()).appendSoftDeleteMutation(timestamp);
getSearchIndex().deleteElement(this, vertex, authorizations);
if (hasEventListeners()) {
fireGraphEvent(new SoftDeleteVertexEvent(this, vertex));
}
}
代码示例来源:origin: org.vertexium/vertexium-accumulo-titan-hadoop
private FaunusVertex createFaunusVertexFromRow(AccumuloGraph graph, PeekingIterator<Map.Entry<Key, Value>> row, Authorizations authorizations) {
final Vertex v = AccumuloVertexInputFormat.createVertex(graph, row, authorizations);
final long vertexId = toFaunusVertexId(v.getId());
FaunusVertex faunusVertex = new FaunusVertex();
faunusVertex.setId(vertexId);
faunusVertex.setVertexLabel(v.getId());
faunusVertex.addProperty("vertexiumId", v.getId());
for (Property property : v.getProperties()) {
if (property.getValue() instanceof StreamingPropertyValue) {
continue;
}
faunusVertex.addProperty(property.getName(), property.getValue());
}
for (EdgeInfo edgeInfo : v.getEdgeInfos(Direction.OUT, authorizations)) {
faunusVertex.addEdge(com.tinkerpop.blueprints.Direction.OUT, edgeInfo.getLabel(), toFaunusVertexId(edgeInfo.getVertexId()));
}
for (EdgeInfo edgeInfo : v.getEdgeInfos(Direction.IN, authorizations)) {
faunusVertex.addEdge(com.tinkerpop.blueprints.Direction.IN, edgeInfo.getLabel(), toFaunusVertexId(edgeInfo.getVertexId()));
}
return faunusVertex;
}
内容来源于网络,如有侵权,请联系作者删除!