private Direction getDirection(String previousVertexId, Edge element) { if (element.getVertexId(Direction.OUT).equals(previousVertexId)) { return Direction.OUT; } else { return Direction.IN; } }
public static Set<String> getAllVertexIdsOnEdges(List<Edge> edges) { Set<String> results = new HashSet<>(); for (Edge edge : edges) { results.add(edge.getVertexId(Direction.IN)); results.add(edge.getVertexId(Direction.OUT)); } return results; } }
public static JSONObject toJsonEdge(Edge edge, String workspaceId) { try { JSONObject json = toJsonElement(edge, workspaceId); json.put("label", edge.getLabel()); json.put("outVertexId", edge.getVertexId(Direction.OUT)); json.put("inVertexId", edge.getVertexId(Direction.IN)); return json; } catch (JSONException e) { throw new RuntimeException(e); } }
@Override protected boolean isIncluded(Edge edge) { switch (direction) { case IN: return edge.getVertexId(Direction.IN).equals(getId()); case OUT: return edge.getVertexId(Direction.OUT).equals(getId()); default: return true; } } };
protected void broadcastEdgeDeletion(Edge edge) { JSONObject dataJson = new JSONObject(); if (edge != null) { dataJson.put("edgeId", edge.getId()); dataJson.put("outVertexId", edge.getVertexId(Direction.OUT)); dataJson.put("inVertexId", edge.getVertexId(Direction.IN)); } JSONObject json = new JSONObject(); json.put("type", "edgeDeletion"); json.put("data", dataJson); broadcastJson(json); }
/** * Find all term mentions connected to either side of the edge. */ public Iterable<Vertex> findByEdge(Edge edge, Authorizations authorizations) { return new JoinIterable<>( findByVertexId(edge.getVertexId(Direction.IN), authorizations), findByVertexId(edge.getVertexId(Direction.OUT), authorizations) ); }
@Override public String toString() { if (this instanceof Edge) { Edge edge = (Edge) this; return getId() + ":[" + edge.getVertexId(Direction.OUT) + "-" + edge.getLabel() + "->" + edge.getVertexId(Direction.IN) + "]"; } return getId(); }
/** * Get the attach vertex on either side of the edge. * * @param direction The side of the edge to get the vertex from (IN or OUT). * @param fetchHints Hint on what should be fetched from the datastore. * @return The vertex. */ default Vertex getVertex(Direction direction, FetchHints fetchHints, Authorizations authorizations) { String vertexId = getVertexId(direction); return getGraph().getVertex(vertexId, fetchHints, authorizations); }
public static void populateClientApiEdge(ClientApiEdge e, Edge edge, String workspaceId) { e.setLabel(edge.getLabel()); e.setOutVertexId(edge.getVertexId(Direction.OUT)); e.setInVertexId(edge.getVertexId(Direction.IN)); populateClientApiElement(e, edge, workspaceId); }
public EdgeBuilderByVertexId prepareEdge(Edge edge) { return prepareEdge( edge.getId(), edge.getVertexId(Direction.OUT), edge.getVertexId(Direction.IN), edge.getLabel(), edge.getTimestamp(), edge.getVisibility() ); }
public void alterEdgeLabel(Edge edge, String newEdgeLabel) { ColumnVisibility edgeColumnVisibility = visibilityToAccumuloVisibility(edge.getVisibility()); Mutation m = createAlterEdgeLabelMutation(edge, newEdgeLabel, edgeColumnVisibility); saveEdgeMutation(m); saveEdgeInfoOnVertex( edge.getId(), edge.getVertexId(Direction.OUT), edge.getVertexId(Direction.IN), newEdgeLabel, edgeColumnVisibility ); }
public ClientApiSourceInfo getSourceInfoForEdge(Edge edge, Authorizations authorizations) { String inVertexId = edge.getVertexId(Direction.IN); Vertex termMention = findTermMention(inVertexId, edge.getId(), null, null, null, authorizations); return getSourceInfoFromTermMention(termMention, authorizations); }
public void alterEdgeLabel(Edge edge, String newEdgeLabel) { ColumnVisibility edgeColumnVisibility = visibilityToAccumuloVisibility(edge.getVisibility()); Mutation m = createAlterEdgeLabelMutation(edge, newEdgeLabel, edgeColumnVisibility); saveEdgeMutation(m); saveEdgeInfoOnVertex( edge.getId(), edge.getVertexId(Direction.OUT), edge.getVertexId(Direction.IN), newEdgeLabel, edgeColumnVisibility ); }
@Override public void populateProductVertexWithWorkspaceEdge(Edge propertyVertexEdge, WorkProductVertex vertex) { vertex.setId(propertyVertexEdge.getVertexId(Direction.IN)); if (WorkspaceProperties.PRODUCT_TO_ENTITY_IS_ANCILLARY.getPropertyValue(propertyVertexEdge, false)) { vertex.setAncillary(true); } populateCustomProductVertexWithWorkspaceEdge(propertyVertexEdge, (TVertex) vertex); }
void addInEdge(Edge edge) { if (this.inEdges instanceof EdgesWithEdgeInfo) { ((EdgesWithEdgeInfo) this.inEdges).add(edge.getId(), new org.vertexium.accumulo.iterator.model.EdgeInfo(edge.getLabel(), edge.getVertexId(Direction.OUT))); } else { throw new VertexiumException("Cannot add edge"); } }
void addInEdge(Edge edge) { if (this.inEdges instanceof EdgesWithEdgeInfo) { ((EdgesWithEdgeInfo) this.inEdges).add(edge.getId(), new org.vertexium.accumulo.iterator.model.EdgeInfo(edge.getLabel(), edge.getVertexId(Direction.OUT))); } else { throw new VertexiumException("Cannot add edge"); } }
void addOutEdge(Edge edge) { if (this.outEdges instanceof EdgesWithEdgeInfo) { ((EdgesWithEdgeInfo) this.outEdges).add(edge.getId(), new org.vertexium.accumulo.iterator.model.EdgeInfo(edge.getLabel(), edge.getVertexId(Direction.IN))); } else { throw new VertexiumException("Cannot add edge"); } }
public boolean alterEdgeVertexOutVertex(Mutation vertexOutMutation, Edge edge, Visibility newVisibility) { ColumnVisibility currentColumnVisibility = visibilityToAccumuloVisibility(edge.getVisibility()); ColumnVisibility newColumnVisibility = visibilityToAccumuloVisibility(newVisibility); if (currentColumnVisibility.equals(newColumnVisibility)) { return false; } EdgeInfo edgeInfo = new EdgeInfo(getNameSubstitutionStrategy().deflate(edge.getLabel()), edge.getVertexId(Direction.IN)); vertexOutMutation.putDelete(AccumuloVertex.CF_OUT_EDGE, new Text(edge.getId()), currentColumnVisibility); vertexOutMutation.put(AccumuloVertex.CF_OUT_EDGE, new Text(edge.getId()), newColumnVisibility, edgeInfo.toValue()); return true; }
public boolean alterEdgeVertexOutVertex(Mutation vertexOutMutation, Edge edge, Visibility newVisibility) { ColumnVisibility currentColumnVisibility = visibilityToAccumuloVisibility(edge.getVisibility()); ColumnVisibility newColumnVisibility = visibilityToAccumuloVisibility(newVisibility); if (currentColumnVisibility.equals(newColumnVisibility)) { return false; } EdgeInfo edgeInfo = new EdgeInfo(getNameSubstitutionStrategy().deflate(edge.getLabel()), edge.getVertexId(Direction.IN)); vertexOutMutation.putDelete(AccumuloVertex.CF_OUT_EDGE, new Text(edge.getId()), currentColumnVisibility); vertexOutMutation.put(AccumuloVertex.CF_OUT_EDGE, new Text(edge.getId()), newColumnVisibility, edgeInfo.toValue()); return true; }
public boolean alterEdgeVertexInVertex(Mutation vertexInMutation, Edge edge, Visibility newVisibility) { ColumnVisibility currentColumnVisibility = visibilityToAccumuloVisibility(edge.getVisibility()); ColumnVisibility newColumnVisibility = visibilityToAccumuloVisibility(newVisibility); if (currentColumnVisibility.equals(newColumnVisibility)) { return false; } EdgeInfo edgeInfo = new EdgeInfo(getNameSubstitutionStrategy().deflate(edge.getLabel()), edge.getVertexId(Direction.OUT)); vertexInMutation.putDelete(AccumuloVertex.CF_IN_EDGE, new Text(edge.getId()), currentColumnVisibility); vertexInMutation.put(AccumuloVertex.CF_IN_EDGE, new Text(edge.getId()), newColumnVisibility, edgeInfo.toValue()); return true; }