/** * creates a transition from this node to the given * destination node. Also the transition pointers to source and destination * node will be set appropriatly. * @throws NullPointerException if destination is null. */ public Transition createOutgoingTransition(NodeImpl destination) { return createOutgoingTransition(destination, null); }
/** * creates a transition with the given name from this node to the given * destination node. Also the transition pointers to source and destination * node will be set appropriatly. * @param transitionName may be null. * @throws NullPointerException if destination is null. */ public TransitionImpl createOutgoingTransition(NodeImpl destination, String transitionName) { TransitionImpl transition = createOutgoingTransition(transitionName); if (destination!=null) { destination.addIncomingTransition(transition); } return transition; }
/** creates a named transition on the current node. * This method requires a current node */ public ProcessFactory transition(String transitionName) { if (exceptionHandler!=null) { exceptionHandler.setTransitionName(transitionName); } else { if (node==null) { throw new PvmException("no current node"); } transition = node.createOutgoingTransition(null, transitionName); observableElement = transition; event = null; eventListenerReference = null; exceptionHandler = null; } return this; }
TransitionImpl transition = (TransitionImpl) sourceNode.createOutgoingTransition(destNode);
/** * Find transitions in the given list of transitions that would form a cycle if added to the given process. * If a transition can be added to the process without creating a cycle, then the transition is added. * The process returned is a DAG (directed acyclic graph) * @param process input process (this process will be modified by calling this method) * @param transitions transitions to check * @return list of transitions that cannot be added to the DAG (transitions that would create a cycle). */ private static List<Transition> findCycleTransitions(ProcessDefinitionImpl process, List<Transition> transitions) { List<Transition> cycleTransitions = new ArrayList<Transition>(); for (Transition t : transitions) { String sourceNodeName = t.getSource().getName(); String destNodeName = t.getDestination().getName(); // Check if when a transition is added to the spanning tree, it creates a cycle // check if there is already a path from transition dest to transition source. // adding the transition would then create a cycle. NodeImpl sourceNode = process.getNode(sourceNodeName); NodeImpl destNode = process.getNode(destNodeName); if (existsPath(destNode, sourceNode)) { cycleTransitions.add(t); } else { // add transition to the DAG sourceNode.createOutgoingTransition(destNode); } } return cycleTransitions; }
/** * Deep first search algorithm that creates spanning tree * (see {@link IterationDetection#createSpanningTree(ProcessDefinitionImpl, ProcessDefinitionImpl)} * @param inNode node of the input process currently processed * @param outNode corresponding node in the spanning tree * @param outProcess spanning tree * @return list of unprocessed transitions during the DFS */ private static List<Transition> processNode(Node inNode, NodeImpl outNode, ProcessDefinitionImpl outProcess) { List<Transition> nonProcessedTransitions = new ArrayList<Transition>(); if (inNode.hasOutgoingTransitions()) { for (Transition t : inNode.getOutgoingTransitions()) { NodeImpl destNode = (NodeImpl) t.getDestination(); String destName = destNode.getName(); if (!outProcess.hasNode(destName)) { // create node NodeImpl newNode = outProcess.createNode(destName); outNode.createOutgoingTransition(newNode, t.getName()); nonProcessedTransitions.addAll(processNode(t.getDestination(), newNode, outProcess)); } else { // node already in the spanning tree, the transition is not in the spanning tree. nonProcessedTransitions.add(t); } } } return nonProcessedTransitions; }
initialNode.createOutgoingTransition(initialActivityNode, "initialSplit_" + initialNode.getName() + "_to_" + initialActivityNode.getName()); endingActivityNode.createOutgoingTransition(endingNode, "endingJoin_" + endingActivityNode.getName() + "_to_" + endingNode.getName()); initialNode.createOutgoingTransition(endingNode, "initialSplit_" + initialNode.getName() + "_to_" + endingNode.getName());
TransitionImpl pvmTransition = fromNode.createOutgoingTransition(toNode, transitionName); if (LOG.isLoggable(Level.FINE)) { LOG.fine("**** created transition = " + transitionName);
TransitionImpl transition = fromNode.createOutgoingTransition(destNode, transitionName); if (LOG.isLoggable(Level.FINE)) { LOG.fine("**** created iteration transition = " + transitionName);