public EdgeBuilderByVertexId prepareEdge(Edge edge) { return prepareEdge( edge.getId(), edge.getVertexId(Direction.OUT), edge.getVertexId(Direction.IN), edge.getLabel(), edge.getTimestamp(), edge.getVisibility() ); }
@Override protected boolean isIncluded(Edge o) { String entityVertexId = o.getOtherVertexId(workspaceVertex.getId()); return entityVertexId.equalsIgnoreCase(vertexId); } };
/** * 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); }
/** * 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). * @return The vertex. */ default Vertex getVertex(Direction direction, Authorizations authorizations) { return getVertex(direction, getGraph().getDefaultFetchHints(), authorizations); }
assertEquals(LABEL_LABEL1, e.getLabel()); Assert.assertEquals(1, count(e.getProperties())); assertEquals("valueA", e.getPropertyValues("propA").iterator().next()); Assert.assertEquals(1, count(v1.getEdges(Direction.OUT, AUTHORIZATIONS_A))); Assert.assertEquals(LABEL_LABEL1, IterableUtils.single(v1.getEdgesSummary(AUTHORIZATIONS_A).getOutEdgeLabels())); e.prepareMutation() .alterEdgeLabel(LABEL_LABEL2) .save(AUTHORIZATIONS_A); graph.flush(); e = graph.getEdge("e1", AUTHORIZATIONS_A); assertEquals(LABEL_LABEL2, e.getLabel()); Assert.assertEquals(1, count(e.getProperties())); assertEquals("valueA", e.getPropertyValues("propA").iterator().next()); v1 = graph.getVertex("v1", AUTHORIZATIONS_A); Assert.assertEquals(1, count(v1.getEdges(Direction.OUT, AUTHORIZATIONS_A))); graph.prepareEdge(e.getId(), e.getVertexId(Direction.OUT), e.getVertexId(Direction.IN), e.getLabel(), e.getVisibility()) .alterEdgeLabel("label3") .save(AUTHORIZATIONS_A); graph.flush(); e = graph.getEdge("e1", AUTHORIZATIONS_A); assertEquals("label3", e.getLabel()); Assert.assertEquals(1, count(e.getProperties())); assertEquals("valueA", e.getPropertyValues("propA").iterator().next()); v1 = graph.getVertex("v1", AUTHORIZATIONS_A); Assert.assertEquals(1, count(v1.getEdges(Direction.OUT, AUTHORIZATIONS_A)));
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"); } }
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 ); }
checkNotNull(edge); Span trace = Trace.start("markEdgeHidden"); trace.data("edgeId", edge.getId()); try { Vertex out = edge.getVertex(Direction.OUT, authorizations); if (out == null) { throw new VertexiumException(String.format("Unable to mark edge hidden %s, can't find out vertex %s", edge.getId(), edge.getVertexId(Direction.OUT))); Vertex in = edge.getVertex(Direction.IN, authorizations); if (in == null) { throw new VertexiumException(String.format("Unable to mark edge hidden %s, can't find in vertex %s", edge.getId(), edge.getVertexId(Direction.IN))); outMutation.put(AccumuloVertex.CF_OUT_EDGE_HIDDEN, new Text(edge.getId()), columnVisibility, AccumuloElement.HIDDEN_VALUE); inMutation.put(AccumuloVertex.CF_IN_EDGE_HIDDEN, new Text(edge.getId()), columnVisibility, AccumuloElement.HIDDEN_VALUE); addMutations(VertexiumObjectType.EDGE, getMarkHiddenRowMutation(edge.getId(), columnVisibility));
graph.flush(); assertNotNull(addedEdge); assertEquals("e1", addedEdge.getId()); assertEquals(LABEL_LABEL1, addedEdge.getLabel()); assertEquals("v1", addedEdge.getVertexId(Direction.OUT)); assertEquals(v1, addedEdge.getVertex(Direction.OUT, AUTHORIZATIONS_A)); assertEquals("v2", addedEdge.getVertexId(Direction.IN)); assertEquals(v2, addedEdge.getVertex(Direction.IN, AUTHORIZATIONS_A)); assertEquals(VISIBILITY_A, addedEdge.getVisibility()); EdgeVertices addedEdgeVertices = addedEdge.getVertices(AUTHORIZATIONS_A); assertEquals(v1, addedEdgeVertices.getOutVertex()); assertEquals(v2, addedEdgeVertices.getInVertex()); assertEquals("e1", e.getId()); assertEquals(LABEL_LABEL1, e.getLabel()); assertEquals("v1", e.getVertexId(Direction.OUT)); assertEquals(v1, e.getVertex(Direction.OUT, AUTHORIZATIONS_A)); assertEquals("v2", e.getVertexId(Direction.IN)); assertEquals(v2, e.getVertex(Direction.IN, AUTHORIZATIONS_A)); assertEquals(VISIBILITY_A, e.getVisibility());
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); } }
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); }
@Handle public ClientApiEdge handle( @Required(name = "graphEdgeId") String graphEdgeId, @ActiveWorkspaceId String workspaceId, Authorizations authorizations ) throws Exception { Edge edge = graph.getEdge(graphEdgeId, authorizations); if (edge == null) { throw new VisalloResourceNotFoundException("Could not find edge: " + graphEdgeId); } Vertex outVertex = edge.getVertex(Direction.OUT, authorizations); if (outVertex == null) { throw new VisalloResourceNotFoundException("Could not find outVertex: " + edge.getVertexId(Direction.OUT)); } Vertex inVertex = edge.getVertex(Direction.IN, authorizations); if (inVertex == null) { throw new VisalloResourceNotFoundException("Could not find inVertex: " + edge.getVertexId(Direction.IN)); } return ClientApiConverter.toClientApiEdgeWithVertexData(edge, outVertex, inVertex, workspaceId, authorizations); } }
private Mutation createAlterEdgeLabelMutation(Edge edge, String newEdgeLabel, ColumnVisibility edgeColumnVisibility) { String edgeRowKey = edge.getId(); Mutation m = new Mutation(edgeRowKey); m.putDelete(AccumuloEdge.CF_SIGNAL, new Text(edge.getLabel()), edgeColumnVisibility, currentTimeMillis()); m.put(AccumuloEdge.CF_SIGNAL, new Text(newEdgeLabel), edgeColumnVisibility, currentTimeMillis(), ElementMutationBuilder.EMPTY_VALUE); return m; }
private String columnEdgeToString(VertexiumCypherQueryContext ctx, Edge edge) { StringBuilder result = new StringBuilder(); result.append("["); result.append(":"); result.append(edge.getLabel()); if (count(edge.getProperties()) > 0) { result.append(" "); result.append(elementPropertiesToString(ctx, edge)); } result.append("]"); return result.toString(); }
@Override protected EdgeVertexPair convert(Edge edge) { String otherVertexId = edge.getOtherVertexId(sourceVertexId); Vertex otherVertex = vertices.get(otherVertexId); if (otherVertex == null) { throw new VertexiumException("Found an edge " + edge.getId() + ", but could not find the vertex on the other end: " + otherVertexId); } return new EdgeVertexPair(edge, otherVertex); } };
private Direction getDirection(String previousVertexId, Edge element) { if (element.getVertexId(Direction.OUT).equals(previousVertexId)) { return Direction.OUT; } else { return Direction.IN; } }
Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); Edge e1 = graph.addEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A); e1.addPropertyValue("k1", "n1", "value1", VISIBILITY_A, AUTHORIZATIONS_A); graph.addEdge("e2", v2, v1, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); assertNotNull(e1_none); assertThrowsException(e1_none::getProperties); assertEquals("v1", e1_none.getVertexId(Direction.OUT)); assertEquals("v2", e1_none.getVertexId(Direction.IN)); assertEquals(1, IterableUtils.count(e1_default.getProperties())); assertEquals("v1", e1_default.getVertexId(Direction.OUT)); assertEquals("v2", e1_default.getVertexId(Direction.IN)); assertEquals(1, IterableUtils.count(e1_properties.getProperties())); assertEquals("v1", e1_properties.getVertexId(Direction.OUT)); assertEquals("v2", e1_properties.getVertexId(Direction.IN));
@Override public String getLabel() { return getVertexiumElement().getLabel(); }
Assert.assertEquals(1, count(e.getProperties())); assertEquals("valueA", e.getPropertyValues("propA").iterator().next()); Property propA = e.getProperty("", "propA"); assertNotNull(propA); e.markPropertyHidden(propA, VISIBILITY_A, AUTHORIZATIONS_A_AND_B); graph.flush(); Assert.assertEquals(0, count(e.getProperties())); Assert.assertEquals(0, count(e.getPropertyValues("propA"))); e.setProperty(propA.getName(), "valueA_changed", VISIBILITY_B, AUTHORIZATIONS_A_AND_B); graph.flush(); Assert.assertEquals(1, count(e.getProperties())); assertEquals("valueA_changed", e.getPropertyValues("propA").iterator().next()); e.markPropertyVisible(propA, VISIBILITY_A, AUTHORIZATIONS_A_AND_B); graph.flush(); Assert.assertEquals(2, count(e.getProperties())); Assert.assertEquals(2, count(e.getPropertyValues("propA"))); List<Object> propertyValues = IterableUtils.toList(e.getPropertyValues("propA")); assertTrue(propertyValues.contains("valueA")); assertTrue(propertyValues.contains("valueA_changed"));