Source:
<code>public void update(Relationship relationship) throws RelationNotFoundException { if (null == relationship) { throw new IllegalArgumentException("relationship was null"); } if (null == relationship.getId()) { throw new IllegalArgumentException("relationship's ID was null"); } PipeFunction<Vertex, Boolean> ifFunction = vertex -> { String uid = vertex.getProperty(Constants.Property.uid.name()); boolean sourceOk = uid.equals(relationship.getSource().getId()); boolean targetOk = uid.equals(relationship.getTarget().getId()); boolean retBool = direction == outgoing ? sourceOk : direction == <START> incoming ? targetOk : (sourceOk || targetOk); <END> return retBool; }; PipeFunction<Vertex, ?> thenFunction = v -> v; PipeFunction<Vertex, ?> elseFunction = v -> Collections.<Vertex>emptyList().iterator(); source().ifThenElse(ifFunction, thenFunction, elseFunction); HawkularPipeline<?, Edge> pipe = null; switch (direction) { case outgoing: pipe = source().outE(relationship.getName()); break; case incoming: pipe = source().inE(relationship.getName()); break; case both: pipe = source().bothE(relationship.getName()); break; } HawkularPipeline<?, Edge> edges = pipe.has("id", relationship.getId()).cast(Edge.class); if (!edges.hasNext()) { throw new RelationNotFoundException(relationship.getId(), null); } Edge edge = edges.next(); if (!edge.getLabel().equals(relationship.getName())) { System.out.println("Name of the relationship cannot be updated!"); } final Direction d1 = direction == outgoing ? Direction.IN : Direction.OUT; final Direction d2 = direction == outgoing ? Direction.OUT : Direction.IN; if (direction != both && (!edge.getVertex(d1).equals(relationship.getTarget()) || !edge.getVertex(d2).equals(relationship.getSource()))) { System.out.println("Cannot change the source or target of the relationship!"); } ElementHelper.setProperties(edge, relationship.getProperties()); }</code><technical_language>this sourceOk && targetOk in case of direction</technical_language>

Target:
public void update(Relationship relationship) throws RelationNotFoundException { if (null == relationship) { throw new IllegalArgumentException("relationship was null"); } if (null == relationship.getId()) { throw new IllegalArgumentException("relationship's ID was null"); } PipeFunction<Vertex, Boolean> ifFunction = vertex -> { String uid = vertex.getProperty(Constants.Property.uid.name()); boolean sourceOk = uid.equals(relationship.getSource().getId()); boolean targetOk = uid.equals(relationship.getTarget().getId()); boolean retBool = direction == outgoing ? sourceOk : direction == incoming ? targetOk : (sourceOk || targetOk); return retBool; }; PipeFunction<Vertex, ?> thenFunction = v -> v; PipeFunction<Vertex, ?> elseFunction = v -> Collections.<Vertex>emptyList().iterator(); HawkularPipeline<?, ?> pipe = source().ifThenElse(ifFunction, thenFunction, elseFunction); switch (direction) { case outgoing: pipe = pipe.outE(relationship.getName()); break; case incoming: pipe = pipe.inE(relationship.getName()); break; case both: pipe = pipe.bothE(relationship.getName()); break; } HawkularPipeline<?, Edge> edges = pipe.has("id", relationship.getId()).cast(Edge.class); if (!edges.hasNext()) { throw new RelationNotFoundException(relationship.getId(), null); } Edge edge = edges.next(); if (!edge.getLabel().equals(relationship.getName())) { System.out.println("Name of the relationship cannot be updated!"); } final Direction d1 = direction == outgoing ? Direction.IN : Direction.OUT; final Direction d2 = direction == outgoing ? Direction.OUT : Direction.IN; if (direction != both && (!edge.getVertex(d1).equals(relationship.getTarget()) || !edge.getVertex(d2).equals(relationship.getSource()))) { System.out.println("Cannot change the source or target of the relationship!"); } ElementHelper.setProperties(edge, relationship.getProperties()); }