Hi,
I had this problem: some process definition using decisions worked well on JBPM 3.1.4, but
when I tried upgrading to 3.2GA, decision nodes didn't work correctly anymore: they
always chose the default transition.
After some work, I've seen that the conditions simply do not work in that syntax -
using the 'expression' as ATTRIBUTE of the condition tag - but work in the
alternate one: using expression as child element.
From the 3.2 userguide (section 18.4.29. condition):
"{content} For backwards compatibility, the condition can also be entered with
the 'expression' attribute, but that attribute is deprecated since 3.2"
If it's still allowed (even deprecated), I was expecting it to still work, somehow (to
keep backward compatibility) - or else the schema to be changed to give clear error on
this.
Is this a real problem / should it be fixed somehow ?!..
JUnit for this:
| import junit.framework.TestCase;
| import org.jbpm.graph.def.ProcessDefinition;
| import org.jbpm.graph.exe.ProcessInstance;
| /**
| * JUnit test of JBPM to check issues regarding the sintax of conditional
transitions.<br>
| * In 3.2 it seems that using the 'expression' ATTRIBUTE of the
<condition> tag does not
| * work! (but only the alternative, where the expression is passed as a child element
of the tag!)
| */
| public class TestDecisionAndConditionalTransitions extends TestCase
| {
| public void testDecision( )
| {
| String def1 = "<process-definition>" + "
<start-state>" + " <transition to='d' />"
| + " </start-state>" + " <decision
name='d'>"
| + " <transition name='t1'
to='a'>"
| + " <condition>#{a ==
'1'}</condition>" + " </transition>"
| + " <transition name='t2'
to='b'>"
| + " <condition>#{a ==
'2'}</condition>" + " </transition>"
| + " <transition name='t3'
to='c'>"
| + " <condition>#{a ==
'3'}</condition>" + " </transition>"
| + " </decision>" + " <state
name='a' />" + " <state name='b' />"
| + " <state name='c' />" +
"</process-definition>";
|
| String def2 = "<process-definition>" + "
<start-state>" + " <transition to='d' />"
| + " </start-state>" + " <decision
name='d'>"
| + " <transition name='t1'
to='a'>"
| + " <condition expression=\"#{a ==
'1'\"/>" + " </transition>"
| + " <transition name='t2'
to='b'>"
| + " <condition expression=\"#{a ==
'2'\"/>" + " </transition>"
| + " <transition name='t3'
to='c'>"
| + " <condition expression=\"#{a ==
'3'\"/>" + " </transition>"
| + " </decision>" + " <state
name='a' />" + " <state name='b' />"
| + " <state name='c' />" +
"</process-definition>";
|
| ProcessDefinition processDefinition1 = ProcessDefinition.parseXmlString( def1
);
| ProcessDefinition processDefinition2 = ProcessDefinition.parseXmlString( def2
);
|
| //test def 1 - should work
| ProcessInstance processInstance = new ProcessInstance( processDefinition1 );
| processInstance.getContextInstance( ).setVariable( "a",
"2" );
| processInstance.signal( );
| assertEquals( processDefinition1.getNode( "b" ),
| processInstance.getRootToken( ).getNode( ) );
|
| //test def 2 - doesn't work on JBPM 3.2 ? (but used to work on 3.1.4 ?)
| ProcessInstance processInstance2 = new ProcessInstance( processDefinition2 );
| processInstance2.getContextInstance( ).setVariable( "a",
"2" );
| processInstance2.signal( );
| assertEquals( processDefinition2.getNode( "b" ),
| processInstance2.getRootToken( ).getNode( ) );
| }
| }
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4039955#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...