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

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

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

Vertex.getVertexIds介绍

[英]Gets vertex ids of connected vertices.
[中]获取连接顶点的顶点ID。

代码示例

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

@Override
public String getOutVertexId() {
  return singleOrDefault(termMention.getVertexIds(Direction.IN, VisalloProperties.TERM_MENTION_LABEL_HAS_TERM_MENTION, this.authorizations), null);
}

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

@Override
public String getResolvedFromTermMentionId() {
  return singleOrDefault(termMention.getVertexIds(Direction.OUT, VisalloProperties.TERM_MENTION_RESOLVED_FROM, this.authorizations), null);
}

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

private String getParentVertexId(Vertex vertex, Authorizations authorizations) {
  Iterable<String> parentIds = vertex.getVertexIds(Direction.OUT, LabelName.IS_A.toString(), authorizations);
  return parentIds == null ? null : Iterables.getOnlyElement(parentIds, null);
}

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

@Override
public String getResolvedToVertexId() {
  return singleOrDefault(termMention.getVertexIds(Direction.OUT, VisalloProperties.TERM_MENTION_LABEL_RESOLVED_TO, this.authorizations), null);
}

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

@Override
public String getResolvedToTermMentionId() {
  return singleOrDefault(termMention.getVertexIds(Direction.IN, VisalloProperties.TERM_MENTION_RESOLVED_FROM, this.authorizations), null);
}

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

private boolean isAttached(VertexiumCypherQueryContext ctx, Vertex vertex, Stream<DeleteElementItem> elementsToDelete) {
  for (String vertexId : vertex.getVertexIds(Direction.BOTH, ctx.getAuthorizations())) {
    if (elementsToDelete.noneMatch(e -> vertexId.equals(e.element.getId()))) {
      return true;
    }
  }
  return false;
}

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

private boolean isAttached(VertexiumCypherQueryContext ctx, Vertex vertex, Stream<DeleteElementItem> elementsToDelete) {
  for (String vertexId : vertex.getVertexIds(Direction.BOTH, ctx.getAuthorizations())) {
    if (elementsToDelete.noneMatch(e -> vertexId.equals(e.element.getId()))) {
      return true;
    }
  }
  return false;
}

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

private Relationship toVertexiumRelationship(String parentIRI, Vertex relationshipVertex, List<OntologyProperty> properties, Map<String, String> relatedVertexIdToIriMap, String workspaceId) {
  Authorizations authorizations = getAuthorizations(workspaceId);
  Set<String> domainVertexIds = IterableUtils.toSet(relationshipVertex.getVertexIds(Direction.IN, LabelName.HAS_EDGE.toString(), authorizations));
  List<String> domainIris = domainVertexIds.stream().map(relatedVertexIdToIriMap::get).collect(Collectors.toList());
  Set<String> rangeVertexIds = IterableUtils.toSet(relationshipVertex.getVertexIds(Direction.OUT, LabelName.HAS_EDGE.toString(), authorizations));
  List<String> rangeIris = rangeVertexIds.stream().map(relatedVertexIdToIriMap::get).collect(Collectors.toList());
  Set<String> inverseOfVertexIds = IterableUtils.toSet(relationshipVertex.getVertexIds(Direction.OUT, LabelName.INVERSE_OF.toString(), getAuthorizations(workspaceId)));
  List<String> inverseOfIRIs = inverseOfVertexIds.stream().map(relatedVertexIdToIriMap::get).collect(Collectors.toList());
  return createRelationship(parentIRI, relationshipVertex, inverseOfIRIs, domainIris, rangeIris, properties, workspaceId);
}

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

@VisibleForTesting
boolean isSearchGlobal(String id, Authorizations authorizations) {
  if (!graph.doesVertexExist(id, authorizations)) {
    return false;
  }
  Iterable<String> vertexIds = getGlobalSavedSearchesRootVertex().getVertexIds(
      Direction.OUT,
      SearchProperties.HAS_SAVED_SEARCH,
      authorizations
  );
  return stream(vertexIds).anyMatch(vertexId -> vertexId.equals(id));
}

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

@VisibleForTesting
  boolean isSearchPrivateToUser(String id, User user, Authorizations authorizations) {
    if (user instanceof SystemUser) {
      return false;
    }
    Vertex userVertex = graph.getVertex(user.getUserId(), authorizations);
    checkNotNull(userVertex, "Could not find user vertex with id " + user.getUserId());
    Iterable<String> vertexIds = userVertex.getVertexIds(
        Direction.OUT,
        SearchProperties.HAS_SAVED_SEARCH,
        authorizations
    );
    return stream(vertexIds).anyMatch(vertexId -> vertexId.equals(id));
  }
}

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

private List<Concept> transformConcepts(Iterable<Vertex> vertices, String workspaceId) {
  Authorizations authorizations = getAuthorizations(workspaceId);
  List<Vertex> filtered = StreamSupport.stream(vertices.spliterator(), false)
      .filter(vertex -> VisalloProperties.CONCEPT_TYPE.getPropertyValue(vertex, "").equals(TYPE_CONCEPT))
      .collect(Collectors.toList());
  Map<String, String> parentVertexIdToIRI = buildParentIdToIriMap(filtered, authorizations);
  List<String> allPropertyVertexIds = filtered.stream()
      .flatMap(vertex ->
          StreamSupport.stream(vertex.getVertexIds(Direction.OUT, LabelName.HAS_PROPERTY.toString(), authorizations).spliterator(), false)
      ).distinct().collect(Collectors.toList());
  List<OntologyProperty> ontologyProperties = transformProperties(getGraph().getVertices(allPropertyVertexIds, authorizations), workspaceId);
  Map<String, OntologyProperty> ontologyPropertiesByVertexId = ontologyProperties.stream()
      .collect(Collectors.toMap(
          ontologyProperty -> ((VertexiumOntologyProperty) ontologyProperty).getVertex().getId(),
          ontologyProperty -> ontologyProperty
      ));
  return filtered.stream().map(vertex -> {
    String parentVertexId = getParentVertexId(vertex, authorizations);
    String parentIRI = parentVertexId == null ? null : parentVertexIdToIRI.get(parentVertexId);
    Iterable<String> propertyVertexIds = vertex.getVertexIds(Direction.OUT, LabelName.HAS_PROPERTY.toString(), authorizations);
    List<OntologyProperty> conceptProperties = StreamSupport.stream(propertyVertexIds.spliterator(), false)
        .map(ontologyPropertiesByVertexId::get)
        .filter(Objects::nonNull)
        .collect(Collectors.toList());
    return createConcept(vertex, conceptProperties, parentIRI, workspaceId);
  }).collect(Collectors.toList());
}

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

.flatMap(vertex ->
        StreamUtils.stream(
            vertex.getVertexIds(Direction.OUT, LabelName.IS_A.toString(), authorizations),
            vertex.getVertexIds(Direction.IN, LabelName.HAS_EDGE.toString(), authorizations),
            vertex.getVertexIds(Direction.OUT, LabelName.HAS_EDGE.toString(), authorizations),
            vertex.getVertexIds(Direction.OUT, LabelName.INVERSE_OF.toString(), authorizations)
        StreamSupport.stream(vertex.getVertexIds(Direction.OUT, LabelName.HAS_PROPERTY.toString(), authorizations).spliterator(), false)
    ).distinct().collect(Collectors.toList());
List<OntologyProperty> ontologyProperties = transformProperties(getGraph().getVertices(allPropertyVertexIds, authorizations), workspaceId);
  String parentIRI = parentVertexId == null ? null : relatedVertexIdToIriMap.get(parentVertexId);
  Iterable<String> propertyVertexIds = vertex.getVertexIds(Direction.OUT, LabelName.HAS_PROPERTY.toString(), authorizations);
  List<OntologyProperty> properties = StreamSupport.stream(propertyVertexIds.spliterator(), false)
      .map(ontologyPropertiesByVertexId::get)

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

/**
 * Overridable so subclasses can supply a custom implementation of OntologyProperty.
 */
protected OntologyProperty createOntologyProperty(
    Vertex propertyVertex,
    ImmutableList<String> dependentPropertyIris,
    PropertyType propertyType,
    String workspaceId
) {
  if (propertyType.equals(PropertyType.EXTENDED_DATA_TABLE)) {
    Authorizations authorizations = getAuthorizations(workspaceId);
    VertexiumExtendedDataTableOntologyProperty result = new VertexiumExtendedDataTableOntologyProperty(propertyVertex, dependentPropertyIris, workspaceId);
    Iterable<String> tablePropertyIris = propertyVertex.getVertexIds(Direction.OUT, LabelName.HAS_PROPERTY.toString(), authorizations);
    for (String tablePropertyIri : tablePropertyIris) {
      result.addProperty(tablePropertyIri.substring(VertexiumOntologyRepository.ID_PREFIX_PROPERTY.length()));
    }
    return result;
  } else {
    return new VertexiumOntologyProperty(propertyVertex, dependentPropertyIris, workspaceId);
  }
}

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

@Test
public void testGetVertexIdsFromVertex() {
  Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
  Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A);
  Vertex v3 = graph.addVertex("v3", VISIBILITY_A, AUTHORIZATIONS_A);
  Vertex v4 = graph.addVertex("v4", VISIBILITY_A, AUTHORIZATIONS_A);
  Vertex v5 = graph.addVertex("v5", VISIBILITY_B, AUTHORIZATIONS_B);
  graph.addEdge(v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
  graph.addEdge(v1, v3, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
  graph.addEdge(v1, v4, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
  graph.addEdge(v2, v3, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
  graph.addEdge(v2, v5, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A_AND_B);
  graph.flush();
  v1 = graph.getVertex("v1", AUTHORIZATIONS_A);
  Assert.assertEquals(3, count(v1.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A)));
  Assert.assertEquals(3, count(v1.getVertexIds(Direction.OUT, AUTHORIZATIONS_A)));
  Assert.assertEquals(0, count(v1.getVertexIds(Direction.IN, AUTHORIZATIONS_A)));
  v2 = graph.getVertex("v2", AUTHORIZATIONS_A);
  Assert.assertEquals(3, count(v2.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A)));
  Assert.assertEquals(2, count(v2.getVertexIds(Direction.OUT, AUTHORIZATIONS_A)));
  Assert.assertEquals(1, count(v2.getVertexIds(Direction.IN, AUTHORIZATIONS_A)));
  v3 = graph.getVertex("v3", AUTHORIZATIONS_A);
  Assert.assertEquals(2, count(v3.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A)));
  Assert.assertEquals(0, count(v3.getVertexIds(Direction.OUT, AUTHORIZATIONS_A)));
  Assert.assertEquals(2, count(v3.getVertexIds(Direction.IN, AUTHORIZATIONS_A)));
  v4 = graph.getVertex("v4", AUTHORIZATIONS_A);
  Assert.assertEquals(1, count(v4.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A)));
  Assert.assertEquals(0, count(v4.getVertexIds(Direction.OUT, AUTHORIZATIONS_A)));
  Assert.assertEquals(1, count(v4.getVertexIds(Direction.IN, AUTHORIZATIONS_A)));
}

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

@Test
public void testGetVertexIdsFromVertex() {
  Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
  Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A);
  Vertex v3 = graph.addVertex("v3", VISIBILITY_A, AUTHORIZATIONS_A);
  Vertex v4 = graph.addVertex("v4", VISIBILITY_A, AUTHORIZATIONS_A);
  Vertex v5 = graph.addVertex("v5", VISIBILITY_B, AUTHORIZATIONS_B);
  graph.addEdge(v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
  graph.addEdge(v1, v3, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
  graph.addEdge(v1, v4, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
  graph.addEdge(v2, v3, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
  graph.addEdge(v2, v5, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A_AND_B);
  graph.flush();
  v1 = graph.getVertex("v1", AUTHORIZATIONS_A);
  Assert.assertEquals(3, count(v1.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A)));
  Assert.assertEquals(3, count(v1.getVertexIds(Direction.OUT, AUTHORIZATIONS_A)));
  Assert.assertEquals(0, count(v1.getVertexIds(Direction.IN, AUTHORIZATIONS_A)));
  v2 = graph.getVertex("v2", AUTHORIZATIONS_A);
  Assert.assertEquals(3, count(v2.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A)));
  Assert.assertEquals(2, count(v2.getVertexIds(Direction.OUT, AUTHORIZATIONS_A)));
  Assert.assertEquals(1, count(v2.getVertexIds(Direction.IN, AUTHORIZATIONS_A)));
  v3 = graph.getVertex("v3", AUTHORIZATIONS_A);
  Assert.assertEquals(2, count(v3.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A)));
  Assert.assertEquals(0, count(v3.getVertexIds(Direction.OUT, AUTHORIZATIONS_A)));
  Assert.assertEquals(2, count(v3.getVertexIds(Direction.IN, AUTHORIZATIONS_A)));
  v4 = graph.getVertex("v4", AUTHORIZATIONS_A);
  Assert.assertEquals(1, count(v4.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A)));
  Assert.assertEquals(0, count(v4.getVertexIds(Direction.OUT, AUTHORIZATIONS_A)));
  Assert.assertEquals(1, count(v4.getVertexIds(Direction.IN, AUTHORIZATIONS_A)));
}

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

VisalloVisibility.SUPER_USER_VISIBILITY_STRING
);
Iterable<String> productVertexIds = productVertex.getVertexIds(
    Direction.OUT,
    WorkspaceProperties.PRODUCT_TO_ENTITY_RELATIONSHIP_IRI,

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

private ClientApiSourceInfo getSourceInfoFromTermMention(Vertex termMention, Authorizations authorizations) {
  if (termMention == null) {
    return null;
  }
  Authorizations authorizationsWithTermMention = getAuthorizations(authorizations);
  ClientApiSourceInfo result = new ClientApiSourceInfo();
  result.vertexId = single(termMention.getVertexIds(
      Direction.IN,
      VisalloProperties.TERM_MENTION_LABEL_HAS_TERM_MENTION,
      authorizationsWithTermMention
  ));
  result.textPropertyKey = VisalloProperties.TERM_MENTION_PROPERTY_KEY.getPropertyValue(termMention);
  result.textPropertyName = VisalloProperties.TERM_MENTION_PROPERTY_NAME.getPropertyValue(termMention);
  result.startOffset = VisalloProperties.TERM_MENTION_START_OFFSET.getPropertyValue(termMention);
  result.endOffset = VisalloProperties.TERM_MENTION_END_OFFSET.getPropertyValue(termMention);
  result.snippet = SourceInfoSnippetSanitizer.sanitizeSnippet(
      VisalloProperties.TERM_MENTION_SNIPPET.getPropertyValue(termMention)
  );
  return result;
}

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

assertEquals(1, count(v1.getEdgeIds(Direction.BOTH, AUTHORIZATIONS_A_AND_B)));
assertEquals(1, count(v1.getEdges(Direction.BOTH, AUTHORIZATIONS_A_AND_B)));
assertEquals(1, count(v1.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A_AND_B)));
assertEquals(1, count(v1.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A_AND_B)));
assertEquals(0, count(v2.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A_AND_B)));
assertEquals(0, count(v2.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A_AND_B)));
assertEquals(1, count(v3.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A_AND_B)));
assertEquals(1, count(v3.getVertexIds(Direction.BOTH, AUTHORIZATIONS_A_AND_B)));

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

相关文章