本文整理汇总了Java中org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP类的典型用法代码示例。如果您正苦于以下问题:Java LabelP类的具体用法?Java LabelP怎么用?Java LabelP使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LabelP类属于org.apache.tinkerpop.gremlin.neo4j.process.traversal包,在下文中一共展示了LabelP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureVreExistsCreatesAVreIfNeeded
import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; //导入依赖的package包/类
@Test
public void ensureVreExistsCreatesAVreIfNeeded() throws Exception {
TinkerPopGraphManager graphManager = newGraph()
.withVertex(v -> v
.withTimId(UUID.randomUUID().toString())
).wrap();
TinkerPopOperations instance = forGraphWrapper(graphManager);
instance.ensureVreExists("SomeVre");
assertThat(
graphManager.getGraph().traversal().V()
.has(T.label, LabelP.of(Vre.DATABASE_LABEL))
.has(Vre.VRE_NAME_PROPERTY_NAME, "SomeVre")
.hasNext(),
is(true)
);
}
示例2: removeRemovesEdgeBetweenTheVertexAndTheCollection
import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; //导入依赖的package包/类
@Test
public void removeRemovesEdgeBetweenTheVertexAndTheCollection() {
GraphWrapper graphWrapper =
newGraph().withVertex("collection", v -> v.withLabel(DATABASE_LABEL)
.withOutgoingRelation(HAS_ENTITY_NODE_RELATION_NAME, "entityNode")
.withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME)
.withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME))
.withVertex("entityNode", v -> v.withOutgoingRelation(HAS_ENTITY_RELATION_NAME, "entity"))
.withVertex("entity", v -> v.withLabel("entity"))
.wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of("collection")).next();
Vertex entityVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of("entity")).next();
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper, mock(CollectionDescription.class),
mock(PropertyHelper.class));
instance.remove(entityVertex);
assertThat(graphWrapper.getGraph().traversal().V(collectionVertex.id()).out(HAS_ENTITY_NODE_RELATION_NAME)
.out(HAS_ENTITY_RELATION_NAME).hasId(entityVertex.id()).hasNext(), is(false));
}
示例3: removeRemovesTheCollectionPropertiesFromTheVertex
import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; //导入依赖的package包/类
@Test
public void removeRemovesTheCollectionPropertiesFromTheVertex() {
GraphWrapper graphWrapper =
newGraph().withVertex("collection", v -> v.withLabel(DATABASE_LABEL)
.withOutgoingRelation(HAS_ENTITY_NODE_RELATION_NAME, "entityNode")
.withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME)
.withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME))
.withVertex("entityNode", v -> v.withOutgoingRelation(HAS_ENTITY_RELATION_NAME, "entity"))
.withVertex("entity", v -> v.withLabel("entity"))
.wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of("collection")).next();
Vertex entityVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of("entity")).next();
CollectionDescription description = CollectionDescription.createCollectionDescription(ENTITY_NAME, VRE_NAME);
PropertyHelper propertyHelper = mock(PropertyHelper.class);
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper, description, propertyHelper);
instance.remove(entityVertex);
verify(propertyHelper).removeProperties(entityVertex, description);
}
示例4: removeDoesNothingWhenTheEntityIsNotPartOfTheCollection
import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; //导入依赖的package包/类
@Test
public void removeDoesNothingWhenTheEntityIsNotPartOfTheCollection() {
GraphWrapper graphWrapper =
newGraph().withVertex("collection", v -> v.withLabel(DATABASE_LABEL)
.withOutgoingRelation(HAS_ENTITY_NODE_RELATION_NAME, "entityNode")
.withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME)
.withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME))
.withVertex("entityNode", v -> {
})
.withVertex("entity", v -> v.withLabel("entity"))
.wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL)).next();
Vertex entityVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of("entity")).next();
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper);
try {
instance.remove(entityVertex);
} catch (FastNoSuchElementException e) {
fail("Should not throw an exception.");
}
}
示例5: setArchetypeConnectsTheCollectionToTheNewArchetype
import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; //导入依赖的package包/类
@Test
public void setArchetypeConnectsTheCollectionToTheNewArchetype() {
String newArchetypeEntity = "newArchetype";
GraphWrapper graphWrapper =
newGraph().withVertex(v -> v.withLabel(DATABASE_LABEL)
.withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME)
.withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME))
.withVertex(v -> v.withLabel(DATABASE_LABEL)
.withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, newArchetypeEntity))
.wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL))
.has(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).next();
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper);
Vertex archetypeVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL))
.has(ENTITY_TYPE_NAME_PROPERTY_NAME, newArchetypeEntity).next();
Collection archetype = new Collection("", archetypeVertex, graphWrapper);
instance.setArchetype(archetype, "");
assertThat(graphWrapper.getGraph().traversal().V(collectionVertex.id()).out(HAS_ARCHETYPE_RELATION_NAME).toList(),
hasItem(likeVertex().withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, newArchetypeEntity)));
}
示例6: setArchetypeSetsTheUriOfTheOriginalArchetypeToEdgeToTheArchetype
import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; //导入依赖的package包/类
@Test
public void setArchetypeSetsTheUriOfTheOriginalArchetypeToEdgeToTheArchetype() {
String newArchetypeEntity = "newArchetype";
GraphWrapper graphWrapper =
newGraph().withVertex(v -> v.withLabel(DATABASE_LABEL)
.withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME)
.withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME))
.withVertex(v -> v.withLabel(DATABASE_LABEL)
.withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, newArchetypeEntity))
.wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL))
.has(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).next();
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper);
Vertex archetypeVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL))
.has(ENTITY_TYPE_NAME_PROPERTY_NAME, newArchetypeEntity).next();
Collection archetype = new Collection("", archetypeVertex, graphWrapper);
String originalArchetypeUri = "http://example.com/originalArchetype";
instance.setArchetype(archetype, originalArchetypeUri);
assertThat(graphWrapper.getGraph().traversal().V(collectionVertex.id()).outE(HAS_ARCHETYPE_RELATION_NAME).toList(),
hasItem(likeEdge().withProperty(RDF_URI_PROP, originalArchetypeUri)));
}
示例7: loadVres
import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; //导入依赖的package包/类
@Override
public Vres loadVres() {
defaultCollectionVerticesCache.clear();
ImmutableVresDto.Builder builder = ImmutableVresDto.builder();
traversal.V().has(T.label, LabelP.of(Vre.DATABASE_LABEL)).forEachRemaining(vreVertex -> {
final Vre vre = Vre.load(vreVertex);
builder.putVres(vre.getVreName(), vre);
});
return builder.build();
}
示例8: getCurrentEntitiesFor
import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; //导入依赖的package包/类
private GraphTraversal<Vertex, Vertex> getCurrentEntitiesFor(String... entityTypeNames) {
if (entityTypeNames.length == 1) {
String type = entityTypeNames[0];
return latestState.V().has(T.label, LabelP.of(type));
} else {
P<String> labels = LabelP.of(entityTypeNames[0]);
for (int i = 1; i < entityTypeNames.length; i++) {
labels = labels.or(LabelP.of(entityTypeNames[i]));
}
return latestState.V().has(T.label, labels);
}
}
示例9: getForVre
import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; //导入依赖的package包/类
public ObjectNode getForVre(String vreName, boolean withCollectionInfo) {
final List<Vertex> relations = graph.getGraph().traversal().V()
.has(T.label, LabelP.of("relationtype"))
.toList();
ObjectNode result = jsnO();
metadata.getVre(vreName)
.getCollections()
.forEach((key, coll) ->
result.set(coll.getCollectionName(), getForCollection(coll, relations, withCollectionInfo)));
return result;
}
示例10: execute
import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; //导入依赖的package包/类
@Override
public void execute(TinkerPopGraphManager graphWrapper) throws IOException {
final Graph graph = graphWrapper.getGraph();
final GraphTraversal<Vertex, Vertex> dcarDisplayNameT = graph.traversal().V()
.has(T.label, LabelP.of(Vre.DATABASE_LABEL))
.has("name", "DutchCaribbean")
.out("hasCollection")
.has("collectionName", "dcarkeywords")
.out("hasDisplayName");
// Only apply this config change if this config actually exists in the current database
if (dcarDisplayNameT.hasNext()) {
LOG.info("Changing displayName configuration for dcarkeywords to dcarkeyword_value");
final Vertex dcarDisplayName = dcarDisplayNameT.next();
final Transaction transaction = graph.tx();
if (!transaction.isOpen()) {
transaction.open();
}
dcarDisplayName.property(LocalProperty.DATABASE_PROPERTY_NAME, "dcarkeyword_value");
transaction.commit();
transaction.close();
} else {
LOG.info("Skipping change for displayName configuration of dcarkeywords " +
"as this collection does not exist in this database");
}
}
示例11: getCurrentEntitiesFor
import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; //导入依赖的package包/类
@Override
public GraphTraversal<Vertex, Vertex> getCurrentEntitiesFor(String... entityTypeNames) {
if (entityTypeNames.length == 1) {
String type = entityTypeNames[0];
return getLatestState().V().has(T.label, LabelP.of(type));
} else {
P<String> labels = LabelP.of(entityTypeNames[0]);
for (int i = 1; i < entityTypeNames.length; i++) {
labels = labels.or(LabelP.of(entityTypeNames[i]));
}
return getLatestState().V().has(T.label, labels);
}
}
示例12: findEntitiesByCollection
import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; //导入依赖的package包/类
public Set<Entity> findEntitiesByCollection(Collection collection) {
CollectionDescription description = collection.getDescription();
String typeName = description.getEntityTypeName();
String vreName = description.getVreName();
return graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL))
.has(ENTITY_TYPE_NAME_PROPERTY_NAME, typeName)
.out(HAS_ENTITY_NODE_RELATION_NAME).out(HAS_ENTITY_RELATION_NAME)
.toSet().stream().map(v -> new Entity(v, getCollections(v, vreName)))
.collect(Collectors.toSet());
}
示例13: findOrCreateCollectionReturnsTheNewlyAddedCollectionWithRdfUri
import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; //导入依赖的package包/类
@Test
public void findOrCreateCollectionReturnsTheNewlyAddedCollectionWithRdfUri() {
String vreName = "vreName";
String rdfUri = "http://www.example.com/entity";
String localName = "entity";
TinkerPopGraphManager graphWrapper = newGraph().withVertex(v -> v.withLabel(Vre.DATABASE_LABEL)
.withProperty("name", vreName))
.withVertex(v -> {
v.withLabel(Vre.DATABASE_LABEL);
v.withProperty(Vre.VRE_NAME_PROPERTY_NAME, "Admin");
v.withOutgoingRelation(Vre.HAS_COLLECTION_RELATION_NAME,
"defaultArchetype");
})
.withVertex("defaultArchetype", v -> {
v.withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "concept");
v.withProperty(COLLECTION_NAME_PROPERTY_NAME, "concepts");
})
.wrap();
Node collectionNode = mock(Node.class);
when(collectionNode.getLocalName()).thenReturn(localName);
when(collectionNode.getURI()).thenReturn(rdfUri);
Database instance = new Database(graphWrapper);
Collection collection = instance.findOrCreateCollection(vreName, collectionNode.getURI(),
collectionNode.getLocalName());
assertThat(collection, hasProperty("vreName", equalTo(vreName)));
assertThat(graphWrapper.getGraph().traversal().V()
.has(T.label, LabelP.of(Vre.DATABASE_LABEL))
.out(Vre.HAS_COLLECTION_RELATION_NAME).has(RDF_URI_PROP, rdfUri)
.hasNext(),
is(true));
assertThat(graphWrapper.getGraph().traversal().V()
.has(T.label, LabelP.of(Vre.DATABASE_LABEL))
.out(Vre.HAS_COLLECTION_RELATION_NAME).has(RDF_URI_PROP, rdfUri)
.out(HAS_ENTITY_NODE_RELATION_NAME)
.hasNext(),
is(true));
}
示例14: shouldSupportHasContainersWithMultiLabels
import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; //导入依赖的package包/类
@Test
public void shouldSupportHasContainersWithMultiLabels() throws Exception {
final Neo4jVertex vertex = (Neo4jVertex) this.graph.addVertex(T.label, "person", "name", "marko");
graph.tx().commit();
assertTrue(g.V().has(T.label, "person").hasNext());
assertEquals("marko", g.V().has(T.label, LabelP.of("person")).values("name").next());
assertEquals("marko", g.V().has(T.label, "person").values("name").next());
// more labels
vertex.addLabel("animal");
vertex.addLabel("object");
graph.tx().commit();
// no indices (neo4j graph step)
assertFalse(g.V().has(T.label, "person").hasNext());
assertEquals("marko", g.V().has(T.label, LabelP.of("person")).values("name").next());
assertEquals("marko", g.V().has(T.label, LabelP.of("animal")).values("name").next());
assertEquals("marko", g.V().has(T.label, LabelP.of("object")).values("name").next());
// no indices (has step)
assertFalse(g.V().as("a").select("a").has(T.label, "person").hasNext());
assertEquals("marko", g.V().as("a").select("a").has(T.label, LabelP.of("person")).values("name").next());
assertEquals("marko", g.V().as("a").select("a").has(T.label, LabelP.of("animal")).values("name").next());
assertEquals("marko", g.V().as("a").select("a").has(T.label, LabelP.of("object")).values("name").next());
// indices (neo4j graph step)
this.getGraph().cypher("CREATE INDEX ON :person(name)").iterate();
graph.tx().commit();
Thread.sleep(500);
assertFalse(g.V().has(T.label, "person").has("name", "marko").hasNext());
assertEquals("marko", g.V().has(T.label, LabelP.of("person")).has("name", "marko").values("name").next());
assertEquals("marko", g.V().has(T.label, LabelP.of("animal")).has("name", "marko").values("name").next());
assertEquals("marko", g.V().has(T.label, LabelP.of("object")).has("name", "marko").values("name").next());
this.getGraph().cypher("CREATE INDEX ON :animal(name)").iterate();
graph.tx().commit();
Thread.sleep(500);
assertFalse(g.V().has(T.label, "animal").has("name", "marko").hasNext());
assertEquals("marko", g.V().has(T.label, LabelP.of("person")).has("name", "marko").values("name").next());
assertEquals("marko", g.V().has(T.label, LabelP.of("animal")).has("name", "marko").values("name").next());
assertEquals("marko", g.V().has(T.label, LabelP.of("object")).has("name", "marko").values("name").next());
this.getGraph().cypher("CREATE INDEX ON :object(name)").iterate();
graph.tx().commit();
Thread.sleep(500);
assertFalse(g.V().has(T.label, "object").has("name", "marko").hasNext());
assertEquals("marko", g.V().has(T.label, LabelP.of("person")).has("name", "marko").values("name").next());
assertEquals("marko", g.V().has(T.label, LabelP.of("animal")).has("name", "marko").values("name").next());
assertEquals("marko", g.V().has(T.label, LabelP.of("object")).has("name", "marko").values("name").next());
}
示例15: shouldSupportNeo4jMultiLabels
import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; //导入依赖的package包/类
@Test
public void shouldSupportNeo4jMultiLabels() {
final Neo4jVertex vertex = (Neo4jVertex) graph.addVertex(T.label, "animal::person", "name", "marko");
tryCommit(graph, graph -> {
assertTrue(vertex.label().equals("animal::person"));
assertEquals(2, vertex.labels().size());
assertTrue(vertex.labels().contains("person"));
assertTrue(vertex.labels().contains("animal"));
assertEquals(2, IteratorUtils.count(vertex.getBaseVertex().labels().iterator()));
});
vertex.addLabel("organism");
tryCommit(graph, graph -> {
assertTrue(vertex.label().equals("animal::organism::person"));
assertEquals(3, vertex.labels().size());
assertTrue(vertex.labels().contains("person"));
assertTrue(vertex.labels().contains("animal"));
assertTrue(vertex.labels().contains("organism"));
assertEquals(3, IteratorUtils.count(vertex.getBaseVertex().labels().iterator()));
});
vertex.removeLabel("person");
tryCommit(graph, graph -> {
assertTrue(vertex.label().equals("animal::organism"));
assertEquals(2, vertex.labels().size());
assertTrue(vertex.labels().contains("animal"));
assertTrue(vertex.labels().contains("organism"));
});
vertex.addLabel("organism"); // repeat add
vertex.removeLabel("person"); // repeat remove
tryCommit(graph, graph -> {
assertTrue(vertex.label().equals("animal::organism"));
assertEquals(2, vertex.labels().size());
assertTrue(vertex.labels().contains("animal"));
assertTrue(vertex.labels().contains("organism"));
assertEquals(2, IteratorUtils.count(vertex.getBaseVertex().labels().iterator()));
});
assertEquals(Long.valueOf(0), g.V().has(T.label, "organism").count().next());
assertEquals(Long.valueOf(1), g.V().has(T.label, LabelP.of("organism")).count().next());
assertEquals(Long.valueOf(1), g.V().has(T.label, LabelP.of("animal")).count().next());
vertex.removeLabel("organism");
vertex.removeLabel("animal");
assertEquals(0, vertex.labels().size());
vertex.addLabel("organism-animal");
tryCommit(graph, graph -> {
assertEquals(Long.valueOf(0), g.V().has(T.label, LabelP.of("organism")).count().next());
assertEquals(Long.valueOf(0), g.V().has(T.label, LabelP.of("animal")).count().next());
assertEquals(Long.valueOf(0), g.V().map(Traverser::get).has(T.label, LabelP.of("organism")).count().next());
assertEquals(Long.valueOf(0), g.V().map(Traverser::get).has(T.label, LabelP.of("animal")).count().next());
//
assertEquals(Long.valueOf(1), g.V().has(T.label, LabelP.of("organism-animal")).count().next());
assertEquals(Long.valueOf(1), g.V().has(T.label, "organism-animal").count().next());
assertEquals(Long.valueOf(1), g.V().map(Traverser::get).has(T.label, LabelP.of("organism-animal")).count().next());
assertEquals(Long.valueOf(1), g.V().map(Traverser::get).has(T.label, "organism-animal").count().next());
});
}