private static BPMNDiagram mergeActivitiesAfterXOR(BPMNDiagram diagram) { boolean repeat = true; loops: while (repeat) { repeat = false; List<Gateway> gateways = getXORGateways(diagram); for (Gateway gateway : gateways) { List<Activity> activities = getOutgoingActivities(diagram, gateway); for (int i = 0; i < activities.size(); i++) { String label = activities.get(i).getLabel(); for (int j = i + 1; j < activities.size(); j++) { if (activities.get(j).getLabel().equals(label)) { diagram = mergeActivitiesAfterXOR(diagram, gateway, activities.get(i), activities.get(j)); diagram = separateSplitFromJoin(diagram); diagram = removeXORtoAND(diagram); diagram = removeConnectedGateways(diagram); diagram = BPMNSimplifier.removeGatewaysUseless(diagram, diagram.getGateways()); repeat = true; continue loops; } } } } } return diagram; }
private static List<Gateway> getANDGateways(BPMNDiagram diagram) { List<Gateway> gateways = new ArrayList<Gateway>(); for (Gateway gateway : diagram.getGateways()) { if (gateway.getGatewayType().equals(Gateway.GatewayType.PARALLEL)) { gateways.add(gateway); } } return gateways; }