/** * 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; }
while(transitionIterator.hasNext()){ Transition transition = transitionIterator.next(); if (!activityIds.contains(transition.getFromId()) || !activityIds.contains(transition.getToId())) { transitionIterator.remove();
String fromId = transition.getFromId(); if (fromId==null) { parser.addWarning("Transition has no 'from' specified");
@Test public void testEmbeddedSubprocess() { ExecutableWorkflow workflow = new ExecutableWorkflow() .activity("phase1", new EmbeddedSubprocess().name("phase one").activity("start", new StartEvent()).activity("end", new EndEvent()) .transition(new Transition().fromId("start").toId("end"))); workflow = serializeWorkflow(workflow); EmbeddedSubprocess embeddedSubprocess = (EmbeddedSubprocess) workflow.getActivities().get(0); assertEquals("phase1", embeddedSubprocess.getId()); assertEquals("phase one", embeddedSubprocess.getName()); StartEvent startEvent = (StartEvent) embeddedSubprocess.getActivities().get(0); assertEquals("start", startEvent.getId()); EndEvent endEvent = (EndEvent) embeddedSubprocess.getActivities().get(1); assertEquals("end", endEvent.getId()); Transition transition = embeddedSubprocess.getTransitions().get(0); assertEquals("start", transition.getFromId()); assertEquals("end", transition.getToId()); }
public void testTransition() { Condition condition = new IsTrue().left(new Binding().expression("testsPassed")); ExecutableWorkflow workflow = new ExecutableWorkflow() .activity("start", new StartEvent()) .activity("smokeTest", new NoneTask()) .activity("checkTestResult", new ExclusiveGateway().defaultTransitionId("to-failed")) .activity("passed", new EndEvent()) .activity("failed", new EndEvent()) .transition("to-smokeTest", new Transition().fromId("start").toId("smokeTest").description("Starting the process")) .transition("to-checkTestResult", new Transition().fromId("smokeTest").toId("checkTestResult")) .transition("to-passed", new Transition().fromId("checkTestResult").toId("passed").condition(condition)) .transition("to-failed", new Transition().fromId("checkTestResult").toId("failed")); workflow = serialize(workflow); assertEquals(4, workflow.getTransitions().size()); assertEquals("to-smokeTest", workflow.getTransitions().get(0).getId()); assertEquals("Starting the process", workflow.getTransitions().get(0).getDescription()); assertEquals("start", workflow.getTransitions().get(0).getFromId()); assertEquals("smokeTest", workflow.getTransitions().get(0).getToId()); assertEquals("to-passed", workflow.getTransitions().get(2).getId()); IsTrue deserialisedCondition = (IsTrue) workflow.getTransitions().get(2).getCondition(); assertEquals("testsPassed", deserialisedCondition.getLeft().getExpression()); }
assertEquals("start", ((StartEvent)workflow.getActivities().get(0)).getId()); assertEquals("end", ((EndEvent)workflow.getActivities().get(1)).getId()); assertEquals("start", workflow.getTransitions().get(0).getFromId()); assertEquals("end", workflow.getTransitions().get(0).getToId());