org.vertexium.Vertex.getVertices()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(12.3k)|赞(0)|评价(0)|浏览(123)

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

Vertex.getVertices介绍

[英]Similar to getEdges but gets the vertices on the other side of the edges attached to this vertex that have the given label.
[中]与GetEdge类似,但获取附加到此顶点的边的另一侧具有给定标签的顶点。

代码示例

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

private List<String> getAssociatedElements(String elementType) {
    Iterable<Vertex> vertices = vertex.getVertices(Direction.BOTH, LabelName.HAS_PROPERTY.toString(), vertex.getAuthorizations());
    List<String> result = StreamSupport.stream(vertices.spliterator(), false)
        .filter(v -> elementType.equals(VisalloProperties.CONCEPT_TYPE.getPropertyValue(v)))
        .map(OntologyProperties.ONTOLOGY_TITLE::getPropertyValue)
        .collect(Collectors.toList());
    CloseableUtils.closeQuietly(vertices);
    return result;
  }
}

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

public Vertex findOutVertex(Vertex termMention, Authorizations authorizations) {
  Authorizations authorizationsWithTermMention = getAuthorizations(authorizations);
  return singleOrDefault(
      termMention.getVertices(
          Direction.IN,
          VisalloProperties.TERM_MENTION_LABEL_HAS_TERM_MENTION,
          authorizationsWithTermMention
      ),
      null
  );
}

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

private List<Vertex> getGenerated() {
  return Lists.newArrayList(structuredFileVertex.getVertices(Direction.BOTH, StructuredIngestOntology.ELEMENT_HAS_SOURCE_IRI, authorizations));
}

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

private Vertex getParentVertex(Vertex vertex, String workspaceId) {
  try {
    return Iterables.getOnlyElement(vertex.getVertices(Direction.OUT, LabelName.IS_A.toString(), getAuthorizations(workspaceId)), null);
  } catch (IllegalArgumentException iae) {
    throw new IllegalStateException(String.format(
        "Unexpected number of parents for concept %s",
        OntologyProperties.TITLE.getPropertyValue(vertex)
    ), iae);
  }
}

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

private Iterable<ClientApiSearch> getGlobalSavedSearches(Authorizations authorizations) {
  Vertex globalSavedSearchesRootVertex = getGlobalSavedSearchesRootVertex();
  Iterable<Vertex> globalSearchVertices = globalSavedSearchesRootVertex.getVertices(
      Direction.OUT,
      SearchProperties.HAS_SAVED_SEARCH,
      authorizations
  );
  return stream(globalSearchVertices)
      .map(searchVertex -> toClientApiSearch(searchVertex, ClientApiSearch.Scope.Global))
      .collect(Collectors.toList());
}

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

/**
 * Find all term mentions connected to the vertex.
 */
public Iterable<Vertex> findByVertexId(String vertexId, Authorizations authorizations) {
  Authorizations authorizationsWithTermMention = getAuthorizations(authorizations);
  Vertex vertex = graph.getVertex(vertexId, authorizationsWithTermMention);
  String[] labels = new String[]{
      VisalloProperties.TERM_MENTION_LABEL_HAS_TERM_MENTION,
      VisalloProperties.TERM_MENTION_LABEL_RESOLVED_TO
  };
  return vertex.getVertices(Direction.BOTH, labels, authorizationsWithTermMention);
}

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

public Iterable<Vertex> findByOutVertex(String outVertexId, Authorizations authorizations) {
  Authorizations authorizationsWithTermMention = getAuthorizations(authorizations);
  Vertex outVertex = graph.getVertex(outVertexId, authorizationsWithTermMention);
  return outVertex.getVertices(
      Direction.OUT,
      VisalloProperties.TERM_MENTION_LABEL_HAS_TERM_MENTION,
      authorizationsWithTermMention
  );
}

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

public Iterable<Vertex> findResolvedTo(String inVertexId, Authorizations authorizations) {
  Authorizations authorizationsWithTermMention = getAuthorizations(authorizations);
  Vertex inVertex = graph.getVertex(inVertexId, authorizationsWithTermMention);
  return inVertex.getVertices(
      Direction.IN,
      VisalloProperties.TERM_MENTION_LABEL_RESOLVED_TO,
      authorizationsWithTermMention
  );
}

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

public Iterable<Vertex> findByEdgeId(String outVertexId, final String edgeId, Authorizations authorizations) {
  Authorizations authorizationsWithTermMention = getAuthorizations(authorizations);
  Vertex outVertex = graph.getVertex(outVertexId, authorizationsWithTermMention);
  return new FilterIterable<Vertex>(outVertex.getVertices(
      Direction.OUT,
      VisalloProperties.TERM_MENTION_LABEL_HAS_TERM_MENTION,
      authorizationsWithTermMention
  )) {
    @Override
    protected boolean isIncluded(Vertex v) {
      String vertexEdgeId = VisalloProperties.TERM_MENTION_RESOLVED_EDGE_ID.getPropertyValue(v);
      return edgeId.equals(vertexEdgeId);
    }
  };
}

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

private Iterable<ClientApiSearch> getUserSavedSearches(User user, Authorizations authorizations) {
  Vertex userVertex = graph.getVertex(user.getUserId(), authorizations);
  checkNotNull(userVertex, "Could not find user vertex with id " + user.getUserId());
  Iterable<Vertex> userSearchVertices = userVertex.getVertices(
      Direction.OUT,
      SearchProperties.HAS_SAVED_SEARCH,
      authorizations
  );
  return stream(userSearchVertices)
      .map(searchVertex -> toClientApiSearch(searchVertex, ClientApiSearch.Scope.User))
      .collect(Collectors.toList());
}

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

private Dashboard dashboardVertexToDashboard(
    String workspaceId,
    Vertex dashboardVertex,
    Authorizations authorizations
) {
  String title = WorkspaceProperties.TITLE.getPropertyValue(dashboardVertex);
  Iterable<Vertex> dashboardItemVertices = dashboardVertex.getVertices(
      Direction.OUT,
      WorkspaceProperties.DASHBOARD_TO_DASHBOARD_ITEM_RELATIONSHIP_IRI,
      authorizations
  );
  List<DashboardItem> items = stream(dashboardItemVertices)
      .map(this::dashboardItemVertexToDashboardItem)
      .collect(Collectors.toList());
  return new VertexiumDashboard(dashboardVertex.getId(), workspaceId, title, items);
}

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

private VertexFindRelatedSearchResults getSearchResults(
    String workspaceId,
    String[] graphVertexIds,
    String limitEdgeLabel,
    Set<String> limitConceptIds,
    long maxVerticesToReturn,
    Authorizations authorizations
) {
  Set<String> visitedIds = new HashSet<>();
  long count = visitedIds.size();
  Iterable<Vertex> vertices = graph.getVertices(Lists.newArrayList(graphVertexIds), FetchHint.EDGE_REFS, authorizations);
  List<Vertex> elements = new ArrayList<>();
  for (Vertex v : vertices) {
    Iterable<Vertex> relatedVertices = v.getVertices(Direction.BOTH, limitEdgeLabel, ClientApiConverter.SEARCH_FETCH_HINTS, authorizations);
    for (Vertex vertex : relatedVertices) {
      if (!visitedIds.add(vertex.getId())) {
        continue;
      }
      if (limitConceptIds.size() == 0 || !isLimited(vertex, limitConceptIds)) {
        if (count < maxVerticesToReturn) {
          elements.add(vertex);
        }
        count++;
      }
    }
  }
  return new VertexFindRelatedSearchResults(elements, count);
}

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

@Override
public Iterable<Workspace> findAllForUser(final User user) {
  checkNotNull(user, "User is required");
  Authorizations authorizations = getAuthorizationRepository().getGraphAuthorizations(
      user,
      VISIBILITY_STRING,
      UserRepository.VISIBILITY_STRING
  );
  Vertex userVertex = getGraph().getVertex(user.getUserId(), authorizations);
  checkNotNull(userVertex, "Could not find user vertex with id " + user.getUserId());
  return stream(userVertex.getVertices(Direction.IN, WORKSPACE_TO_USER_RELATIONSHIP_IRI, authorizations))
      .map((Vertex workspaceVertex) -> {
        String cacheKey = getUserWorkspaceVertexCacheKey(workspaceVertex.getId(), user);
        userWorkspaceVertexCache.put(cacheKey, workspaceVertex);
        return new VertexiumWorkspace(workspaceVertex);
      })
      .collect(Collectors.toList());
}

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

@Override
protected List<Relationship> getChildRelationships(Relationship relationship, String workspaceId) {
  Vertex relationshipVertex = ((VertexiumRelationship) relationship).getVertex();
  return transformRelationships(relationshipVertex.getVertices(Direction.IN, LabelName.IS_A.toString(), getAuthorizations(workspaceId)), workspaceId);
}

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

@Override
protected List<Concept> getChildConcepts(Concept concept, String workspaceId) {
  Vertex conceptVertex = ((VertexiumConcept) concept).getVertex();
  return toConcepts(conceptVertex.getVertices(Direction.IN, LabelName.IS_A.toString(), getAuthorizations(workspaceId)), workspaceId);
}

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

@Override
public List<JSONObject> getLongRunningProcesses(User user) {
  Authorizations authorizations = getAuthorizations(user);
  Vertex userVertex = graph.getVertex(user.getUserId(), authorizations);
  checkNotNull(userVertex, "Could not find user with id: " + user.getUserId());
  Iterable<Vertex> longRunningProcessVertices = userVertex.getVertices(
      Direction.OUT,
      LongRunningProcessProperties.LONG_RUNNING_PROCESS_TO_USER_EDGE_IRI,
      authorizations
  );
  return toList(new ConvertingIterable<Vertex, JSONObject>(longRunningProcessVertices) {
    @Override
    protected JSONObject convert(Vertex longRunningProcessVertex) {
      JSONObject json = LongRunningProcessProperties.QUEUE_ITEM_JSON_PROPERTY.getPropertyValue(
          longRunningProcessVertex);
      json.put("id", longRunningProcessVertex.getId());
      return json;
    }
  });
}

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

@Override
public Iterable<Vertex> getVertices(Direction direction, final String... labels) {
  final org.vertexium.Direction sgDirection = VertexiumBlueprintsConvert.toVertexium(direction);
  final Authorizations authorizations = getGraph().getAuthorizationsProvider().getAuthorizations();
  return new ConvertingIterable<org.vertexium.Vertex, Vertex>(getVertexiumElement().getVertices(sgDirection, labels, authorizations)) {
    @Override
    protected Vertex convert(org.vertexium.Vertex vertex) {
      return VertexiumBlueprintsVertex.create(getGraph(), vertex, authorizations);
    }
  };
}

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

private Iterable<Vertex> allVertices(FetchHints fetchHints) {
  List<String> edgeLabels = getParameters().getEdgeLabels();
  String[] edgeLabelsArray = edgeLabels == null || edgeLabels.size() == 0
      ? null
      : edgeLabels.toArray(new String[edgeLabels.size()]);
  Iterable<Vertex> results = getSourceVertex().getVertices(
      getDirection(),
      edgeLabelsArray,
      fetchHints,
      getParameters().getAuthorizations()
  );
  if (getOtherVertexId() != null) {
    results = new FilterIterable<Vertex>(results) {
      @Override
      protected boolean isIncluded(Vertex otherVertex) {
        return otherVertex.getId().equals(getOtherVertexId());
      }
    };
  }
  if (getParameters().getIds() != null) {
    results = new FilterIterable<Vertex>(results) {
      @Override
      protected boolean isIncluded(Vertex otherVertex) {
        return getParameters().getIds().contains(otherVertex.getId());
      }
    };
  }
  return results;
}

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

@Override
public void deleteDashboard(String workspaceId, String dashboardId, User user) {
  LOGGER.debug("deleteDashboard(dashboardId: %s, userId: %s)", dashboardId, user.getUserId());
  if (!hasWritePermissions(workspaceId, user)) {
    throw new VisalloAccessDeniedException(
        "user " + user.getUserId() + " does not have write access to workspace " + workspaceId,
        user,
        workspaceId
    );
  }
  Authorizations authorizations = getAuthorizationRepository().getGraphAuthorizations(
      user,
      VISIBILITY_STRING,
      workspaceId
  );
  Vertex dashboardVertex = getGraph().getVertex(dashboardId, authorizations);
  Iterable<Vertex> dashboardItemVertices = dashboardVertex.getVertices(
      Direction.OUT,
      WorkspaceProperties.DASHBOARD_TO_DASHBOARD_ITEM_RELATIONSHIP_IRI,
      authorizations
  );
  for (Vertex dashboardItemVertex : dashboardItemVertices) {
    getGraph().softDeleteVertex(dashboardItemVertex, authorizations);
  }
  getGraph().softDeleteVertex(dashboardVertex, authorizations);
  getGraph().flush();
}

代码示例来源: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)
  );
}

相关文章