@Override public GraphQuery has(String key, Object value) { this.q.has(key, value); hasFilter = true; return this; }
@Override public GraphQuery has(String key) { this.q.has(key); hasFilter = true; return this; }
@Override @Deprecated public <T extends Comparable<T>> GraphQuery has(String key, T value, Compare compare) { org.vertexium.query.Predicate vertexiumPredicate = toVertexiumPredicate(compare); this.q.has(key, vertexiumPredicate, value); hasFilter = true; return this; }
@Override public GraphQuery has(String key, Predicate predicate, Object value) { org.vertexium.query.Predicate vertexiumPredicate = toVertexiumPredicate(predicate); this.q.has(key, vertexiumPredicate, value); hasFilter = true; return this; }
private Vertex findExistingVertexWithHash(String hash, Authorizations authorizations) { Iterator<Vertex> existingVertices = this.graph.query(authorizations) .has(VisalloProperties.CONTENT_HASH.getPropertyName(), hash) .vertices() .iterator(); if (existingVertices.hasNext()) { return existingVertices.next(); } return null; }
@Override public Iterable<Vertex> getVertices(final String key, final Object value) { final Authorizations authorizations = getAuthorizationsProvider().getAuthorizations(); return new ConvertingIterable<org.vertexium.Vertex, Vertex>(getGraph().query(authorizations).has(key, Compare.EQUAL, value).vertices(getFetchHints())) { @Override protected Vertex convert(org.vertexium.Vertex vertex) { return VertexiumBlueprintsVertex.create(VertexiumBlueprintsGraph.this, vertex, authorizations); } }; }
@Override public Iterable<Edge> getEdges(final String key, final Object value) { final Authorizations authorizations = getAuthorizationsProvider().getAuthorizations(); return new ConvertingIterable<org.vertexium.Edge, Edge>(getGraph().query(authorizations).has(key, Compare.EQUAL, value).edges(getFetchHints())) { @Override protected Edge convert(org.vertexium.Edge edge) { return VertexiumBlueprintsEdge.create(VertexiumBlueprintsGraph.this, edge, authorizations); } }; }
@Override public User findByPasswordResetToken(String token) { QueryResultsIterable<Vertex> userVertices = graph.query(authorizations) .has(UserVisalloProperties.PASSWORD_RESET_TOKEN.getPropertyName(), token) .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), userConceptId) .vertices(); Vertex user = singleOrDefault(userVertices, null); return createFromVertex(user); }
@Override public Iterable<Relationship> getRelationshipsByIRI(List<String> relationshipIRIs, String workspaceId) { QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId)) .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_RELATIONSHIP) .has(OntologyProperties.ONTOLOGY_TITLE.getPropertyName(), Contains.IN, relationshipIRIs) .vertices(); return transformRelationships(vertices, workspaceId); }
@Override protected List<Concept> findLoadedConceptsByIntent(String intent, String workspaceId) { QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId)) .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_CONCEPT) .has(OntologyProperties.INTENT.getPropertyName(), intent) .vertices(); return transformConcepts(vertices, workspaceId); }
@Test public void testGraphQueryVertexHasWithSecurityCantSeeProperty() { graph.prepareVertex("v1", VISIBILITY_A) .setProperty("age", 25, VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); Iterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A) .has("age", Compare.EQUAL, 25) .vertices(); Assert.assertEquals(0, count(vertices)); }
@Override public Iterable<Concept> getConceptsByIRI(List<String> conceptIRIs, String workspaceId) { QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId)) .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_CONCEPT) .has(OntologyProperties.ONTOLOGY_TITLE.getPropertyName(), Contains.IN, conceptIRIs) .vertices(); return transformConcepts(vertices, workspaceId); }
@Override protected List<Relationship> findLoadedRelationshipsByIntent(String intent, String workspaceId) { QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId)) .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_RELATIONSHIP) .has(OntologyProperties.INTENT.getPropertyName(), intent) .vertices(); return transformRelationships(vertices, workspaceId); }
@Override public Iterable<OntologyProperty> getPropertiesByIRI(List<String> propertyIRIs, String workspaceId) { QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId)) .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_PROPERTY) .has(OntologyProperties.ONTOLOGY_TITLE.getPropertyName(), Contains.IN, propertyIRIs) .vertices(); return transformProperties(vertices, workspaceId); }
@Override public List<OntologyProperty> getPropertiesByIntent(String intent, String workspaceId) { QueryResultsIterable<Vertex> vertices = getGraph().query(getAuthorizations(workspaceId)) .has(VisalloProperties.CONCEPT_TYPE.getPropertyName(), OntologyRepository.TYPE_PROPERTY) .has(OntologyProperties.INTENT.getPropertyName(), intent) .vertices(); return transformProperties(vertices, workspaceId); }
@Test public void testGraphQueryVertexHasWithSecurityCantSeeProperty() { graph.prepareVertex("v1", VISIBILITY_A) .setProperty("age", 25, VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); Iterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A) .has("age", Compare.EQUAL, 25) .vertices(); Assert.assertEquals(0, count(vertices)); }
@Test public void testAddVertexWithoutIndexing() { assumeTrue("add vertex without indexing not supported", !isDefaultSearchIndex()); graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_A) .setIndexHint(IndexHint.DO_NOT_INDEX) .save(AUTHORIZATIONS_A); graph.flush(); Iterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A_AND_B) .has("prop1", "value1") .vertices(); assertVertexIds(vertices); }
@Test public void testAddVertexWithoutIndexing() { assumeTrue("add vertex without indexing not supported", !isDefaultSearchIndex()); graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_A) .setIndexHint(IndexHint.DO_NOT_INDEX) .save(AUTHORIZATIONS_A); graph.flush(); Iterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A_AND_B) .has("prop1", "value1") .vertices(); assertVertexIds(vertices); }
@Test public void testGraphQueryForEdgesUsingInOrOutVertexId() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); Vertex v3 = graph.addVertex("v3", VISIBILITY_A, AUTHORIZATIONS_A); graph.addEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A); graph.addEdge("e2", v1, v3, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A); graph.addEdge("e3", v2, v3, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); QueryResultsIterable<Edge> edges = graph.query(AUTHORIZATIONS_A) .has(Edge.IN_OR_OUT_VERTEX_ID_PROPERTY_NAME, "v1") .edges(); assertEdgeIdsAnyOrder(edges, "e1", "e2"); }
@Test public void testDisableEdgeIndexing() { assumeTrue("disabling indexing not supported", disableEdgeIndexing(graph)); Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A).save(AUTHORIZATIONS_A_AND_B); Vertex v2 = graph.prepareVertex("v2", VISIBILITY_A).save(AUTHORIZATIONS_A_AND_B); graph.prepareEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); Iterable<Edge> edges = graph.query(AUTHORIZATIONS_A) .has("prop1", "value1") .edges(); Assert.assertEquals(0, count(edges)); }