@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(); }
@Test public void testFindRelatedEdgeSummaryAfterSoftDelete() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); Edge e1 = graph.addEdge("e v1->v2", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); List<String> vertexIds = new ArrayList<>(); vertexIds.add("v1"); vertexIds.add("v2"); List<RelatedEdge> relatedEdges = toList(graph.findRelatedEdgeSummary(vertexIds, AUTHORIZATIONS_A)); assertEquals(1, relatedEdges.size()); org.vertexium.test.util.IterableUtils.assertContains(new RelatedEdgeImpl("e v1->v2", LABEL_LABEL1, v1.getId(), v2.getId()), relatedEdges); graph.softDeleteEdge(e1, AUTHORIZATIONS_A); graph.flush(); relatedEdges = toList(graph.findRelatedEdgeSummary(vertexIds, AUTHORIZATIONS_A)); assertEquals(0, relatedEdges.size()); }
@Test public void testFindRelatedEdgeSummaryAfterSoftDelete() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); Edge e1 = graph.addEdge("e v1->v2", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); List<String> vertexIds = new ArrayList<>(); vertexIds.add("v1"); vertexIds.add("v2"); List<RelatedEdge> relatedEdges = toList(graph.findRelatedEdgeSummary(vertexIds, AUTHORIZATIONS_A)); assertEquals(1, relatedEdges.size()); org.vertexium.test.util.IterableUtils.assertContains(new RelatedEdgeImpl("e v1->v2", LABEL_LABEL1, v1.getId(), v2.getId()), relatedEdges); graph.softDeleteEdge(e1, AUTHORIZATIONS_A); graph.flush(); relatedEdges = toList(graph.findRelatedEdgeSummary(vertexIds, AUTHORIZATIONS_A)); assertEquals(0, relatedEdges.size()); }
ctx.getGraph().softDeleteVertex(childId, authorizations); } else { ctx.getGraph().softDeleteEdge(childEdgeId, authorizations); ctx.getGraph().softDeleteEdge(edgeId, authorizations);
public void unresolveTerm(Vertex termMention, Authorizations authorizations) { Vertex outVertex = termMentionRepository.findOutVertex(termMention, authorizations); if (outVertex == null) { return; } String resolveEdgeId = VisalloProperties.TERM_MENTION_RESOLVED_EDGE_ID.getPropertyValue(termMention, null); if (resolveEdgeId != null) { Edge resolveEdge = graph.getEdge(resolveEdgeId, authorizations); long beforeDeletionTimestamp = System.currentTimeMillis() - 1; graph.softDeleteEdge(resolveEdge, authorizations); graph.flush(); workQueueRepository.pushEdgeDeletion(resolveEdge, beforeDeletionTimestamp, Priority.HIGH); } termMentionRepository.delete(termMention, authorizations); workQueueRepository.pushTextUpdated(outVertex.getId()); graph.flush(); }
@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 testFindRelatedEdgeSummaryAfterSoftDeleteAndReAdd() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); Edge e1 = graph.addEdge("e v1->v2", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); List<String> vertexIds = new ArrayList<>(); vertexIds.add("v1"); vertexIds.add("v2"); List<RelatedEdge> relatedEdges = toList(graph.findRelatedEdgeSummary(vertexIds, AUTHORIZATIONS_A)); assertEquals(1, relatedEdges.size()); org.vertexium.test.util.IterableUtils.assertContains(new RelatedEdgeImpl("e v1->v2", LABEL_LABEL1, v1.getId(), v2.getId()), relatedEdges); graph.softDeleteEdge(e1, AUTHORIZATIONS_A); graph.flush(); graph.prepareEdge("e v1->v2", v1, v2, LABEL_LABEL1, VISIBILITY_A) .save(AUTHORIZATIONS_A); graph.flush(); relatedEdges = toList(graph.findRelatedEdgeSummary(vertexIds, AUTHORIZATIONS_A)); assertEquals(1, relatedEdges.size()); org.vertexium.test.util.IterableUtils.assertContains(new RelatedEdgeImpl("e v1->v2", LABEL_LABEL1, v1.getId(), v2.getId()), relatedEdges); }
@Test public void testFindRelatedEdgeSummaryAfterSoftDeleteAndReAdd() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); Edge e1 = graph.addEdge("e v1->v2", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); List<String> vertexIds = new ArrayList<>(); vertexIds.add("v1"); vertexIds.add("v2"); List<RelatedEdge> relatedEdges = toList(graph.findRelatedEdgeSummary(vertexIds, AUTHORIZATIONS_A)); assertEquals(1, relatedEdges.size()); org.vertexium.test.util.IterableUtils.assertContains(new RelatedEdgeImpl("e v1->v2", LABEL_LABEL1, v1.getId(), v2.getId()), relatedEdges); graph.softDeleteEdge(e1, AUTHORIZATIONS_A); graph.flush(); graph.prepareEdge("e v1->v2", v1, v2, LABEL_LABEL1, VISIBILITY_A) .save(AUTHORIZATIONS_A); graph.flush(); relatedEdges = toList(graph.findRelatedEdgeSummary(vertexIds, AUTHORIZATIONS_A)); assertEquals(1, relatedEdges.size()); org.vertexium.test.util.IterableUtils.assertContains(new RelatedEdgeImpl("e v1->v2", LABEL_LABEL1, v1.getId(), v2.getId()), relatedEdges); }
@Override public void updatePropertyDomainIris(OntologyProperty property, Set<String> domainIris, User user, String workspaceId) { VertexiumOntologyProperty vertexiumProperty = (VertexiumOntologyProperty) property; if (!isPublic(workspaceId) && property.getSandboxStatus() != SandboxStatus.PRIVATE) { throw new UnsupportedOperationException("Sandboxed updating of domain iris is not currently supported for published properties"); } Iterable<EdgeVertexPair> existingConcepts = vertexiumProperty.getVertex().getEdgeVertexPairs(Direction.BOTH, LabelName.HAS_PROPERTY.toString(), getAuthorizations(workspaceId)); for (EdgeVertexPair existingConcept : existingConcepts) { String conceptIri = OntologyProperties.ONTOLOGY_TITLE.getPropertyValue(existingConcept.getVertex()); if (!domainIris.remove(conceptIri)) { getGraph().softDeleteEdge(existingConcept.getEdge(), getAuthorizations(workspaceId)); } } for (String domainIri : domainIris) { Vertex domainVertex; Concept concept = getConceptByIRI(domainIri, workspaceId); if (concept != null) { domainVertex = ((VertexiumConcept) concept).getVertex(); } else { Relationship relationship = getRelationshipByIRI(domainIri, workspaceId); if (relationship != null) { domainVertex = ((VertexiumRelationship) relationship).getVertex(); } else { throw new VisalloException("Could not find domain with IRI " + domainIri); } } findOrAddEdge(domainVertex, ((VertexiumOntologyProperty) property).getVertex(), LabelName.HAS_PROPERTY.toString(), user, workspaceId); } }
@Test public void testFindPathsWithSoftDeletedEdges() { Vertex v1 = graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_A); Vertex v2 = graph.addVertex("v2", VISIBILITY_EMPTY, AUTHORIZATIONS_A); Vertex v3 = graph.addVertex("v3", VISIBILITY_EMPTY, AUTHORIZATIONS_A); graph.addEdge(v1, v2, LABEL_LABEL1, VISIBILITY_EMPTY, AUTHORIZATIONS_A); // v1 -> v2 Edge v2ToV3 = graph.addEdge(v2, v3, LABEL_LABEL1, VISIBILITY_EMPTY, AUTHORIZATIONS_A); // v2 -> v3 graph.flush(); List<Path> paths = toList(graph.findPaths(new FindPathOptions("v1", "v3", 2), AUTHORIZATIONS_A)); assertPaths( paths, new Path("v1", "v2", "v3") ); graph.softDeleteEdge(v2ToV3, AUTHORIZATIONS_A); graph.flush(); assertNull(graph.getEdge(v2ToV3.getId(), AUTHORIZATIONS_A)); paths = toList(graph.findPaths(new FindPathOptions("v1", "v3", 2), AUTHORIZATIONS_A)); assertEquals(0, paths.size()); }
getGraph().softDeleteEdge(edgeInfo.getEdgeId(), authorizations); });
@Test public void testFindPathsWithSoftDeletedEdges() { Vertex v1 = graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_A); Vertex v2 = graph.addVertex("v2", VISIBILITY_EMPTY, AUTHORIZATIONS_A); Vertex v3 = graph.addVertex("v3", VISIBILITY_EMPTY, AUTHORIZATIONS_A); graph.addEdge(v1, v2, LABEL_LABEL1, VISIBILITY_EMPTY, AUTHORIZATIONS_A); // v1 -> v2 Edge v2ToV3 = graph.addEdge(v2, v3, LABEL_LABEL1, VISIBILITY_EMPTY, AUTHORIZATIONS_A); // v2 -> v3 graph.flush(); List<Path> paths = toList(graph.findPaths(new FindPathOptions("v1", "v3", 2), AUTHORIZATIONS_A)); assertPaths( paths, new Path("v1", "v2", "v3") ); graph.softDeleteEdge(v2ToV3, AUTHORIZATIONS_A); graph.flush(); assertNull(graph.getEdge(v2ToV3.getId(), AUTHORIZATIONS_A)); paths = toList(graph.findPaths(new FindPathOptions("v1", "v3", 2), AUTHORIZATIONS_A)); assertEquals(0, paths.size()); }
)).collect(Collectors.toList()); for (Edge edge : edges) { getGraph().softDeleteEdge(edge, authorizations);
this.workQueueRepository.pushEdgeHidden(edge, beforeActionTimestamp, Priority.HIGH); } else { graph.softDeleteEdge(edge, authorizations);
@Test public void testReAddingSoftDeletedEdge() { 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.flush(); Edge e1 = graph.getEdge("e1", AUTHORIZATIONS_A); graph.softDeleteEdge(e1, AUTHORIZATIONS_A); graph.flush(); graph.prepareEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A) .save(AUTHORIZATIONS_A); graph.flush(); e1 = graph.getEdge("e1", AUTHORIZATIONS_A); assertNotNull(e1); assertEquals(VISIBILITY_A.getVisibilityString(), e1.getVisibility().getVisibilityString()); v1 = graph.getVertex("v1", AUTHORIZATIONS_A); assertEquals(1, count(v1.getEdgeIds(Direction.BOTH, AUTHORIZATIONS_A))); assertEquals(1, count(v1.getEdges(Direction.BOTH, AUTHORIZATIONS_A))); assertEquals(1, count(v1.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A))); v2 = graph.getVertex("v2", AUTHORIZATIONS_A); assertEquals(1, count(v2.getEdgeIds(Direction.BOTH, AUTHORIZATIONS_A))); assertEquals(1, count(v2.getEdges(Direction.BOTH, AUTHORIZATIONS_A))); assertEquals(1, count(v2.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A))); }
@Test public void testReAddingSoftDeletedEdge() { 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.flush(); Edge e1 = graph.getEdge("e1", AUTHORIZATIONS_A); graph.softDeleteEdge(e1, AUTHORIZATIONS_A); graph.flush(); graph.prepareEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A) .save(AUTHORIZATIONS_A); graph.flush(); e1 = graph.getEdge("e1", AUTHORIZATIONS_A); assertNotNull(e1); assertEquals(VISIBILITY_A.getVisibilityString(), e1.getVisibility().getVisibilityString()); v1 = graph.getVertex("v1", AUTHORIZATIONS_A); assertEquals(1, count(v1.getEdgeIds(Direction.BOTH, AUTHORIZATIONS_A))); assertEquals(1, count(v1.getEdges(Direction.BOTH, AUTHORIZATIONS_A))); assertEquals(1, count(v1.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A))); v2 = graph.getVertex("v2", AUTHORIZATIONS_A); assertEquals(1, count(v2.getEdgeIds(Direction.BOTH, AUTHORIZATIONS_A))); assertEquals(1, count(v2.getEdges(Direction.BOTH, AUTHORIZATIONS_A))); assertEquals(1, count(v2.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A))); }
@Test public void testGetSoftDeletedElementWithFetchHintsAndTimestamp() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); Edge e1 = graph.addEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); long beforeDeleteTime = IncreasingTime.currentTimeMillis(); graph.softDeleteEdge(e1, AUTHORIZATIONS_A); graph.softDeleteVertex(v1, AUTHORIZATIONS_A); graph.flush(); assertNull(graph.getEdge(e1.getId(), AUTHORIZATIONS_A)); assertNull(graph.getEdge(e1.getId(), graph.getDefaultFetchHints(), AUTHORIZATIONS_A)); assertNull(graph.getEdge(e1.getId(), FetchHints.ALL_INCLUDING_HIDDEN, AUTHORIZATIONS_A)); assertNull(graph.getVertex(v1.getId(), AUTHORIZATIONS_A)); assertNull(graph.getVertex(v1.getId(), graph.getDefaultFetchHints(), AUTHORIZATIONS_A)); assertNull(graph.getVertex(v1.getId(), FetchHints.ALL_INCLUDING_HIDDEN, AUTHORIZATIONS_A)); assertNotNull(graph.getEdge(e1.getId(), graph.getDefaultFetchHints(), beforeDeleteTime, AUTHORIZATIONS_A)); assertNotNull(graph.getEdge(e1.getId(), FetchHints.ALL_INCLUDING_HIDDEN, beforeDeleteTime, AUTHORIZATIONS_A)); assertNotNull(graph.getVertex(v1.getId(), graph.getDefaultFetchHints(), beforeDeleteTime, AUTHORIZATIONS_A)); assertNotNull(graph.getVertex(v1.getId(), FetchHints.ALL_INCLUDING_HIDDEN, beforeDeleteTime, AUTHORIZATIONS_A)); }
@Test public void testGetSoftDeletedElementWithFetchHintsAndTimestamp() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); Edge e1 = graph.addEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); long beforeDeleteTime = IncreasingTime.currentTimeMillis(); graph.softDeleteEdge(e1, AUTHORIZATIONS_A); graph.softDeleteVertex(v1, AUTHORIZATIONS_A); graph.flush(); assertNull(graph.getEdge(e1.getId(), AUTHORIZATIONS_A)); assertNull(graph.getEdge(e1.getId(), graph.getDefaultFetchHints(), AUTHORIZATIONS_A)); assertNull(graph.getEdge(e1.getId(), FetchHints.ALL_INCLUDING_HIDDEN, AUTHORIZATIONS_A)); assertNull(graph.getVertex(v1.getId(), AUTHORIZATIONS_A)); assertNull(graph.getVertex(v1.getId(), graph.getDefaultFetchHints(), AUTHORIZATIONS_A)); assertNull(graph.getVertex(v1.getId(), FetchHints.ALL_INCLUDING_HIDDEN, AUTHORIZATIONS_A)); assertNotNull(graph.getEdge(e1.getId(), graph.getDefaultFetchHints(), beforeDeleteTime, AUTHORIZATIONS_A)); assertNotNull(graph.getEdge(e1.getId(), FetchHints.ALL_INCLUDING_HIDDEN, beforeDeleteTime, AUTHORIZATIONS_A)); assertNotNull(graph.getVertex(v1.getId(), graph.getDefaultFetchHints(), beforeDeleteTime, AUTHORIZATIONS_A)); assertNotNull(graph.getVertex(v1.getId(), FetchHints.ALL_INCLUDING_HIDDEN, beforeDeleteTime, AUTHORIZATIONS_A)); }
graph.softDeleteEdge(e1, AUTHORIZATIONS_A_AND_B); graph.flush();
graph.softDeleteEdge(e1, AUTHORIZATIONS_A_AND_B); graph.flush();