protected ImmutableList<String> getDependentPropertyIris(Vertex vertex, String workspaceId) { List<Edge> dependentProperties = Lists.newArrayList(vertex.getEdges(Direction.OUT, OntologyProperties.EDGE_LABEL_DEPENDENT_PROPERTY, getAuthorizations(workspaceId))); dependentProperties.sort((e1, e2) -> { Integer o1 = OntologyProperties.DEPENDENT_PROPERTY_ORDER_PROPERTY_NAME.getPropertyValue(e1, 0); Integer o2 = OntologyProperties.DEPENDENT_PROPERTY_ORDER_PROPERTY_NAME.getPropertyValue(e2, 0); return Integer.compare(o1, o2); }); return ImmutableList.copyOf(dependentProperties.stream().map(e -> { String propertyId = e.getOtherVertexId(vertex.getId()); return propertyId.substring(VertexiumOntologyRepository.ID_PREFIX_PROPERTY.length()); }).collect(Collectors.toList())); }
@Override public void cleanUpElements(Graph graph, Vertex productVertex, Authorizations authorizations) { Iterable<Edge> productElementEdges = productVertex.getEdges( Direction.OUT, WorkspaceProperties.PRODUCT_TO_ENTITY_RELATIONSHIP_IRI, authorizations ); for (Edge productToElement : productElementEdges) { graph.softDeleteEdge(productToElement, authorizations); } graph.flush(); }
private Iterable<Edge> allEdges(FetchHints fetchHints) { Iterable<Edge> results = getSourceVertex().getEdges(getDirection(), fetchHints, getParameters().getAuthorizations()); if (getOtherVertexId() != null) { results = new FilterIterable<Edge>(results) { @Override protected boolean isIncluded(Edge edge) { return edge.getOtherVertexId(getSourceVertex().getId()).equals(getOtherVertexId()); } }; } return results; }
private Iterable<Edge> allEdges(FetchHints fetchHints) { Iterable<Edge> results = getSourceVertex().getEdges(getDirection(), fetchHints, getParameters().getAuthorizations()); if (getOtherVertexId() != null) { results = new FilterIterable<Edge>(results) { @Override protected boolean isIncluded(Edge edge) { return edge.getOtherVertexId(getSourceVertex().getId()).equals(getOtherVertexId()); } }; } return results; }
@Override public void cleanUpElements( Graph graph, Vertex productVertex, Authorizations authorizations ) { Iterable<Edge> productElementEdges = productVertex.getEdges( Direction.OUT, WorkspaceProperties.PRODUCT_TO_ENTITY_RELATIONSHIP_IRI, authorizations ); for (Edge productToElement : productElementEdges) { if (GraphProductOntology.NODE_CHILDREN.hasProperty(productToElement)) { String otherElementId = productToElement.getOtherVertexId(productVertex.getId()); graph.softDeleteVertex(otherElementId, authorizations); } else { graph.softDeleteEdge(productToElement, authorizations); } } graph.flush(); }
@Test public void testAddEdgeWithVisibility() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); graph.addEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A); graph.addEdge("e2", v1, v2, LABEL_LABEL2, VISIBILITY_B, AUTHORIZATIONS_B); graph.flush(); Iterable<Edge> aEdges = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getEdges(Direction.BOTH, AUTHORIZATIONS_A); Assert.assertEquals(1, count(aEdges)); assertEquals(LABEL_LABEL1, IterableUtils.single(aEdges).getLabel()); Iterable<Edge> bEdges = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getEdges(Direction.BOTH, AUTHORIZATIONS_B); Assert.assertEquals(1, count(bEdges)); assertEquals(LABEL_LABEL2, IterableUtils.single(bEdges).getLabel()); Iterable<Edge> allEdges = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getEdges(Direction.BOTH, AUTHORIZATIONS_A_AND_B); Assert.assertEquals(2, count(allEdges)); }
@Test public void testAddEdgeWithVisibility() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); graph.addEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A); graph.addEdge("e2", v1, v2, LABEL_LABEL2, VISIBILITY_B, AUTHORIZATIONS_B); graph.flush(); Iterable<Edge> aEdges = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getEdges(Direction.BOTH, AUTHORIZATIONS_A); Assert.assertEquals(1, count(aEdges)); assertEquals(LABEL_LABEL1, IterableUtils.single(aEdges).getLabel()); Iterable<Edge> bEdges = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getEdges(Direction.BOTH, AUTHORIZATIONS_B); Assert.assertEquals(1, count(bEdges)); assertEquals(LABEL_LABEL2, IterableUtils.single(bEdges).getLabel()); Iterable<Edge> allEdges = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getEdges(Direction.BOTH, AUTHORIZATIONS_A_AND_B); Assert.assertEquals(2, count(allEdges)); }
private Stream<Edge> findEdges( VertexiumCypherQueryContext ctx, String name, ListMultimap<String, CypherAstBase> propertiesMap, Vertex startingVertex, Direction direction, List<String> labelNames ) { if (name == null && propertiesMap.size() == 0) { return stream(startingVertex.getEdgeInfos(direction, labelNamesToArray(labelNames), ctx.getAuthorizations())) .map(edgeInfo -> new EdgeInfoEdge(ctx.getGraph(), startingVertex.getId(), edgeInfo, ctx.getFetchHints(), ctx.getAuthorizations())); } return stream(startingVertex.getEdges(direction, labelNamesToArray(labelNames), ctx.getFetchHints(), ctx.getAuthorizations())); }
private Stream<Edge> findEdges( VertexiumCypherQueryContext ctx, String name, ListMultimap<String, CypherAstBase> propertiesMap, Vertex startingVertex, Direction direction, List<String> labelNames ) { if (name == null && propertiesMap.size() == 0) { return stream(startingVertex.getEdgeInfos(direction, labelNamesToArray(labelNames), ctx.getAuthorizations())) .map(edgeInfo -> new EdgeInfoEdge(ctx.getGraph(), startingVertex.getId(), edgeInfo, ctx.getFetchHints(), ctx.getAuthorizations())); } return stream(startingVertex.getEdges(direction, labelNamesToArray(labelNames), ctx.getFetchHints(), ctx.getAuthorizations())); }
@Override public void deleteVertex(Vertex vertex, Authorizations authorizations) { if (!((InMemoryVertex) vertex).canRead(authorizations)) { return; } List<Edge> edgesToDelete = IterableUtils.toList(vertex.getEdges(Direction.BOTH, authorizations)); for (Edge edgeToDelete : edgesToDelete) { deleteEdge(edgeToDelete, authorizations); } deleteAllExtendedDataForElement(vertex, authorizations); this.vertices.remove(vertex.getId()); getSearchIndex().deleteElement(this, vertex, authorizations); if (hasEventListeners()) { fireGraphEvent(new DeleteVertexEvent(this, vertex)); } }
@Override public void markVertexHidden(Vertex vertex, Visibility visibility, Authorizations authorizations) { if (!((InMemoryVertex) vertex).canRead(authorizations)) { return; } List<Edge> edgesToMarkHidden = IterableUtils.toList(vertex.getEdges(Direction.BOTH, authorizations)); for (Edge edgeToMarkHidden : edgesToMarkHidden) { markEdgeHidden(edgeToMarkHidden, visibility, authorizations); } this.vertices.getTableElement(vertex.getId()).appendMarkHiddenMutation(visibility); refreshVertexInMemoryTableElement(vertex); getSearchIndex().markElementHidden(this, vertex, visibility, authorizations); if (hasEventListeners()) { fireGraphEvent(new MarkHiddenVertexEvent(this, vertex)); } }
@Override public void markVertexVisible(Vertex vertex, Visibility visibility, Authorizations authorizations) { if (!((InMemoryVertex) vertex).canRead(authorizations)) { return; } List<Edge> edgesToMarkVisible = IterableUtils.toList(vertex.getEdges(Direction.BOTH, FetchHints.ALL_INCLUDING_HIDDEN, authorizations)); for (Edge edgeToMarkVisible : edgesToMarkVisible) { markEdgeVisible(edgeToMarkVisible, visibility, authorizations); } this.vertices.getTableElement(vertex.getId()).appendMarkVisibleMutation(visibility); refreshVertexInMemoryTableElement(vertex); getSearchIndex().markElementVisible(this, vertex, visibility, authorizations); if (hasEventListeners()) { fireGraphEvent(new MarkVisibleVertexEvent(this, vertex)); } }
@Override public void markVertexHidden(Vertex vertex, Visibility visibility, Authorizations authorizations) { checkNotNull(vertex, "vertex cannot be null"); Span trace = Trace.start("softDeleteVertex"); trace.data("vertexId", vertex.getId()); try { ColumnVisibility columnVisibility = visibilityToAccumuloVisibility(visibility); // Delete all edges that this vertex participates. for (Edge edge : vertex.getEdges(Direction.BOTH, authorizations)) { markEdgeHidden(edge, visibility, authorizations); } addMutations(VertexiumObjectType.VERTEX, getMarkHiddenRowMutation(vertex.getId(), columnVisibility)); getSearchIndex().markElementHidden(this, vertex, visibility, authorizations); if (hasEventListeners()) { queueEvent(new MarkHiddenVertexEvent(this, vertex)); } } finally { trace.stop(); } }
@Override public void deleteVertex(Vertex vertex, Authorizations authorizations) { checkNotNull(vertex, "vertex cannot be null"); Span trace = Trace.start("deleteVertex"); trace.data("vertexId", vertex.getId()); try { getSearchIndex().deleteElement(this, vertex, authorizations); // Delete all edges that this vertex participates. for (Edge edge : vertex.getEdges(Direction.BOTH, authorizations)) { deleteEdge(edge, authorizations); } deleteAllExtendedDataForElement(vertex, authorizations); addMutations(VertexiumObjectType.VERTEX, getDeleteRowMutation(vertex.getId())); if (hasEventListeners()) { queueEvent(new DeleteVertexEvent(this, vertex)); } } finally { trace.stop(); } }
@Override public void deleteVertex(Vertex vertex, Authorizations authorizations) { checkNotNull(vertex, "vertex cannot be null"); Span trace = Trace.start("deleteVertex"); trace.data("vertexId", vertex.getId()); try { getSearchIndex().deleteElement(this, vertex, authorizations); // Delete all edges that this vertex participates. for (Edge edge : vertex.getEdges(Direction.BOTH, authorizations)) { deleteEdge(edge, authorizations); } deleteAllExtendedDataForElement(vertex, authorizations); addMutations(VertexiumObjectType.VERTEX, getDeleteRowMutation(vertex.getId())); if (hasEventListeners()) { queueEvent(new DeleteVertexEvent(this, vertex)); } } finally { trace.stop(); } }
@Override public void markVertexHidden(Vertex vertex, Visibility visibility, Authorizations authorizations) { checkNotNull(vertex, "vertex cannot be null"); Span trace = Trace.start("softDeleteVertex"); trace.data("vertexId", vertex.getId()); try { ColumnVisibility columnVisibility = visibilityToAccumuloVisibility(visibility); // Delete all edges that this vertex participates. for (Edge edge : vertex.getEdges(Direction.BOTH, authorizations)) { markEdgeHidden(edge, visibility, authorizations); } addMutations(VertexiumObjectType.VERTEX, getMarkHiddenRowMutation(vertex.getId(), columnVisibility)); getSearchIndex().markElementHidden(this, vertex, visibility, authorizations); if (hasEventListeners()) { queueEvent(new MarkHiddenVertexEvent(this, vertex)); } } finally { trace.stop(); } }
@Override public void markVertexVisible(Vertex vertex, Visibility visibility, Authorizations authorizations) { checkNotNull(vertex, "vertex cannot be null"); Span trace = Trace.start("softDeleteVertex"); trace.data("vertexId", vertex.getId()); try { ColumnVisibility columnVisibility = visibilityToAccumuloVisibility(visibility); // Delete all edges that this vertex participates. for (Edge edge : vertex.getEdges(Direction.BOTH, FetchHints.ALL_INCLUDING_HIDDEN, authorizations)) { markEdgeVisible(edge, visibility, authorizations); } addMutations(VertexiumObjectType.VERTEX, getMarkVisibleRowMutation(vertex.getId(), columnVisibility)); getSearchIndex().markElementVisible(this, vertex, visibility, authorizations); if (hasEventListeners()) { queueEvent(new MarkVisibleVertexEvent(this, vertex)); } } finally { trace.stop(); } }
@Override public void markVertexVisible(Vertex vertex, Visibility visibility, Authorizations authorizations) { checkNotNull(vertex, "vertex cannot be null"); Span trace = Trace.start("softDeleteVertex"); trace.data("vertexId", vertex.getId()); try { ColumnVisibility columnVisibility = visibilityToAccumuloVisibility(visibility); // Delete all edges that this vertex participates. for (Edge edge : vertex.getEdges(Direction.BOTH, FetchHints.ALL_INCLUDING_HIDDEN, authorizations)) { markEdgeVisible(edge, visibility, authorizations); } addMutations(VertexiumObjectType.VERTEX, getMarkVisibleRowMutation(vertex.getId(), columnVisibility)); getSearchIndex().markElementVisible(this, vertex, visibility, authorizations); if (hasEventListeners()) { queueEvent(new MarkVisibleVertexEvent(this, vertex)); } } finally { trace.stop(); } }
@Override public void softDeleteVertex(Vertex vertex, Long timestamp, Authorizations authorizations) { checkNotNull(vertex, "vertex cannot be null"); Span trace = Trace.start("softDeleteVertex"); trace.data("vertexId", vertex.getId()); try { if (timestamp == null) { timestamp = IncreasingTime.currentTimeMillis(); } getSearchIndex().deleteElement(this, vertex, authorizations); // Delete all edges that this vertex participates. for (Edge edge : vertex.getEdges(Direction.BOTH, authorizations)) { softDeleteEdge(edge, timestamp, authorizations); } addMutations(VertexiumObjectType.VERTEX, getSoftDeleteRowMutation(vertex.getId(), timestamp)); if (hasEventListeners()) { queueEvent(new SoftDeleteVertexEvent(this, vertex)); } } finally { trace.stop(); } }
@Override public void softDeleteVertex(Vertex vertex, Long timestamp, Authorizations authorizations) { checkNotNull(vertex, "vertex cannot be null"); Span trace = Trace.start("softDeleteVertex"); trace.data("vertexId", vertex.getId()); try { if (timestamp == null) { timestamp = IncreasingTime.currentTimeMillis(); } getSearchIndex().deleteElement(this, vertex, authorizations); // Delete all edges that this vertex participates. for (Edge edge : vertex.getEdges(Direction.BOTH, authorizations)) { softDeleteEdge(edge, timestamp, authorizations); } addMutations(VertexiumObjectType.VERTEX, getSoftDeleteRowMutation(vertex.getId(), timestamp)); if (hasEventListeners()) { queueEvent(new SoftDeleteVertexEvent(this, vertex)); } } finally { trace.stop(); } }