diagram.edges.stream() .filter(edge -> activityIds.contains(edge.fromId)) .forEach(edge -> edge.fromId("shape-" + edge.fromId));
/** * Returns a list of edges read from sequenceFlow element transitions, and BPMNEdge coordinates. */ private List<Edge> readEdges(List<Node> shapes, List<Transition> transitions, XmlElement planeElement) { Map<String, Edge> edgesBySequenceFlowId = readEdgesBySequenceFlowId(planeElement); // Map shape activity IDs to shape IDs, which are needed for edge from/to IDs. Map<String,String> nodeIdByActivityId = new HashMap<>(); for (Node shape : shapes) { nodeIdByActivityId.put(shape.elementId, shape.id); } // Add node IDs from the previously-parsed workflow transitions and diagram nodes. List<Edge> edges = new ArrayList<>(); for (Transition transition : transitions) { String sequenceFlowId = transition.getId(); Edge edge = edgesBySequenceFlowId.get(sequenceFlowId); if (edge==null) { BadRequestException.checkNotNull(edge, "No edge for sequenceFlow " + sequenceFlowId); } edge.fromId(nodeIdByActivityId.get(transition.getFromId())); edge.toId(nodeIdByActivityId.get(transition.getToId())); edges.add(edge); } return edges; }
public Diagram addEdge(String transitionId, String fromId, String toId, Point...dockers) { return addEdge(new Edge() .transitionId(transitionId) .fromId(fromId) .toId(toId) .dockers(Arrays.asList(dockers))); }
public Diagram addEdge(String transitionId, String fromId, String toId, Point...dockers) { return addEdge(new Edge() .transitionId(transitionId) .fromId(fromId) .toId(toId) .dockers(Arrays.asList(dockers))); }
@Test public void testSetFromAndTo() { String from = "n1"; String to = "n2"; Edge edge = new Edge() .fromId(from) .toId(to); assertEquals(from, edge.fromId); assertEquals(to, edge.toId); }
@Test public void testEquals() { List<Point> dockers = new ArrayList<>(); dockers.add(Point.of(1.0, 2.0)); dockers.add(Point.of(4.0, 5.0)); dockers.add(Point.of(6.0, 7.0)); String from = "n1"; String to = "n2"; String transId = "t1"; Edge edge1 = new Edge() .transitionId(transId) .fromId(from) .toId(to) .dockers(dockers); Edge edge2 = new Edge() .transitionId(transId) .fromId(from) .toId(to) .dockers(dockers); assertEquals(edge1, edge2); assertEquals(edge1.hashCode(), edge2.hashCode()); } }