public boolean hasUnpositioned() { for (ProcessNode<?, ?> node : getModelNodes()) { if (!node.hasPos()) { return true; } } return false; }
/** * Normalize the process model. By default this may do nothing. * * @return The model (this). */ public M normalize(SplitFactory<? extends T, M> splitFactory) { ensureIds(); // Make all nodes directly refer to other nodes. for (T childNode : mProcessNodes) { childNode.resolveRefs(); } for (T childNode : mProcessNodes) { // Create a copy as we are actually going to remove all successors, but need to keep the list ArrayList<Identifiable> successors = new ArrayList<>(childNode.getSuccessors()); if (successors.size() > 1 && !(childNode instanceof Split)) { for (Identifiable suc2 : successors) { // Remove the current node as predecessor. ProcessNode<?, ?> suc = (ProcessNode) suc2; suc.removePredecessor(childNode); childNode.removeSuccessor(suc); // remove the predecessor from the current node } // create a new join, this should Split<? extends T, M> newSplit = splitFactory.createSplit(asM(), successors); childNode.addSuccessor(newSplit); } } return this.asM(); }
public void ensureIds() { Set<String> ids = new HashSet<>(); List<ProcessNode<?, ?>> unnamedNodes = new ArrayList<>(); for (ProcessNode<?, ?> node : getModelNodes()) { String id = node.getId(); if (id == null) { unnamedNodes.add(node); } else { ids.add(id); } } Map<String, Integer> startCounts = new HashMap<>(); for (ProcessNode<?, ?> unnamed : unnamedNodes) { String idBase = unnamed.getIdBase(); int startCount = getOrDefault(startCounts, idBase, 1); for (String id = idBase + Integer.toString(startCount); ids.contains(id); id = idBase + Integer.toString(startCount)) { ++startCount; } unnamed.setId(idBase + Integer.toString(startCount)); startCounts.put(idBase, startCount + 1); } }