use of com.tinkerpop.blueprints.Edge in project blueprints by tinkerpop.
the class Neo4j2GraphSpecificTestSuite method testAutoStartTxOnEdgeIterables.
public void testAutoStartTxOnEdgeIterables() throws Exception {
Neo4j2Graph graph = (Neo4j2Graph) graphTest.generateGraph();
Vertex a = graph.addVertex(null);
Vertex b = graph.addVertex(null);
Neo4j2Edge edge = graph.addEdge(null, a, b, "testEdge");
edge.setProperty("foo", "bar");
Iterable<Edge> iterable = graph.getEdges();
graph.commit();
try {
assertTrue(iterable.iterator().hasNext());
assertNotNull(iterable.iterator().next());
assertNotNull(graph.getEdges("foo", "bar").iterator().hasNext());
} catch (NotInTransactionException e) {
fail("Iterating edge iterable does not auto-start transaction");
} finally {
graph.shutdown();
}
}
use of com.tinkerpop.blueprints.Edge in project blueprints by tinkerpop.
the class Neo4jGraphSpecificTestSuite method testQueryIndex.
public void testQueryIndex() throws Exception {
Neo4jGraph graph = (Neo4jGraph) graphTest.generateGraph();
Index<Vertex> vertexIndex = graph.createIndex("vertices", Vertex.class);
Index<Edge> edgeIndex = graph.createIndex("edges", Edge.class);
Vertex a = graph.addVertex(null);
a.setProperty("name", "marko");
vertexIndex.put("name", "marko", a);
Iterator itty = graph.getIndex("vertices", Vertex.class).query("name", "*rko").iterator();
int counter = 0;
while (itty.hasNext()) {
counter++;
assertEquals(itty.next(), a);
}
assertEquals(counter, 1);
Vertex b = graph.addVertex(null);
Edge edge = graph.addEdge(null, a, b, "knows");
edge.setProperty("weight", 0.75);
edgeIndex.put("weight", 0.75, edge);
itty = graph.getIndex("edges", Edge.class).query("label", "k?ows").iterator();
counter = 0;
while (itty.hasNext()) {
counter++;
assertEquals(itty.next(), edge);
}
assertEquals(counter, 0);
itty = graph.getIndex("edges", Edge.class).query("weight", "[0.5 TO 1.0]").iterator();
counter = 0;
while (itty.hasNext()) {
counter++;
assertEquals(itty.next(), edge);
}
assertEquals(counter, 1);
assertEquals(count(graph.getIndex("edges", Edge.class).query("weight", "[0.1 TO 0.5]")), 0);
graph.shutdown();
}
use of com.tinkerpop.blueprints.Edge in project incubator-atlas by apache.
the class AtlasEntityTagQuery method getQueryPipe.
@Override
protected Pipe getQueryPipe() {
GremlinPipeline p;
if (guid.equals("*")) {
p = new GremlinPipeline().has(Constants.ENTITY_TEXT_PROPERTY_KEY).hasNot(Constants.ENTITY_TYPE_PROPERTY_KEY, "Taxonomy").outE();
} else {
p = new GremlinPipeline().has(Constants.GUID_PROPERTY_KEY, guid).outE();
}
// todo: this is basically the same pipeline used in TagRelation.asPipe()
p.add(new FilterFunctionPipe<>(new PipeFunction<Edge, Boolean>() {
@Override
public Boolean compute(Edge edge) {
String type = edge.getVertex(Direction.OUT).getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY);
VertexWrapper v = new TermVertexWrapper(edge.getVertex(Direction.IN));
return edge.getLabel().startsWith(type) && v.getPropertyKeys().contains("available_as_tag");
}
}));
return p.inV();
}
use of com.tinkerpop.blueprints.Edge in project incubator-atlas by apache.
the class TraitRelation method traverse.
@Override
public Collection<RelationSet> traverse(VertexWrapper vWrapper) {
Vertex v = vWrapper.getVertex();
Collection<VertexWrapper> vertices = new ArrayList<>();
for (Edge e : v.getEdges(Direction.OUT)) {
if (e.getLabel().startsWith(v.<String>getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY))) {
VertexWrapper trait = new TermVertexWrapper(e.getVertex(Direction.IN));
if (!trait.getPropertyKeys().contains("available_as_tag") && !isDeleted(trait.getVertex())) {
vertices.add(trait);
}
}
}
return Collections.singletonList(new RelationSet("traits", vertices));
}
use of com.tinkerpop.blueprints.Edge in project frames by tinkerpop.
the class TypedGraphModuleTest method testDeserializeEdgeType.
public void testDeserializeEdgeType() {
Graph graph = new TinkerGraph();
FramedGraphFactory factory = new FramedGraphFactory(new TypedGraphModuleBuilder().withClass(A.class).withClass(B.class).withClass(C.class).build());
FramedGraph<Graph> framedGraph = factory.create(graph);
Vertex v1 = graph.addVertex(null);
Vertex v2 = graph.addVertex(null);
Edge cE = graph.addEdge(null, v1, v2, "label");
cE.setProperty("type", "C");
Base c = framedGraph.getEdge(cE.getId(), Direction.OUT, Base.class);
assertTrue(c instanceof C);
}
Aggregations