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

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

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

Graph.deleteEdge介绍

[英]Permanently deletes an edge from the graph. This method requires fetching the edge before deletion.
[中]从图形中永久删除边。此方法要求在删除前提取边缘。

代码示例

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

protected void removeEdge(GraphUpdateContext ctx, String fromVertexId, String toVertexId) {
  String edgeId = fromVertexId + "-" + toVertexId;
  ctx.getGraph().deleteEdge(edgeId, ctx.getAuthorizations());
}

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

public void deleteEdge(Edge edge) {
  getGraph().deleteEdge(edge, getAuthorizations());
}

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

public void deleteEdge(Edge edge) {
  getGraph().deleteEdge(edge, getAuthorizations());
}

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

@Override
public void removeEdge(Edge edge) {
  org.vertexium.Edge sgEdge = VertexiumBlueprintsConvert.toVertexium(edge);
  getGraph().deleteEdge(sgEdge, getAuthorizationsProvider().getAuthorizations());
}

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

private void internalDeleteObject(Vertex vertex, String workspaceId) {
  Authorizations authorizations = getAuthorizations(workspaceId);
  Iterable<EdgeInfo> edges = vertex.getEdgeInfos(Direction.BOTH, authorizations);
  for (EdgeInfo edge : edges) {
    graph.deleteEdge(edge.getEdgeId(), authorizations);
  }
  graph.deleteVertex(vertex.getId(), authorizations);
}

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

public void delete() {
    getGraph().deleteEdge(getE(), getAuthorizations());
    getGraph().flush();
  }
}

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

public void deleteProductAncillaryVertex(String workspaceId, String vertexId, User user, String sourceGuid) {
  Authorizations authorizations = getAuthorizationRepository().getGraphAuthorizations(
      user,
      VISIBILITY_STRING,
      VISIBILITY_PRODUCT_STRING,
      workspaceId
  );
  List<String> productIds = new ArrayList<>();
  try (GraphUpdateContext ctx = graphRepository.beginGraphUpdate(Priority.NORMAL, user, authorizations)) {
    Graph graph = ctx.getGraph();
    Vertex annotation = getGraph().getVertex(vertexId, authorizations);
    annotation.getEdgeInfos(Direction.BOTH, authorizations).forEach(edgeInfo -> {
      if (WorkspaceProperties.PRODUCT_TO_ENTITY_RELATIONSHIP_IRI.equals(edgeInfo.getLabel())) {
        productIds.add(edgeInfo.getVertexId());
      }
      graph.deleteEdge(edgeInfo.getEdgeId(), authorizations);
    });
    graph.deleteVertex(annotation, authorizations);
  }
  for (String productId : productIds) {
    getWorkQueueRepository().broadcastWorkProductAncillaryChange(
        productId, workspaceId, vertexId, user, sourceGuid
    );
  }
}

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

private void saveDependentProperties(String propertyVertexId, Collection<String> dependentPropertyIris, User user, String workspaceId) {
  Authorizations authorizations = getAuthorizations(workspaceId);
  for (int i = 0; i < 1000; i++) {
    String edgeId = propertyVertexId + "-dependentProperty-" + i;
    Edge edge = graph.getEdge(edgeId, authorizations);
    if (edge == null) {
      break;
    }
    graph.deleteEdge(edge, authorizations);
  }
  graph.flush();
  try (GraphUpdateContext ctx = graphRepository.beginGraphUpdate(getPriority(user), user, authorizations)) {
    ctx.setPushOnQueue(false);
    Visibility visibility = VISIBILITY.getVisibility();
    VisibilityJson visibilityJson = new VisibilityJson(visibility.getVisibilityString());
    Date modifiedDate = new Date();
    Metadata metadata = getMetadata(modifiedDate, user, visibility);
    AtomicInteger indexCounter = new AtomicInteger();
    for (String dependentPropertyIri : dependentPropertyIris) {
      int i = indexCounter.getAndIncrement();
      String dependentPropertyVertexId = ID_PREFIX_PROPERTY + dependentPropertyIri;
      String edgeId = propertyVertexId + "-dependentProperty-" + i;
      EdgeBuilderByVertexId m = graph.prepareEdge(edgeId, propertyVertexId, dependentPropertyVertexId, OntologyProperties.EDGE_LABEL_DEPENDENT_PROPERTY, visibility);
      ctx.update(m, edgeCtx -> {
        edgeCtx.updateBuiltInProperties(modifiedDate, visibilityJson);
        OntologyProperties.DEPENDENT_PROPERTY_ORDER_PROPERTY_NAME.updateProperty(edgeCtx, i, metadata, visibility);
      });
    }
  }
}

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

@Test
public void testExtendedDataQueryAfterDeleteForEdge() {
  graph.prepareVertex("v1", VISIBILITY_A).save(AUTHORIZATIONS_A);
  graph.prepareVertex("v2", VISIBILITY_A).save(AUTHORIZATIONS_A);
  graph.prepareEdge("e1", "v1", "v2", LABEL_LABEL1, VISIBILITY_A)
      .addExtendedData("table1", "row1", "name", "value 1", VISIBILITY_A)
      .addExtendedData("table1", "row2", "name", "value 2", VISIBILITY_A)
      .save(AUTHORIZATIONS_A);
  graph.flush();
  List<ExtendedDataRow> searchResultsList = toList(graph.query(AUTHORIZATIONS_A).extendedDataRows());
  assertRowIdsAnyOrder(Lists.newArrayList("row1", "row2"), searchResultsList);
  graph.deleteEdge("e1", AUTHORIZATIONS_A);
  graph.flush();
  searchResultsList = toList(graph.query(AUTHORIZATIONS_A).extendedDataRows());
  assertRowIdsAnyOrder(Lists.newArrayList(), searchResultsList);
}

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

@Test
public void testExtendedDataQueryAfterDeleteForEdge() {
  graph.prepareVertex("v1", VISIBILITY_A).save(AUTHORIZATIONS_A);
  graph.prepareVertex("v2", VISIBILITY_A).save(AUTHORIZATIONS_A);
  graph.prepareEdge("e1", "v1", "v2", LABEL_LABEL1, VISIBILITY_A)
      .addExtendedData("table1", "row1", "name", "value 1", VISIBILITY_A)
      .addExtendedData("table1", "row2", "name", "value 2", VISIBILITY_A)
      .save(AUTHORIZATIONS_A);
  graph.flush();
  List<ExtendedDataRow> searchResultsList = toList(graph.query(AUTHORIZATIONS_A).extendedDataRows());
  assertRowIdsAnyOrder(Lists.newArrayList("row1", "row2"), searchResultsList);
  graph.deleteEdge("e1", AUTHORIZATIONS_A);
  graph.flush();
  searchResultsList = toList(graph.query(AUTHORIZATIONS_A).extendedDataRows());
  assertRowIdsAnyOrder(Lists.newArrayList(), searchResultsList);
}

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

@Test
public void testDeleteEdge() {
  Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
  Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A);
  Edge addedEdge = graph.addEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
  graph.flush();
  Assert.assertEquals(1, count(graph.getEdges(AUTHORIZATIONS_A)));
  try {
    graph.deleteEdge("e1", AUTHORIZATIONS_B);
  } catch (NullPointerException e) {
    // expected
  }
  Assert.assertEquals(1, count(graph.getEdges(AUTHORIZATIONS_A)));
  graph.deleteEdge("e1", AUTHORIZATIONS_A);
  graph.flush();
  Assert.assertEquals(0, count(graph.getEdges(AUTHORIZATIONS_A)));
  v1 = graph.getVertex("v1", AUTHORIZATIONS_A);
  Assert.assertEquals(0, count(v1.getVertices(Direction.BOTH, AUTHORIZATIONS_A)));
  v2 = graph.getVertex("v2", AUTHORIZATIONS_A);
  Assert.assertEquals(0, count(v2.getVertices(Direction.BOTH, AUTHORIZATIONS_A)));
  graph.flush();
  assertEvents(
      new AddVertexEvent(graph, v1),
      new AddVertexEvent(graph, v2),
      new AddEdgeEvent(graph, addedEdge),
      new DeleteEdgeEvent(graph, addedEdge)
  );
}

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

@Test
public void testDeleteEdge() {
  Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
  Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A);
  Edge addedEdge = graph.addEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
  graph.flush();
  Assert.assertEquals(1, count(graph.getEdges(AUTHORIZATIONS_A)));
  try {
    graph.deleteEdge("e1", AUTHORIZATIONS_B);
  } catch (NullPointerException e) {
    // expected
  }
  Assert.assertEquals(1, count(graph.getEdges(AUTHORIZATIONS_A)));
  graph.deleteEdge("e1", AUTHORIZATIONS_A);
  graph.flush();
  Assert.assertEquals(0, count(graph.getEdges(AUTHORIZATIONS_A)));
  v1 = graph.getVertex("v1", AUTHORIZATIONS_A);
  Assert.assertEquals(0, count(v1.getVertices(Direction.BOTH, AUTHORIZATIONS_A)));
  v2 = graph.getVertex("v2", AUTHORIZATIONS_A);
  Assert.assertEquals(0, count(v2.getVertices(Direction.BOTH, AUTHORIZATIONS_A)));
  graph.flush();
  assertEvents(
      new AddVertexEvent(graph, v1),
      new AddVertexEvent(graph, v2),
      new AddEdgeEvent(graph, addedEdge),
      new DeleteEdgeEvent(graph, addedEdge)
  );
}

相关文章

微信公众号

最新文章

更多