@Nonnull @Override public IdVertexQuery<?, G> query() { return new IdVertexQuery<>(base.query(), graph); }
@Nonnull @Override public ElementVertexQuery query() { return new ElementVertexQuery(base.query(), graph); }
public VertexQuery query() { return new WrapperVertexQuery(this.baseVertex.query()) { @Override public Iterable<Edge> edges() { return new ShellEdgeIterable(this.query.edges()); } @Override public Iterable<Vertex> vertices() { return new AdjacentShellVertexIterable(this.query.vertices()); } }; }
@Override public AtlasVertexQuery<Titan0Vertex, Titan0Edge> query() { return new Titan0VertexQuery(graph, wrappedElement.query()); }
@Override public Term next() { VertexQuery query = this.it.next().query(); query.has("index", position); return vertexToTerm(query.vertices().iterator().next()); }
protected Edge processNextStart() { while (true) { if (this.nextEnds.hasNext()) { return this.nextEnds.next(); } else { this.nextEnds = this.doBranchFactor ? this.starts.next().query().direction(this.direction).labels(this.labels).limit(this.branchFactor).edges().iterator() : this.starts.next().getEdges(this.direction, this.labels).iterator(); } } }
public VertexQuery query() { return new WrapperVertexQuery(((Vertex) this.baseElement).query()) { @Override public Iterable<Vertex> vertices() { return new IdVertexIterable(this.query.vertices(), idGraph); } @Override public Iterable<Edge> edges() { return new IdEdgeIterable(this.query.edges(), idGraph); } }; }
public VertexQuery query() { return new WrapperVertexQuery(((Vertex) this.baseElement).query()) { @Override public Iterable<Vertex> vertices() { return new WrappedVertexIterable(this.query.vertices()); } @Override public Iterable<Edge> edges() { return new WrappedEdgeIterable(this.query.edges()); } }; }
public VertexQuery query() { return new WrapperVertexQuery(((Vertex) this.baseElement).query()) { @Override public Iterable<Vertex> vertices() { return new EventVertexIterable(this.query.vertices(), eventGraph); } @Override public Iterable<Edge> edges() { return new EventEdgeIterable(this.query.edges(), eventGraph); } }; }
protected Vertex processNextStart() { while (true) { if (this.nextEnds.hasNext()) { return this.nextEnds.next(); } else { this.nextEnds = this.doBranchFactor ? this.starts.next().query().direction(this.direction).labels(this.labels).limit(this.branchFactor).vertices().iterator() : this.starts.next().getVertices(this.direction, this.labels).iterator(); } } }
public VertexQuery query() { return new WrapperVertexQuery(((Vertex) this.baseElement).query()) { @Override public Iterable<Vertex> vertices() { return new PartitionVertexIterable(this.query.vertices(), graph); } @Override public Iterable<Edge> edges() { return new PartitionEdgeIterable(this.query.edges(), graph); } }; }
public VertexQuery query() { return new WrapperVertexQuery(((Vertex) this.baseElement).query()) { @Override public Iterable<Vertex> vertices() { return new ReadOnlyVertexIterable(this.query.vertices()); } @Override public Iterable<Edge> edges() { return new ReadOnlyEdgeIterable(this.query.edges()); } }; } }
@Override public VertexQuery query() { return new WrapperVertexQuery(((Vertex) getRaw()).query()) { @Override public Iterable<Vertex> vertices() { return new ActiveVersionedVertexIterable<V>(this.query.vertices(), getGraph()); } @Override public Iterable<Edge> edges() { return new ActiveVersionedEdgeIterable<V>(this.query.edges(), getGraph()); } }; }
public VertexQuery build(final Vertex vertex) { VertexQuery query = vertex.query(); for (final HasContainer hasContainer : this.hasContainers) { query = query.has(hasContainer.key, hasContainer.predicate, hasContainer.value); } return query.limit(this.limit).labels(this.labels).direction(this.direction); } }
@Override protected void clearReference(PersistentEObject object, EReference reference) { Vertex vertex = backend.getOrCreateVertex(object); for (Edge edge : vertex.query().labels(reference.getName()).direction(Direction.OUT).edges()) { edge.remove(); } setSize(vertex, reference, 0); }
@Override protected Object getReference(PersistentEObject object, EReference reference, int index) { Object soughtReference = null; Vertex vertex = backend.getVertex(object.id()); Vertex referencedVertex; if (!reference.isMany()) { referencedVertex = Iterables.getOnlyElement( vertex.getVertices(Direction.OUT, reference.getName()), null); } else { checkElementIndex(index, getSize(vertex, reference), "Invalid get index " + index); referencedVertex = Iterables.getOnlyElement( vertex.query() .labels(reference.getName()) .direction(Direction.OUT) .has(POSITION, index) .vertices(), null); } if (nonNull(referencedVertex)) { soughtReference = reifyVertex(referencedVertex); } return soughtReference; }
@Override public boolean hasSingleRelation(Vertex source, RelationTypeMetadata<TitanEdgeMetadata> metadata, RelationTypeMetadata.Direction direction) { String label = metadata.getDatastoreMetadata().getDiscriminator(); long count; switch (direction) { case FROM: count = source.query().direction(Direction.OUT).labels(label) .count(); break; case TO: count = source.query().direction(Direction.IN).labels(label) .count(); break; default: throw new XOException("Unkown direction '" + direction.name() + "'."); } if (count > 1) { throw new XOException("Multiple results are available."); } return count == 1; }
@Override protected void unsetReference(PersistentEObject object, EReference reference) { Vertex vertex = backend.getVertex(object.id()); if (!reference.isMany()) { Edge edge = Iterables.getOnlyElement(vertex.getEdges(Direction.OUT, reference.getName()), null); if (nonNull(edge)) { edge.remove(); } } else { for (Edge edge : vertex.query().labels(reference.getName()).direction(Direction.OUT).edges()) { edge.remove(); } vertex.removeProperty(reference.getName() + SEPARATOR + SIZE_LITERAL); } }
@Override public Iterable<Edge> getRelations(Vertex source, RelationTypeMetadata<TitanEdgeMetadata> metadata, RelationTypeMetadata.Direction direction) { VertexQuery query = source.query(); String discriminator = metadata.getDatastoreMetadata() .getDiscriminator(); switch (direction) { case TO: query = query.direction(Direction.IN).labels(discriminator); break; case FROM: query = query.direction(Direction.OUT).labels(discriminator); break; default: throw new XOException("Unknown direction '" + direction.name() + "'."); } return query.edges(); }
public void testVertexEdgesWithNonVisibleVertexOnOtherEnd() { Graph graph = graphTest.generateGraph(); if (!(graph instanceof VertexiumBlueprintsGraph)) { throw new RuntimeException("Invalid graph"); } org.vertexium.Graph vertexiumGraph = ((VertexiumBlueprintsGraph) graph).getGraph(); Authorizations aAuthorizations = vertexiumGraph.createAuthorizations("a"); org.vertexium.Vertex v1 = vertexiumGraph.addVertex("v1", new Visibility(""), aAuthorizations); org.vertexium.Vertex v2 = vertexiumGraph.addVertex("v2", new Visibility("a"), aAuthorizations); org.vertexium.Vertex v3 = vertexiumGraph.addVertex("v3", new Visibility(""), aAuthorizations); vertexiumGraph.addEdge("e1to2", v1, v2, "label", new Visibility(""), aAuthorizations); vertexiumGraph.addEdge("e1to3", v1, v3, "label", new Visibility(""), aAuthorizations); vertexiumGraph.flush(); Vertex blueV1 = graph.getVertex("v1"); assertEquals(1, count(blueV1.getEdges(Direction.BOTH, "label"))); assertEquals(1, count(blueV1.getVertices(Direction.BOTH, "label"))); assertEquals(1, count((Iterable) blueV1.query().direction(Direction.BOTH).vertexIds())); graph.shutdown(); } }