本文整理了Java中org.vertexium.Vertex.getEdgeInfos()
方法的一些代码示例,展示了Vertex.getEdgeInfos()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex.getEdgeInfos()
方法的具体详情如下:
包路径:org.vertexium.Vertex
类名称:Vertex
方法名:getEdgeInfos
[英]Get a list of EdgeInfo.
[中]获取EdgeInfo的列表。
代码示例来源:origin: org.vertexium/vertexium-test
List<EdgeInfo> edgeInfos = toList(v1.getEdgeInfos(Direction.BOTH, AUTHORIZATIONS_A));
edgeInfos.sort(Comparator.comparing(EdgeInfo::getEdgeId));
assertEquals(3, edgeInfos.size());
edgeInfos = toList(v2.getEdgeInfos(Direction.BOTH, AUTHORIZATIONS_A));
edgeInfos.sort(Comparator.comparing(EdgeInfo::getEdgeId));
assertEquals(3, edgeInfos.size());
assertEquals(Arrays.asList(Direction.IN, Direction.IN, Direction.OUT), edgeInfos.stream().map(EdgeInfo::getDirection).collect(Collectors.toList()));
edgeInfos = toList(v1.getEdgeInfos(Direction.IN, AUTHORIZATIONS_A));
edgeInfos.sort(Comparator.comparing(EdgeInfo::getEdgeId));
assertEquals(1, edgeInfos.size());
assertEquals(Direction.IN, edgeInfos.stream().map(EdgeInfo::getDirection).findFirst().get());
edgeInfos = toList(v1.getEdgeInfos(Direction.OUT, AUTHORIZATIONS_A));
edgeInfos.sort(Comparator.comparing(EdgeInfo::getEdgeId));
assertEquals(2, edgeInfos.size());
代码示例来源:origin: visallo/vertexium
List<EdgeInfo> edgeInfos = toList(v1.getEdgeInfos(Direction.BOTH, AUTHORIZATIONS_A));
edgeInfos.sort(Comparator.comparing(EdgeInfo::getEdgeId));
assertEquals(3, edgeInfos.size());
edgeInfos = toList(v2.getEdgeInfos(Direction.BOTH, AUTHORIZATIONS_A));
edgeInfos.sort(Comparator.comparing(EdgeInfo::getEdgeId));
assertEquals(3, edgeInfos.size());
assertEquals(Arrays.asList(Direction.IN, Direction.IN, Direction.OUT), edgeInfos.stream().map(EdgeInfo::getDirection).collect(Collectors.toList()));
edgeInfos = toList(v1.getEdgeInfos(Direction.IN, AUTHORIZATIONS_A));
edgeInfos.sort(Comparator.comparing(EdgeInfo::getEdgeId));
assertEquals(1, edgeInfos.size());
assertEquals(Direction.IN, edgeInfos.stream().map(EdgeInfo::getDirection).findFirst().get());
edgeInfos = toList(v1.getEdgeInfos(Direction.OUT, AUTHORIZATIONS_A));
edgeInfos.sort(Comparator.comparing(EdgeInfo::getEdgeId));
assertEquals(2, edgeInfos.size());
代码示例来源:origin: org.visallo/visallo-core
/**
* @param commonCount the number of vertices this vertex has in common with other vertices.
*/
public static ClientApiVertex toClientApiVertex(
Vertex vertex,
String workspaceId,
Integer commonCount,
boolean includeEdgeInfos,
Authorizations authorizations
) {
checkNotNull(vertex, "vertex is required");
ClientApiVertex v = new ClientApiVertex();
if (authorizations != null) {
stream(vertex.getEdgeLabels(Direction.BOTH, authorizations))
.forEach(v::addEdgeLabel);
if (includeEdgeInfos) {
stream(vertex.getEdgeInfos(Direction.BOTH, authorizations))
.map(ClientApiConverter::toClientApi)
.forEach(v::addEdgeInfo);
}
}
populateClientApiElement(v, vertex, workspaceId);
v.setCommonCount(commonCount);
return v;
}
代码示例来源:origin: org.vertexium/vertexium-core
@Override
public Iterable<String> findRelatedEdgeIdsForVertices(Iterable<Vertex> verticesIterable, Authorizations authorizations) {
List<String> results = new ArrayList<>();
List<Vertex> vertices = IterableUtils.toList(verticesIterable);
for (Vertex outVertex : vertices) {
if (outVertex == null) {
throw new VertexiumException("verticesIterable cannot have null values");
}
Iterable<EdgeInfo> edgeInfos = outVertex.getEdgeInfos(Direction.OUT, authorizations);
for (EdgeInfo edgeInfo : edgeInfos) {
for (Vertex inVertex : vertices) {
if (edgeInfo.getVertexId() == null) { // This check is for legacy data. null EdgeInfo.vertexIds are no longer permitted
continue;
}
if (edgeInfo.getVertexId().equals(inVertex.getId())) {
results.add(edgeInfo.getEdgeId());
}
}
}
}
return results;
}
代码示例来源:origin: org.vertexium/vertexium-core
protected void findPathsSetIntersection(FindPathOptions options, List<Path> foundPaths, Vertex sourceVertex, Vertex destVertex, ProgressCallback progressCallback, Authorizations authorizations) {
String sourceVertexId = sourceVertex.getId();
String destVertexId = destVertex.getId();
progressCallback.progress(0.1, ProgressCallback.Step.SEARCHING_SOURCE_VERTEX_EDGES);
Set<String> sourceVertexConnectedVertexIds = filterFindPathEdgeInfo(options, sourceVertex.getEdgeInfos(Direction.BOTH, options.getLabels(), authorizations));
Map<String, Boolean> sourceVerticesExist = doVerticesExist(sourceVertexConnectedVertexIds, authorizations);
sourceVertexConnectedVertexIds = stream(sourceVerticesExist.keySet())
.filter(key -> sourceVerticesExist.getOrDefault(key, false))
.collect(Collectors.toSet());
progressCallback.progress(0.3, ProgressCallback.Step.SEARCHING_DESTINATION_VERTEX_EDGES);
Set<String> destVertexConnectedVertexIds = filterFindPathEdgeInfo(options, destVertex.getEdgeInfos(Direction.BOTH, options.getLabels(), authorizations));
Map<String, Boolean> destVerticesExist = doVerticesExist(destVertexConnectedVertexIds, authorizations);
destVertexConnectedVertexIds = stream(destVerticesExist.keySet())
.filter(key -> destVerticesExist.getOrDefault(key, false))
.collect(Collectors.toSet());
if (sourceVertexConnectedVertexIds.contains(destVertexId)) {
foundPaths.add(new Path(sourceVertexId, destVertexId));
if (options.isGetAnyPath()) {
return;
}
}
progressCallback.progress(0.6, ProgressCallback.Step.MERGING_EDGES);
sourceVertexConnectedVertexIds.retainAll(destVertexConnectedVertexIds);
progressCallback.progress(0.9, ProgressCallback.Step.ADDING_PATHS);
for (String connectedVertexId : sourceVertexConnectedVertexIds) {
foundPaths.add(new Path(sourceVertexId, connectedVertexId, destVertexId));
}
}
代码示例来源:origin: visallo/vertexium
protected void findPathsSetIntersection(FindPathOptions options, List<Path> foundPaths, Vertex sourceVertex, Vertex destVertex, ProgressCallback progressCallback, Authorizations authorizations) {
String sourceVertexId = sourceVertex.getId();
String destVertexId = destVertex.getId();
progressCallback.progress(0.1, ProgressCallback.Step.SEARCHING_SOURCE_VERTEX_EDGES);
Set<String> sourceVertexConnectedVertexIds = filterFindPathEdgeInfo(options, sourceVertex.getEdgeInfos(Direction.BOTH, options.getLabels(), authorizations));
Map<String, Boolean> sourceVerticesExist = doVerticesExist(sourceVertexConnectedVertexIds, authorizations);
sourceVertexConnectedVertexIds = stream(sourceVerticesExist.keySet())
.filter(key -> sourceVerticesExist.getOrDefault(key, false))
.collect(Collectors.toSet());
progressCallback.progress(0.3, ProgressCallback.Step.SEARCHING_DESTINATION_VERTEX_EDGES);
Set<String> destVertexConnectedVertexIds = filterFindPathEdgeInfo(options, destVertex.getEdgeInfos(Direction.BOTH, options.getLabels(), authorizations));
Map<String, Boolean> destVerticesExist = doVerticesExist(destVertexConnectedVertexIds, authorizations);
destVertexConnectedVertexIds = stream(destVerticesExist.keySet())
.filter(key -> destVerticesExist.getOrDefault(key, false))
.collect(Collectors.toSet());
if (sourceVertexConnectedVertexIds.contains(destVertexId)) {
foundPaths.add(new Path(sourceVertexId, destVertexId));
if (options.isGetAnyPath()) {
return;
}
}
progressCallback.progress(0.6, ProgressCallback.Step.MERGING_EDGES);
sourceVertexConnectedVertexIds.retainAll(destVertexConnectedVertexIds);
progressCallback.progress(0.9, ProgressCallback.Step.ADDING_PATHS);
for (String connectedVertexId : sourceVertexConnectedVertexIds) {
foundPaths.add(new Path(sourceVertexId, connectedVertexId, destVertexId));
}
}
代码示例来源:origin: visallo/vertexium
@Override
public Iterable<String> findRelatedEdgeIdsForVertices(Iterable<Vertex> verticesIterable, Authorizations authorizations) {
List<String> results = new ArrayList<>();
List<Vertex> vertices = IterableUtils.toList(verticesIterable);
for (Vertex outVertex : vertices) {
if (outVertex == null) {
throw new VertexiumException("verticesIterable cannot have null values");
}
Iterable<EdgeInfo> edgeInfos = outVertex.getEdgeInfos(Direction.OUT, authorizations);
for (EdgeInfo edgeInfo : edgeInfos) {
for (Vertex inVertex : vertices) {
if (edgeInfo.getVertexId() == null) { // This check is for legacy data. null EdgeInfo.vertexIds are no longer permitted
continue;
}
if (edgeInfo.getVertexId().equals(inVertex.getId())) {
results.add(edgeInfo.getEdgeId());
}
}
}
}
return results;
}
代码示例来源:origin: org.vertexium/vertexium-core
@Override
public Iterable<RelatedEdge> findRelatedEdgeSummaryForVertices(Iterable<Vertex> verticesIterable, Authorizations authorizations) {
List<RelatedEdge> results = new ArrayList<>();
List<Vertex> vertices = IterableUtils.toList(verticesIterable);
for (Vertex outVertex : vertices) {
Iterable<EdgeInfo> edgeInfos = outVertex.getEdgeInfos(Direction.OUT, authorizations);
for (EdgeInfo edgeInfo : edgeInfos) {
for (Vertex inVertex : vertices) {
if (edgeInfo.getVertexId().equals(inVertex.getId())) {
results.add(new RelatedEdgeImpl(edgeInfo.getEdgeId(), edgeInfo.getLabel(), outVertex.getId(), inVertex.getId()));
}
}
}
}
return results;
}
代码示例来源:origin: visallo/vertexium
@Override
public Iterable<RelatedEdge> findRelatedEdgeSummaryForVertices(Iterable<Vertex> verticesIterable, Authorizations authorizations) {
List<RelatedEdge> results = new ArrayList<>();
List<Vertex> vertices = IterableUtils.toList(verticesIterable);
for (Vertex outVertex : vertices) {
Iterable<EdgeInfo> edgeInfos = outVertex.getEdgeInfos(Direction.OUT, authorizations);
for (EdgeInfo edgeInfo : edgeInfos) {
for (Vertex inVertex : vertices) {
if (edgeInfo.getVertexId().equals(inVertex.getId())) {
results.add(new RelatedEdgeImpl(edgeInfo.getEdgeId(), edgeInfo.getLabel(), outVertex.getId(), inVertex.getId()));
}
}
}
}
return results;
}
代码示例来源:origin: org.vertexium/vertexium-elasticsearch2
private QueryBuilder getVertexFilter(EnumSet<ElasticsearchDocumentType> elementTypes) {
List<QueryBuilder> filters = new ArrayList<>();
List<String> edgeLabels = getParameters().getEdgeLabels();
String[] edgeLabelsArray = edgeLabels == null || edgeLabels.size() == 0
? null
: edgeLabels.toArray(new String[edgeLabels.size()]);
Stream<EdgeInfo> edgeInfos = stream(sourceVertex.getEdgeInfos(
direction,
edgeLabelsArray,
getParameters().getAuthorizations()
));
if (otherVertexId != null) {
edgeInfos = edgeInfos.filter(ei -> ei.getVertexId().equals(otherVertexId));
}
String[] ids = edgeInfos.map(EdgeInfo::getVertexId).toArray(String[]::new);
if (elementTypes.contains(ElasticsearchDocumentType.VERTEX)) {
filters.add(QueryBuilders.idsQuery().ids(ids));
}
if (elementTypes.contains(ElasticsearchDocumentType.VERTEX_EXTENDED_DATA)) {
for (String vertexId : ids) {
filters.add(
QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery(Elasticsearch2SearchIndex.ELEMENT_TYPE_FIELD_NAME, ElasticsearchDocumentType.VERTEX_EXTENDED_DATA.getKey()))
.must(QueryBuilders.termQuery(Elasticsearch2SearchIndex.EXTENDED_DATA_ELEMENT_ID_FIELD_NAME, vertexId)));
}
}
return orFilters(filters);
}
代码示例来源:origin: org.vertexium/vertexium-elasticsearch-singledocument
? null
: edgeLabels.toArray(new String[edgeLabels.size()]);
Stream<EdgeInfo> edgeInfos = stream(sourceVertex.getEdgeInfos(
direction,
edgeLabelsArray,
代码示例来源:origin: org.visallo/visallo-model-vertexium
private Product productVertexToProduct(
String workspaceId,
Vertex productVertex,
boolean includeExtended,
WorkProductExtendedData workProductExtendedData,
Authorizations authorizations,
User user
) {
String title = WorkspaceProperties.TITLE.getPropertyValue(productVertex);
String kind = WorkspaceProperties.PRODUCT_KIND.getPropertyValue(productVertex);
JSONObject data = getProductDataJson(productVertex);
JSONObject extendedData = includeExtended ? getProductExtendedDataJson(productVertex, workProductExtendedData) : null;
String md5 = getProductPreviewDataMd5(productVertex, user);
// Don't use current workspace, use the product workspace.
List<EdgeInfo> edgeInfos = Lists.newArrayList(productVertex.getEdgeInfos(Direction.BOTH, WorkspaceProperties.WORKSPACE_TO_PRODUCT_RELATIONSHIP_IRI, authorizations));
if (edgeInfos.size() > 0) {
workspaceId = edgeInfos.get(0).getVertexId();
}
return new VertexiumProduct(productVertex.getId(), workspaceId, title, kind, data, extendedData, md5);
}
代码示例来源: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
? null
: edgeLabels.toArray(new String[edgeLabels.size()]);
Stream<EdgeInfo> edgeInfos = stream(sourceVertex.getEdgeInfos(
direction,
edgeLabelsArray,
代码示例来源:origin: org.vertexium/vertexium-elasticsearch5
? null
: edgeLabels.toArray(new String[edgeLabels.size()]);
Stream<EdgeInfo> edgeInfos = stream(sourceVertex.getEdgeInfos(
direction,
edgeLabelsArray,
代码示例来源:origin: org.vertexium/vertexium-test
.build();
v1 = graph.getVertex("v1", specificEdgeLabelFetchHints, AUTHORIZATIONS_A);
List<org.vertexium.EdgeInfo> edgeInfos = toList(v1.getEdgeInfos(Direction.BOTH, AUTHORIZATIONS_A));
assertTrue(edgeInfos.stream().anyMatch(e -> e.getEdgeId().equals("e1")));
assertFalse(edgeInfos.stream().anyMatch(e -> e.getEdgeId().equals("e2")));
Vertex v1_noEdges = graph.getVertex("v1", noEdgeLabelsFetchHints, AUTHORIZATIONS_A);
assertThrowsException(() -> v1_noEdges.getEdges(Direction.BOTH, AUTHORIZATIONS_A));
assertThrowsException(() -> v1_noEdges.getEdgeInfos(Direction.BOTH, AUTHORIZATIONS_A));
.build();
Vertex v1_withEdgeLabelsAndCounts = graph.getVertex("v1", edgeLabelsAndCountsFetchHints, AUTHORIZATIONS_A);
assertThrowsException(() -> v1_withEdgeLabelsAndCounts.getEdgeInfos(Direction.BOTH, AUTHORIZATIONS_A));
assertEquals(
LABEL_LABEL1 + "," + LABEL_LABEL2 + "," + LABEL_LABEL3,
.build();
Vertex v1_withEdgeRefs = graph.getVertex("v1", allEdgeInfoFetchHints, AUTHORIZATIONS_A);
edgeInfos = toList(v1_withEdgeRefs.getEdgeInfos(Direction.BOTH, AUTHORIZATIONS_A));
assertTrue(edgeInfos.stream().anyMatch(e -> e.getEdgeId().equals("e1")));
assertTrue(edgeInfos.stream().anyMatch(e -> e.getEdgeId().equals("e2")));
代码示例来源: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.vertexium/vertexium-cypher
private Stream<Edge> findEdges(
VertexiumCypherQueryContext ctx,
String name,
ListMultimap<String, CypherAstBase> propertiesMap,
Vertex startingVertex,
Direction direction,
List<String> labelNames
) {
if (name == null && propertiesMap.size() == 0) {
return stream(startingVertex.getEdgeInfos(direction, labelNamesToArray(labelNames), ctx.getAuthorizations()))
.map(edgeInfo -> new EdgeInfoEdge(ctx.getGraph(), startingVertex.getId(), edgeInfo, ctx.getFetchHints(), ctx.getAuthorizations()));
}
return stream(startingVertex.getEdges(direction, labelNamesToArray(labelNames), ctx.getFetchHints(), ctx.getAuthorizations()));
}
代码示例来源:origin: visallo/vertexium
private Stream<Edge> findEdges(
VertexiumCypherQueryContext ctx,
String name,
ListMultimap<String, CypherAstBase> propertiesMap,
Vertex startingVertex,
Direction direction,
List<String> labelNames
) {
if (name == null && propertiesMap.size() == 0) {
return stream(startingVertex.getEdgeInfos(direction, labelNamesToArray(labelNames), ctx.getAuthorizations()))
.map(edgeInfo -> new EdgeInfoEdge(ctx.getGraph(), startingVertex.getId(), edgeInfo, ctx.getFetchHints(), ctx.getAuthorizations()));
}
return stream(startingVertex.getEdges(direction, labelNamesToArray(labelNames), ctx.getFetchHints(), ctx.getAuthorizations()));
}
代码示例来源:origin: org.vertexium/vertexium-accumulo-titan-hadoop
private FaunusVertex createFaunusVertexFromRow(AccumuloGraph graph, PeekingIterator<Map.Entry<Key, Value>> row, Authorizations authorizations) {
final Vertex v = AccumuloVertexInputFormat.createVertex(graph, row, authorizations);
final long vertexId = toFaunusVertexId(v.getId());
FaunusVertex faunusVertex = new FaunusVertex();
faunusVertex.setId(vertexId);
faunusVertex.setVertexLabel(v.getId());
faunusVertex.addProperty("vertexiumId", v.getId());
for (Property property : v.getProperties()) {
if (property.getValue() instanceof StreamingPropertyValue) {
continue;
}
faunusVertex.addProperty(property.getName(), property.getValue());
}
for (EdgeInfo edgeInfo : v.getEdgeInfos(Direction.OUT, authorizations)) {
faunusVertex.addEdge(com.tinkerpop.blueprints.Direction.OUT, edgeInfo.getLabel(), toFaunusVertexId(edgeInfo.getVertexId()));
}
for (EdgeInfo edgeInfo : v.getEdgeInfos(Direction.IN, authorizations)) {
faunusVertex.addEdge(com.tinkerpop.blueprints.Direction.IN, edgeInfo.getLabel(), toFaunusVertexId(edgeInfo.getVertexId()));
}
return faunusVertex;
}
内容来源于网络,如有侵权,请联系作者删除!