org.vertexium.Graph.softDeleteEdge()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(15.7k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.vertexium.Graph.softDeleteEdge()方法的一些代码示例,展示了Graph.softDeleteEdge()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.softDeleteEdge()方法的具体详情如下:
包路径:org.vertexium.Graph
类名称:Graph
方法名:softDeleteEdge

Graph.softDeleteEdge介绍

[英]Soft deletes an edge from the graph. This method requires fetching the edge before soft deletion.
[中]Soft从图形中删除边。此方法要求在软删除之前获取边缘。

代码示例

代码示例来源:origin: org.visallo/visallo-core

@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();
}

代码示例来源:origin: org.vertexium/vertexium-test

@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());
}

代码示例来源:origin: visallo/vertexium

@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());
}

代码示例来源:origin: org.visallo/visallo-web-product-graph

ctx.getGraph().softDeleteVertex(childId, authorizations);
    } else {
      ctx.getGraph().softDeleteEdge(childEdgeId, authorizations);
ctx.getGraph().softDeleteEdge(edgeId, authorizations);

代码示例来源:origin: org.visallo/visallo-core

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();
}

代码示例来源:origin: org.visallo/visallo-web-product-graph

@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();
}

代码示例来源:origin: org.vertexium/vertexium-test

@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);
}

代码示例来源:origin: visallo/vertexium

@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);
}

代码示例来源:origin: org.visallo/visallo-model-vertexium

@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);
  }
}

代码示例来源:origin: visallo/vertexium

@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());
}

代码示例来源:origin: org.visallo/visallo-model-vertexium

getGraph().softDeleteEdge(edgeInfo.getEdgeId(), authorizations);
});

代码示例来源:origin: org.vertexium/vertexium-test

@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());
}

代码示例来源:origin: org.visallo/visallo-model-vertexium

)).collect(Collectors.toList());
for (Edge edge : edges) {
  getGraph().softDeleteEdge(edge, authorizations);

代码示例来源:origin: org.visallo/visallo-core

this.workQueueRepository.pushEdgeHidden(edge, beforeActionTimestamp, Priority.HIGH);
} else {
  graph.softDeleteEdge(edge, authorizations);

代码示例来源:origin: visallo/vertexium

@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)));
}

代码示例来源:origin: org.vertexium/vertexium-test

@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)));
}

代码示例来源:origin: org.vertexium/vertexium-test

@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));
}

代码示例来源:origin: visallo/vertexium

@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));
}

代码示例来源:origin: visallo/vertexium

graph.softDeleteEdge(e1, AUTHORIZATIONS_A_AND_B);
graph.flush();

代码示例来源:origin: org.vertexium/vertexium-test

graph.softDeleteEdge(e1, AUTHORIZATIONS_A_AND_B);
graph.flush();

相关文章