[
http://jira.jboss.com/jira/browse/JBPM-1185?page=comments#action_12415592 ]
Britt Miner commented on JBPM-1185:
-----------------------------------
calculateLeavingTransition() is a new method. None of the changed functionality currently
returns more than the default transition (one transition) anyway.
Node.leave(ExecutionContext executionContext) uses the default transition, and the line in
ProcessState also uses the default transition. Both of these scenarios are really begging
for the "proper" transition to take, not necessarily the "first" one.
The code changes just ensure that the "proper" transition is what is taken.
Truly, "getDefaultLeavingTransition()" should evolve into always returning the
"proper" calculated leaving transition. But I'm not confident enough with
other areas of the code to know what might be affected by doing that. Also,
getDefaultTransition() doesn't currently take an ExecutionContext, and that's
required to evaluate the Conditions.
Node, State and ProcessState don't support Conditions on
Transitions
--------------------------------------------------------------------
Key: JBPM-1185
URL:
http://jira.jboss.com/jira/browse/JBPM-1185
Project: JBoss jBPM
Issue Type: Bug
Components: Core Engine
Affects Versions: jBPM jPDL 3.2.2
Reporter: Britt Miner
Assigned To: Tom Baeyens
Node, State, and ProcessState don't provide any preliminary check for conditions
provided on transitions. No check is performed until the transition is signaled, at which
point the process will barf if a condition is present on the default transition, and that
condition evaluates to false.
Regardless if a person "should" be using transition conditions in Node or
State, the schema allows it, the documentation doesn't forbid it, and the current
behavior of a Transition element in the jpdl is inconsistent. The fix to make everything
consistent is fairly simple--only org.jbpm.graph.def.Node needs to really be altered (and
a one-liner in ProcessState):
In org.jbpm.graph.def.Node, add the following method:
// BRITT--
public Transition calculateLeavingTransition(ExecutionContext executionContext) {
Transition transition = null;
Iterator iter = leavingTransitions.iterator();
while (iter.hasNext()) {
Transition candidate = (Transition) iter.next();
String conditionExpression = candidate.getCondition();
if (conditionExpression != null) {
Object result = JbpmExpressionEvaluator.evaluate(conditionExpression,
executionContext);
if (Boolean.TRUE.equals(result)) {
transition = candidate;
break;
}
} else {
transition = candidate;
break;
}
}
if (transition == null) {
log.warn("All transition conditions have evaluated to 'false'.
Returning the default transition, prepped for signalling (condition enforcement has been
removed).");
this.getDefaultLeavingTransition().removeConditionEnforcement();
transition = this.getDefaultLeavingTransition();
}
return transition;
}
// --BRITT
...and modify "leave(ExecutionContext executionContext)":
// BRITT --replace the following line with the code below
// to check conditions before selecting the transition to take...
//leave(executionContext, getDefaultLeavingTransition()); //original line
leave(executionContext, calculateLeavingTransition(executionContext));
// --BRITT
For consistency, ProcessState should also have one line modified at the very end of
it's "leave(ExecutionContext, Transition)" method:
// BRITT-- rather than specify which transition, let the super class decide...
//super.leave(executionContext, getDefaultLeavingTransition());
super.leave(executionContext, calculateLeavingTransition(executionContext));
// --BRITT
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira