protected FetchHints idFetchHintsToElementFetchHints(EnumSet<IdFetchHint> idFetchHints) { return idFetchHints.contains(IdFetchHint.INCLUDE_HIDDEN) ? FetchHints.builder().setIncludeHidden(true).build() : FetchHints.NONE; }
protected FetchHints idFetchHintsToElementFetchHints(EnumSet<IdFetchHint> idFetchHints) { return idFetchHints.contains(IdFetchHint.INCLUDE_HIDDEN) ? FetchHints.builder().setIncludeHidden(true).build() : FetchHints.NONE; }
@Override public Iterable<RelatedEdge> findRelatedEdgeSummary(Iterable<String> vertexIds, Long endTime, Authorizations authorizations) { FetchHints fetchHints = new FetchHintsBuilder() .setIncludeOutEdgeRefs(true) .build(); return findRelatedEdgeSummaryForVertices(getVertices(vertexIds, fetchHints, endTime, authorizations), authorizations); }
@Override public Iterable<RelatedEdge> findRelatedEdgeSummary(Iterable<String> vertexIds, Long endTime, Authorizations authorizations) { FetchHints fetchHints = new FetchHintsBuilder() .setIncludeOutEdgeRefs(true) .build(); return findRelatedEdgeSummaryForVertices(getVertices(vertexIds, fetchHints, endTime, authorizations), authorizations); }
@Override public Iterable<String> findRelatedEdgeIds(Iterable<String> vertexIds, Long endTime, Authorizations authorizations) { FetchHints fetchHints = new FetchHintsBuilder() .setIncludeOutEdgeRefs(true) .build(); return findRelatedEdgeIdsForVertices(getVertices(vertexIds, fetchHints, endTime, authorizations), authorizations); }
@Override public Iterable<String> findRelatedEdgeIds(Iterable<String> vertexIds, Long endTime, Authorizations authorizations) { FetchHints fetchHints = new FetchHintsBuilder() .setIncludeOutEdgeRefs(true) .build(); return findRelatedEdgeIdsForVertices(getVertices(vertexIds, fetchHints, endTime, authorizations), authorizations); }
@Override protected QueryResultsIterable<? extends VertexiumObject> extendedData(FetchHints extendedDataFetchHints) { FetchHints fetchHints = FetchHints.builder() .setIncludeExtendedDataTableNames(true) .build(); return extendedData(extendedDataFetchHints, new JoinIterable<>( allVertices(fetchHints), allEdges(fetchHints) )); }
@Override protected QueryResultsIterable<? extends VertexiumObject> extendedData(FetchHints extendedDataFetchHints) { FetchHints fetchHints = FetchHints.builder() .setIncludeExtendedDataTableNames(true) .build(); return extendedData(extendedDataFetchHints, new JoinIterable<>( allVertices(fetchHints), allEdges(fetchHints) )); }
@Override protected QueryResultsIterable<? extends VertexiumObject> extendedData(FetchHints extendedDataFetchHints) { FetchHints extendedDataTableNamesFetchHints = FetchHints.builder() .setIncludeExtendedDataTableNames(true) .build(); return extendedData(extendedDataFetchHints, new JoinIterable<>( getIterableFromElementType(ElementType.VERTEX, extendedDataTableNamesFetchHints), getIterableFromElementType(ElementType.EDGE, extendedDataTableNamesFetchHints) )); }
@Override protected QueryResultsIterable<? extends VertexiumObject> extendedData(FetchHints extendedDataFetchHints) { FetchHints extendedDataTableNamesFetchHints = FetchHints.builder() .setIncludeExtendedDataTableNames(true) .build(); return extendedData(extendedDataFetchHints, new JoinIterable<>( getIterableFromElementType(ElementType.VERTEX, extendedDataTableNamesFetchHints), getIterableFromElementType(ElementType.EDGE, extendedDataTableNamesFetchHints) )); }
@Test public void testFetchHintsExceptions() { Metadata prop1Metadata = Metadata.create(); prop1Metadata.add("metadata1", "metadata1Value", VISIBILITY_A); prop1Metadata.add("metadata2", "metadata2Value", VISIBILITY_A); graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", prop1Metadata, VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); FetchHints propertyFetchHints = FetchHints.builder() .setPropertyNamesToInclude("prop2") .build(); Vertex v1WithOnlyProp2 = graph.getVertex("v1", propertyFetchHints, AUTHORIZATIONS_A); assertNotNull(v1WithOnlyProp2.getProperties()); assertThrowsException(() -> v1WithOnlyProp2.getProperty("prop1")); FetchHints propertiesFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .build(); Vertex v1WithAllProperties = graph.getVertex("v1", propertiesFetchHints, AUTHORIZATIONS_A); assertThrowsException(v1WithAllProperties.getProperty("prop1")::getMetadata); FetchHints metadataFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .setMetadataKeysToInclude("metadata1") .build(); Vertex v1WithOnlyMetadata1 = graph.getVertex("v1", metadataFetchHints, AUTHORIZATIONS_A); Property prop1 = v1WithOnlyMetadata1.getProperty("prop1"); assertNotNull(prop1.getMetadata()); assertNotNull(v1WithOnlyMetadata1.getProperty("prop1").getMetadata().getEntry("metadata1")); assertThrowsException(() -> v1WithOnlyMetadata1.getProperty("prop1").getMetadata().getEntry("metadata2")); }
@Test public void testFetchHintsExceptions() { Metadata prop1Metadata = Metadata.create(); prop1Metadata.add("metadata1", "metadata1Value", VISIBILITY_A); prop1Metadata.add("metadata2", "metadata2Value", VISIBILITY_A); graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", prop1Metadata, VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); FetchHints propertyFetchHints = FetchHints.builder() .setPropertyNamesToInclude("prop2") .build(); Vertex v1WithOnlyProp2 = graph.getVertex("v1", propertyFetchHints, AUTHORIZATIONS_A); assertNotNull(v1WithOnlyProp2.getProperties()); assertThrowsException(() -> v1WithOnlyProp2.getProperty("prop1")); FetchHints propertiesFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .build(); Vertex v1WithAllProperties = graph.getVertex("v1", propertiesFetchHints, AUTHORIZATIONS_A); assertThrowsException(v1WithAllProperties.getProperty("prop1")::getMetadata); FetchHints metadataFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .setMetadataKeysToInclude("metadata1") .build(); Vertex v1WithOnlyMetadata1 = graph.getVertex("v1", metadataFetchHints, AUTHORIZATIONS_A); Property prop1 = v1WithOnlyMetadata1.getProperty("prop1"); assertNotNull(prop1.getMetadata()); assertNotNull(v1WithOnlyMetadata1.getProperty("prop1").getMetadata().getEntry("metadata1")); assertThrowsException(() -> v1WithOnlyMetadata1.getProperty("prop1").getMetadata().getEntry("metadata2")); }
.build(); v1 = graph.getVertex("v1", specificPropertiesFetchHints, AUTHORIZATIONS_A); Metadata n1WithoutM2 = v1.getProperty("n1").getMetadata(); .build(); Vertex v1_noMetadata = graph.getVertex("v1", noPropertiesFetchHints, AUTHORIZATIONS_A); assertThrowsException(() -> v1_noMetadata.getProperty("n1").getMetadata()); .setIncludeAllPropertyMetadata(true) .setMetadataKeysToInclude("m1", "m3") .build(); Vertex v1_withMetadata = graph.getVertex("v1", allPropertiesFetchHints, AUTHORIZATIONS_A); Metadata n1 = v1_withMetadata.getProperty("n1").getMetadata();
@Test public void testFetchHintsProperties() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); v1.addPropertyValue("k1", "n1", "value1", VISIBILITY_A, AUTHORIZATIONS_A); v1.addPropertyValue("k1", "n2", "value2", VISIBILITY_A, AUTHORIZATIONS_A); v1.addPropertyValue("k1", "n3", "value3", VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); FetchHints specificPropertiesFetchHints = FetchHints.builder() .setPropertyNamesToInclude("n1", "n3") .build(); Vertex v1WithoutN2 = graph.getVertex("v1", specificPropertiesFetchHints, AUTHORIZATIONS_A); assertEquals("value1", v1WithoutN2.getPropertyValue("n1")); assertThrowsException(() -> v1WithoutN2.getProperty("n1").getMetadata()); assertThrowsException(() -> v1WithoutN2.getPropertyValue("n2")); assertEquals("value3", v1WithoutN2.getPropertyValue("n3")); FetchHints noPropertiesFetchHints = FetchHints.NONE; Vertex v1WithNotProperties = graph.getVertex("v1", noPropertiesFetchHints, AUTHORIZATIONS_A); assertThrowsException(v1WithNotProperties::getProperties); assertThrowsException(() -> v1WithNotProperties.getProperty("n1")); FetchHints allPropertiesFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .setPropertyNamesToInclude("n1", "n3") .build(); v1 = graph.getVertex("v1", allPropertiesFetchHints, AUTHORIZATIONS_A); assertEquals("value1", v1.getPropertyValue("n1")); assertEquals("value2", v1.getPropertyValue("n2")); assertEquals("value3", v1.getPropertyValue("n3")); }
@Test public void testFetchHintsProperties() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); v1.addPropertyValue("k1", "n1", "value1", VISIBILITY_A, AUTHORIZATIONS_A); v1.addPropertyValue("k1", "n2", "value2", VISIBILITY_A, AUTHORIZATIONS_A); v1.addPropertyValue("k1", "n3", "value3", VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); FetchHints specificPropertiesFetchHints = FetchHints.builder() .setPropertyNamesToInclude("n1", "n3") .build(); Vertex v1WithoutN2 = graph.getVertex("v1", specificPropertiesFetchHints, AUTHORIZATIONS_A); assertEquals("value1", v1WithoutN2.getPropertyValue("n1")); assertThrowsException(() -> v1WithoutN2.getProperty("n1").getMetadata()); assertThrowsException(() -> v1WithoutN2.getPropertyValue("n2")); assertEquals("value3", v1WithoutN2.getPropertyValue("n3")); FetchHints noPropertiesFetchHints = FetchHints.NONE; Vertex v1WithNotProperties = graph.getVertex("v1", noPropertiesFetchHints, AUTHORIZATIONS_A); assertThrowsException(v1WithNotProperties::getProperties); assertThrowsException(() -> v1WithNotProperties.getProperty("n1")); FetchHints allPropertiesFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .setPropertyNamesToInclude("n1", "n3") .build(); v1 = graph.getVertex("v1", allPropertiesFetchHints, AUTHORIZATIONS_A); assertEquals("value1", v1.getPropertyValue("n1")); assertEquals("value2", v1.getPropertyValue("n2")); assertEquals("value3", v1.getPropertyValue("n3")); }
@Test public void testSearchingForHiddenEdges() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_ALL); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_ALL); Vertex v3 = graph.addVertex("v3", VISIBILITY_A, AUTHORIZATIONS_ALL); Edge e1 = graph.addEdge("v1tov2", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_ALL); Edge e2 = graph.addEdge("v2tov3", v2, v3, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_ALL); graph.flush(); graph.markEdgeHidden(e1, VISIBILITY_B, AUTHORIZATIONS_ALL); graph.flush(); FetchHints propertiesFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .build(); QueryResultsIterable<Edge> edges = graph.query(AUTHORIZATIONS_A) .edges(propertiesFetchHints); assertResultsCount(2, edges); assertEdgeIdsAnyOrder(edges, e1.getId(), e2.getId()); edges = graph.query(AUTHORIZATIONS_A_AND_B) .edges(propertiesFetchHints); assertResultsCount(1, edges); assertEdgeIdsAnyOrder(edges, e2.getId()); graph.markEdgeVisible(e1, VISIBILITY_B, AUTHORIZATIONS_ALL); graph.flush(); edges = graph.query(AUTHORIZATIONS_A_AND_B) .edges(propertiesFetchHints); assertResultsCount(2, edges); assertEdgeIdsAnyOrder(edges, e1.getId(), e2.getId()); }
.build(); QueryResultsIterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A) .has("name", "joe")
@Test public void testSearchingForHiddenEdges() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_ALL); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_ALL); Vertex v3 = graph.addVertex("v3", VISIBILITY_A, AUTHORIZATIONS_ALL); Edge e1 = graph.addEdge("v1tov2", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_ALL); Edge e2 = graph.addEdge("v2tov3", v2, v3, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_ALL); graph.flush(); graph.markEdgeHidden(e1, VISIBILITY_B, AUTHORIZATIONS_ALL); graph.flush(); FetchHints propertiesFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .build(); QueryResultsIterable<Edge> edges = graph.query(AUTHORIZATIONS_A) .edges(propertiesFetchHints); assertResultsCount(2, edges); assertEdgeIdsAnyOrder(edges, e1.getId(), e2.getId()); edges = graph.query(AUTHORIZATIONS_A_AND_B) .edges(propertiesFetchHints); assertResultsCount(1, edges); assertEdgeIdsAnyOrder(edges, e2.getId()); graph.markEdgeVisible(e1, VISIBILITY_B, AUTHORIZATIONS_ALL); graph.flush(); edges = graph.query(AUTHORIZATIONS_A_AND_B) .edges(propertiesFetchHints); assertResultsCount(2, edges); assertEdgeIdsAnyOrder(edges, e1.getId(), e2.getId()); }
.build(); QueryResultsIterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A) .has("prop1", "value1")