/** * is the default leaving transition. */ public Transition getDefaultLeavingTransition() { if (leavingTransitions != null && !leavingTransitions.isEmpty()) { // select the first unconditional transition for (Iterator i = leavingTransitions.iterator(); i.hasNext();) { Transition transition = (Transition) i.next(); if (transition.getCondition() == null) return transition; } // there is no unconditional transition, just pick the first one return (Transition) leavingTransitions.get(0); } else if (superState != null) { return superState.getDefaultLeavingTransition(); } return null; }
private void writeTransition(Element transitionElement, Transition transition) { if (transition.getTo() != null) { transitionElement.addAttribute("to", transition.getTo().getName()); } if (transition.getName() != null) { transitionElement.addAttribute("name", transition.getName()); } Event transitionEvent = transition.getEvent(Event.EVENTTYPE_TRANSITION); if (transitionEvent != null && transitionEvent.hasActions()) { writeActions(transitionElement, transitionEvent.getActions()); } }
public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof Transition)) return false; Transition other = (Transition) o; if (id != 0 && id == other.getId()) return true; return (name != null ? name.equals(other.getName()) : other.getName() == null) && from != null && from.equals(other.getFrom()); }
String transitionName = transitionElement.attributeValue("name"); Transition transition = new Transition(); transition.setProcessDefinition(processDefinition); transition.setName(transitionName); transition.setDescription(transitionElement.elementTextTrim("description")); transition.setCondition(condition);
try { fireSuperStateLeaveEvents(executionContext); fireEvent(Event.EVENTTYPE_TRANSITION, executionContext); Node destination = fireSuperStateEnterEvents(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); } }
public static void addNodesAndTransitions(ProcessDefinition pd, String[] nodes, String[] transitions) { for ( int i = 0; i < nodes.length; i++ ) { pd.addNode( createNode( nodes[i] ) ); } for ( int i = 0; i < transitions.length; i++ ) { String[] parsedTransition = cutTransitionText( transitions[i] ); Node from = pd.getNode( parsedTransition[0] ); Node to = pd.getNode( parsedTransition[2] ); Transition t = new Transition( parsedTransition[1] ); t.setProcessDefinition(pd); from.addLeavingTransition(t); to.addArrivingTransition(t); } }
public ProcessBuilder addSequenceFlow(String targetName) { Node jbpmNode = flowObject.getNode(); Transition jbpmTransition = new Transition(targetName); jbpmTransition.setFrom(jbpmNode); jbpmNode.addLeavingTransition(jbpmTransition); flowObject.setOutFlow(new SequenceFlowImpl(jbpmTransition)); return this; }
String transitionName = transitionElement.attributeValue("name"); Transition transition = new Transition(); transition.setProcessDefinition(processDefinition); transition.setName(transitionName); transition.setDescription(transitionElement.elementTextTrim("description")); transition.setCondition(condition);
public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof Transition)) return false; Transition other = (Transition) o; if (id != 0 && id == other.getId()) return true; return (name != null ? name.equals(other.getName()) : other.getName() == null) && from != null && from.equals(other.getFrom()); }
try { fireSuperStateLeaveEvents(executionContext); fireEvent(Event.EVENTTYPE_TRANSITION, executionContext); Node destination = fireSuperStateEnterEvents(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); } }
public static void addNodesAndTransitions(ProcessDefinition pd, String[] nodes, String[] transitions) { for ( int i = 0; i < nodes.length; i++ ) { pd.addNode( createNode( nodes[i] ) ); } for ( int i = 0; i < transitions.length; i++ ) { String[] parsedTransition = cutTransitionText( transitions[i] ); Node from = pd.getNode( parsedTransition[0] ); Node to = pd.getNode( parsedTransition[2] ); Transition t = new Transition( parsedTransition[1] ); t.setProcessDefinition(pd); from.addLeavingTransition(t); to.addArrivingTransition(t); } }
private void writeTransition(Element transitionElement, Transition transition) { if (transition.getTo() != null) { transitionElement.addAttribute("to", transition.getTo().getName()); } if (transition.getName() != null) { transitionElement.addAttribute("name", transition.getName()); } Event transitionEvent = transition.getEvent(Event.EVENTTYPE_TRANSITION); if (transitionEvent != null && transitionEvent.hasActions()) { writeActions(transitionElement, transitionEvent.getActions()); } }
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; }
/** * is the default leaving transition. */ public Transition getDefaultLeavingTransition() { if (leavingTransitions != null && !leavingTransitions.isEmpty()) { // select the first unconditional transition for (Iterator i = leavingTransitions.iterator(); i.hasNext();) { Transition transition = (Transition) i.next(); if (transition.getCondition() == null) return transition; } // there is no unconditional transition, just pick the first one return (Transition) leavingTransitions.get(0); } else if (superState != null) { return superState.getDefaultLeavingTransition(); } return null; }
public String getName() { return jbpmTransition.getName(); }
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; }