private CanonicalProcessType buildCPF() { CanonicalProcessType cpf = new CanonicalProcessType(); NetType net = new NetType(); EventType event = new EventType(); event.setId("1"); event.setOriginalID("1"); event.setName("event"); TaskType task = new TaskType(); task.setId("2"); task.setOriginalID("2"); task.setName("task"); EdgeType edge = new EdgeType(); edge.setId("3"); edge.setOriginalID("3"); edge.setSourceId("1"); edge.setTargetId("2"); net.getNode().add(event); net.getNode().add(task); net.getEdge().add(edge); cpf.getNet().add(net); return cpf; }
@Test public void testSimpleMerge() { final NetType rootNet = yawl2Canonical.getCpf().getNet().get(0); assertEquals(9, rootNet.getEdge().size()); assertEquals(8, rootNet.getNode().size()); final List<EdgeType> edges = getOutgoingEdges(rootNet, getNodeByName(rootNet, "IN").getId()); assertEquals(1, edges.size()); final NodeType routingNode = getNodeByID(rootNet, edges.get(0).getTargetId()); checkNode(rootNet, routingNode, StateType.class, 1, 3); final List<EdgeType> routingEdges = getOutgoingEdges(rootNet, routingNode.getId()); for (final EdgeType edge : routingEdges) { assertNull("No condition after StateNode", edge.getConditionExpr()); } checkNode(rootNet, "A", TaskType.class, 1, 1); checkNode(rootNet, "B", TaskType.class, 1, 1); final NodeType nodeC = checkNode(rootNet, "C", TaskType.class, 1, 1); final List<EdgeType> cEdges = getOutgoingEdges(rootNet, nodeC.getId()); assertEquals(1, cEdges.size()); final NodeType joiningNode = getNodeByID(rootNet, cEdges.get(0).getTargetId()); checkNode(rootNet, joiningNode, XORJoinType.class, 3, 1); checkNode(rootNet, "D", TaskType.class, 1, 1); }
/* loop through the list of nodes and process each one. */ private void manipulateShapes( CanonicalProcessType cpf, AnnotationsType anf, Map<String, AnnotationData> annotations) { GraphicsType annotation; for (NetType net : cpf.getNet()) { for (NodeType node : net.getNode()) { annotation = findGraphicsType(anf, node.getId()); if (annotation != null) { if (node instanceof EventType) { manipulateEvent(annotation, node, annotations); } else if (node instanceof TaskType) { manipulateTask(annotation, node, annotations); } } } } }