protected void retrieveNode(Node node) { Hibernate.initialize(node); // Hibernate.initialize(node.getLeavingTransitions()); if (node.getSuperState() != null) retrieveNode(node.getSuperState()); }
protected void retrieveNode(Node node) { if( node != null ) { Hibernate.initialize(node); // Hibernate.initialize(node.getLeavingTransitions()); if (node.getSuperState() != null) retrieveNode(node.getSuperState()); } }
/** * collect all superstates of a that do not contain node b. */ static List collectAllSuperStates(Node a, Node b) { SuperState superState = a.getSuperState(); List leavingSuperStates = new ArrayList(); while (superState != null) { if (!superState.containsNode(b)) { leavingSuperStates.add(superState); superState = superState.getSuperState(); } else { superState = null; } } return leavingSuperStates; }
/** * collect all superstates of a that do not contain node b. */ static List collectAllSuperStates(Node a, Node b) { SuperState superState = a.getSuperState(); List leavingSuperStates = new ArrayList(); while (superState != null) { if (!superState.containsNode(b)) { leavingSuperStates.add(superState); superState = superState.getSuperState(); } else { superState = null; } } return leavingSuperStates; }
/** * recursively checks if the given node is one of the descendants of this * supernode. */ public boolean containsNode(Node node) { boolean containsNode = false; SuperState parent = node.getSuperState(); while ((!containsNode) && (parent != null)) { if (this.equals(parent)) { containsNode = true; } else { parent = parent.getSuperState(); } } return containsNode; }
/** * adds available transitions of that node to the Set and after that calls itself recursively * for the SuperSate of the Node if it has a super state */ private void addAvailableTransitionsOfNode(Node currentNode, Set availableTransitions) { List leavingTransitions = currentNode.getLeavingTransitions(); if (leavingTransitions != null) { for (Iterator iter = leavingTransitions.iterator(); iter.hasNext();) { Transition transition = (Transition) iter.next(); String conditionExpression = transition.getCondition(); if (conditionExpression != null) { Boolean result = (Boolean) JbpmExpressionEvaluator.evaluate(conditionExpression, new ExecutionContext(this), Boolean.class); if (Boolean.TRUE.equals(result)) { availableTransitions.add(transition); } } else { availableTransitions.add(transition); } } } if (currentNode.getSuperState() != null) { addAvailableTransitionsOfNode(currentNode.getSuperState(), availableTransitions); } }
/** * recursively checks if the given node is one of the descendants of this * supernode. */ public boolean containsNode(Node node) { boolean containsNode = false; SuperState parent = node.getSuperState(); while ((!containsNode) && (parent != null)) { if (this.equals(parent)) { containsNode = true; } else { parent = parent.getSuperState(); } } return containsNode; }
/** * adds available transitions of that node to the Set and after that calls itself recursively * for the SuperSate of the Node if it has a super state */ private void addAvailableTransitionsOfNode(Node currentNode, Set availableTransitions) { List leavingTransitions = currentNode.getLeavingTransitions(); if (leavingTransitions != null) { for (Iterator iter = leavingTransitions.iterator(); iter.hasNext();) { Transition transition = (Transition) iter.next(); String conditionExpression = transition.getCondition(); if (conditionExpression != null) { Boolean result = (Boolean) JbpmExpressionEvaluator.evaluate(conditionExpression, new ExecutionContext(this), Boolean.class); if (Boolean.TRUE.equals(result)) { availableTransitions.add(transition); } } else { availableTransitions.add(transition); } } } if (currentNode.getSuperState() != null) { addAvailableTransitionsOfNode(currentNode.getSuperState(), availableTransitions); } }
Node fireSuperStateEnterEvents(ExecutionContext executionContext) { // calculate the actual destinationNode node Node destination = to; while (destination != null && destination.isSuperStateNode()) { List nodes = destination.getNodes(); destination = nodes != null && !nodes.isEmpty() ? (Node) nodes.get(0) : null; } if (destination == null) { String transitionName = name != null ? '\'' + name + '\'' : "in node '" + from + '\''; throw new JbpmException("transition " + transitionName + " has no destination"); } // optimisation: check if there is a candidate superstate to be entered if (destination.getSuperState() != null) { // collect all the superstates being left List leavingSuperStates = collectAllSuperStates(destination, from); // reverse order so that events fire from outer to inner superstates Collections.reverse(leavingSuperStates); // fire a superstate-enter event for all superstates being left fireSuperStateEvents(leavingSuperStates, Event.EVENTTYPE_SUPERSTATE_ENTER, executionContext); } return destination; }
Node fireSuperStateEnterEvents(ExecutionContext executionContext) { // calculate the actual destinationNode node Node destination = to; while (destination != null && destination.isSuperStateNode()) { List nodes = destination.getNodes(); destination = nodes != null && !nodes.isEmpty() ? (Node) nodes.get(0) : null; } if (destination == null) { String transitionName = name != null ? '\'' + name + '\'' : "in node '" + from + '\''; throw new JbpmException("transition " + transitionName + " has no destination"); } // optimisation: check if there is a candidate superstate to be entered if (destination.getSuperState() != null) { // collect all the superstates being left List leavingSuperStates = collectAllSuperStates(destination, from); // reverse order so that events fire from outer to inner superstates Collections.reverse(leavingSuperStates); // fire a superstate-enter event for all superstates being left fireSuperStateEvents(leavingSuperStates, Event.EVENTTYPE_SUPERSTATE_ENTER, executionContext); } return destination; }
void fireSuperStateLeaveEvents(ExecutionContext executionContext) { // optimisation: check if there is a candidate superstate to be left if (executionContext.getTransitionSource().getSuperState() != null) { // collect all the superstates being left List leavingSuperStates = collectAllSuperStates(executionContext.getTransitionSource(), to); // fire a node-leave event for all superstates being left fireSuperStateEvents(leavingSuperStates, Event.EVENTTYPE_SUPERSTATE_LEAVE, executionContext); } }
void fireSuperStateLeaveEvents(ExecutionContext executionContext) { // optimisation: check if there is a candidate superstate to be left if (executionContext.getTransitionSource().getSuperState() != null) { // collect all the superstates being left List leavingSuperStates = collectAllSuperStates(executionContext.getTransitionSource(), to); // fire a node-leave event for all superstates being left fireSuperStateEvents(leavingSuperStates, Event.EVENTTYPE_SUPERSTATE_LEAVE, executionContext); } }