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

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

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

Graph.getEdge介绍

[英]Get an edge from the graph.
[中]从图表中获取边。

代码示例

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

private ImmutableList<Element> getEdgesFromMessage(GraphPropertyMessage message) {
  ImmutableList.Builder<Element> edges = ImmutableList.builder();
  for (String edgeId : message.getGraphEdgeId()) {
    Edge edge;
    if (message.getStatus() == ElementOrPropertyStatus.DELETION || message.getStatus() == ElementOrPropertyStatus.HIDDEN) {
      edge = graph.getEdge(edgeId, FetchHint.ALL, message.getBeforeActionTimestamp(), this.authorizations);
    } else {
      edge = graph.getEdge(edgeId, this.authorizations);
    }
    if (doesExist(edge)) {
      edges.add(edge);
    } else {
      LOGGER.warn("Could not find edge with id %s", edgeId);
    }
  }
  return edges.build();
}

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

private Edge getEdge() {
  return getGraph().getEdge(getId(), getFetchHints(), authorizations);
}

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

private Edge getEdge() {
  return getGraph().getEdge(getId(), getFetchHints(), authorizations);
}

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

private Element requeryWithAuthsAndMergedElement(Graph graph, Element element, Authorizations authorizations) {
  Element existingElement;
  if (element instanceof Vertex) {
    existingElement = graph.getVertex(element.getId(), authorizations);
  } else if (element instanceof Edge) {
    existingElement = graph.getEdge(element.getId(), authorizations);
  } else {
    throw new VertexiumException("Unexpected element type " + element.getClass().getName());
  }
  if (existingElement == null) {
    return element;
  }
  LOGGER.debug("Reindexing element " + element.getId());
  existingElement.mergeProperties(element);
  return existingElement;
}

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

@Override
public Edge getEdge(Object id) {
  if (id == null) {
    throw new IllegalArgumentException("Id cannot be null");
  }
  Authorizations authorizations = getAuthorizationsProvider().getAuthorizations();
  return VertexiumBlueprintsEdge.create(this, getGraph().getEdge(VertexiumBlueprintsConvert.idToString(id), getFetchHints(), authorizations), authorizations);
}

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

private Edge getE() {
  return getGraph().getEdge(getId(), FetchHints.ALL_INCLUDING_HIDDEN, getTime(), getAuthorizations());
}

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

protected Element getExistingElement(Graph graph, PropertyVisalloRdfTriple triple, Authorizations authorizations) {
    Element elem = triple.getElementType() == ElementType.VERTEX
        ? graph.getVertex(triple.getElementId(), authorizations)
        : graph.getEdge(triple.getElementId(), authorizations);
    if (elem == null) {
      graph.flush();
      elem = triple.getElementType() == ElementType.VERTEX
          ? graph.getVertex(triple.getElementId(), authorizations)
          : graph.getEdge(triple.getElementId(), authorizations);
    }
    checkNotNull(elem, "Could not find element with id " + triple.getElementId());
    return elem;
  }
}

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

@Handle
  public ClientApiEdgeDetails handle(
      @Required(name = "edgeId") String edgeId,
      Authorizations authorizations
  ) throws Exception {
    Edge edge = this.graph.getEdge(edgeId, authorizations);
    if (edge == null) {
      throw new VisalloResourceNotFoundException("Could not find edge with id: " + edgeId, edgeId);
    }

    ClientApiSourceInfo sourceInfo = termMentionRepository.getSourceInfoForEdge(edge, authorizations);

    ClientApiEdgeDetails result = new ClientApiEdgeDetails();
    result.sourceInfo = sourceInfo;
    return result;
  }
}

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

@Test
public void testEdgeHashCodeAndEquals() {
  Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A).save(AUTHORIZATIONS_A);
  Vertex v2 = graph.prepareVertex("v2", VISIBILITY_A).save(AUTHORIZATIONS_A);
  Edge e1 = graph.prepareEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A)
      .setProperty("prop1", "value1", VISIBILITY_A)
      .save(AUTHORIZATIONS_A);
  Edge e2 = graph.prepareEdge("e2", v1, v2, LABEL_LABEL1, VISIBILITY_A)
      .setProperty("prop1", "value1", VISIBILITY_A)
      .save(AUTHORIZATIONS_A);
  graph.flush();
  Edge e1Loaded = graph.getEdge("e1", AUTHORIZATIONS_A);
  assertEquals(e1Loaded.hashCode(), e1.hashCode());
  assertTrue(e1Loaded.equals(e1));
  assertNotEquals(e1Loaded.hashCode(), e2.hashCode());
  assertFalse(e1Loaded.equals(e2));
}

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

@Test
public void testEdgeHashCodeAndEquals() {
  Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A).save(AUTHORIZATIONS_A);
  Vertex v2 = graph.prepareVertex("v2", VISIBILITY_A).save(AUTHORIZATIONS_A);
  Edge e1 = graph.prepareEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A)
      .setProperty("prop1", "value1", VISIBILITY_A)
      .save(AUTHORIZATIONS_A);
  Edge e2 = graph.prepareEdge("e2", v1, v2, LABEL_LABEL1, VISIBILITY_A)
      .setProperty("prop1", "value1", VISIBILITY_A)
      .save(AUTHORIZATIONS_A);
  graph.flush();
  Edge e1Loaded = graph.getEdge("e1", AUTHORIZATIONS_A);
  assertEquals(e1Loaded.hashCode(), e1.hashCode());
  assertTrue(e1Loaded.equals(e1));
  assertNotEquals(e1Loaded.hashCode(), e2.hashCode());
  assertFalse(e1Loaded.equals(e2));
}

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

public LazyEdge get(String edgeId) {
    Edge e = getGraph().getEdge(edgeId, getGraph().getDefaultFetchHints(), getTime(), getAuthorizations());
    if (e == null) {
      return null;
    }
    return new LazyEdge(edgeId);
  }
}

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

@Override
protected Edge getE() {
  return getGraph().getEdge(getEdgeId(), getGraph().getDefaultFetchHints(), getTime(), getAuthorizations());
}

代码示例来源: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.vertexium/vertexium-elasticsearch5

protected static void handleElement(
    Graph graph,
    Elasticsearch5SearchIndex elasticsearch5SearchIndex,
    FlushObjectQueue.FlushObject flushObject,
    Authorizations authorizations
) {
  Element element;
  switch (flushObject.getElementType()) {
    case VERTEX:
      element = graph.getVertex(flushObject.getElementId(), authorizations);
      break;
    case EDGE:
      element = graph.getEdge(flushObject.getElementId(), authorizations);
      break;
    default:
      throw new VertexiumException("Invalid element type: " + flushObject.getElementType());
  }
  elasticsearch5SearchIndex.addElement(graph, element, authorizations);
}

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

@Handle
  public ClientApiSuccess handle(
      @Required(name = "edgeId") String edgeId,
      @ActiveWorkspaceId String workspaceId,
      User user,
      Authorizations authorizations
  ) throws Exception {
    Edge edge = graph.getEdge(edgeId, authorizations);
    if (!aclProvider.canDeleteElement(edge, user, workspaceId)) {
      throw new VisalloAccessDeniedException("Edge " + edgeId + " is not deleteable", user, edge.getId());
    }

    Vertex outVertex = edge.getVertex(Direction.OUT, authorizations);
    Vertex inVertex = edge.getVertex(Direction.IN, authorizations);

    SandboxStatus sandboxStatus = SandboxStatusUtil.getSandboxStatus(edge, workspaceId);

    boolean isPublicEdge = sandboxStatus == SandboxStatus.PUBLIC;

    workspaceHelper.deleteEdge(workspaceId, edge, outVertex, inVertex, isPublicEdge, Priority.HIGH, authorizations, user);

    return VisalloResponse.SUCCESS;
  }
}

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

public Element getElement() {
  switch (elementType) {
    case VERTEX:
      return getGraph().getVertex(getElementId(), getGraph().getDefaultFetchHints(), getTime(), getAuthorizations());
    case EDGE:
      return getGraph().getEdge(getElementId(), getGraph().getDefaultFetchHints(), getTime(), getAuthorizations());
    default:
      throw new VertexiumException("Unhandled element type: " + elementType);
  }
}

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

@Handle
  public ClientApiVertex handle(
      @Required(name = "vertexId") String vertexId,
      @Required(name = "multiValueKey") String multiValueKey,
      @ActiveWorkspaceId String workspaceId,
      User user,
      Authorizations authorizations
  ) throws Exception {
    Vertex artifactVertex = graph.getVertex(vertexId, authorizations);
    ArtifactDetectedObject artifactDetectedObject = VisalloProperties.DETECTED_OBJECT.getPropertyValue(artifactVertex, multiValueKey);
    Edge edge = graph.getEdge(artifactDetectedObject.getEdgeId(), authorizations);
    Vertex resolvedVertex = edge.getOtherVertex(artifactVertex.getId(), authorizations);

    SandboxStatus edgeSandboxStatus = SandboxStatusUtil.getSandboxStatus(edge, workspaceId);
    boolean isPublicEdge = edgeSandboxStatus == SandboxStatus.PUBLIC;

    workspaceHelper.deleteEdge(workspaceId, edge, artifactVertex, resolvedVertex, isPublicEdge, Priority.HIGH, authorizations, user);

    return (ClientApiVertex) ClientApiConverter.toClientApi(artifactVertex, workspaceId, 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.vertexium/vertexium-test

@Test
public void testSoftDeletePropertyOnEdgeNotIndexed() {
  Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A_AND_B);
  Vertex v2 = graph.addVertex("v2", VISIBILITY_B, AUTHORIZATIONS_A_AND_B);
  ElementBuilder<Edge> elementBuilder = graph.prepareEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_B)
      .setProperty("prop1", "value1", VISIBILITY_B);
  elementBuilder.setIndexHint(IndexHint.DO_NOT_INDEX);
  Edge e1 = elementBuilder.save(AUTHORIZATIONS_A_AND_B);
  graph.flush();
  ExistingElementMutation<Edge> m = e1.prepareMutation();
  m.softDeleteProperty("prop1", VISIBILITY_B);
  m.setIndexHint(IndexHint.DO_NOT_INDEX);
  m.save(AUTHORIZATIONS_A_AND_B);
  graph.flush();
  e1 = graph.getEdge("e1", AUTHORIZATIONS_A_AND_B);
  assertEquals(0, IterableUtils.count(e1.getProperties()));
}

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

@Test
public void testSoftDeletePropertyOnEdgeNotIndexed() {
  Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A_AND_B);
  Vertex v2 = graph.addVertex("v2", VISIBILITY_B, AUTHORIZATIONS_A_AND_B);
  ElementBuilder<Edge> elementBuilder = graph.prepareEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_B)
      .setProperty("prop1", "value1", VISIBILITY_B);
  elementBuilder.setIndexHint(IndexHint.DO_NOT_INDEX);
  Edge e1 = elementBuilder.save(AUTHORIZATIONS_A_AND_B);
  graph.flush();
  ExistingElementMutation<Edge> m = e1.prepareMutation();
  m.softDeleteProperty("prop1", VISIBILITY_B);
  m.setIndexHint(IndexHint.DO_NOT_INDEX);
  m.save(AUTHORIZATIONS_A_AND_B);
  graph.flush();
  e1 = graph.getEdge("e1", AUTHORIZATIONS_A_AND_B);
  assertEquals(0, IterableUtils.count(e1.getProperties()));
}

相关文章

微信公众号

最新文章

更多