<br><font size=2 face="sans-serif">Kris,<br>
</font>
<br><font size=2 face="sans-serif">Thanks for the fast response - the 'return'
statement made all the difference - it's working as expected now.</font>
<br>
<br><font size=2 face="sans-serif">This was code from a simple unit test,
so I wasn't initially checking errors after loading the process. After
adding the code you suggested, the old process definition (i.e. without
the return statement in the split node constraints) failed to parse with
the following error:</font>
<br>
<br><font size=2 face="sans-serif">&quot;This method must return a result
of type Object&quot;</font>
<br>
<br><font size=2 face="sans-serif">&nbsp;- pretty obvious that a return
statement was required. I'll be sure to add the error checking code to
all future tests. ;)</font>
<br>
<br><font size=2 face="sans-serif">Thanks again for your help,</font>
<br>
<br><font size=2 face="sans-serif">Alan</font>
<p>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>Kris Verlaenen &lt;kris.verlaenen@cs.kuleuven.be&gt;</b>
</font>
<br><font size=1 face="sans-serif">Sent by: rules-users-bounces@lists.jboss.org</font>
<p><font size=1 face="sans-serif">19/10/2009 16:43</font>
<table border>
<tr valign=top>
<td bgcolor=white>
<div align=center><font size=1 face="sans-serif">Please respond to<br>
Rules Users List &lt;rules-users@lists.jboss.org&gt;</font></div></table>
<br>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif">Rules Users List &lt;rules-users@lists.jboss.org&gt;,
Alan.Gairey@tessella.com</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">Re: [rules-users] How do I configure
the constraints for a Split &nbsp; &nbsp; &nbsp; &nbsp;node in
Drools Flow to test the value of a process variable?</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><tt><font size=2>Alan,<br>
<br>
Your code constraints should look something like:<br>
<br>
 &nbsp;return &quot;error&quot;.equals(status);<br>
<br>
Do you check for errors after loading a process? &nbsp;Basically, errors<br>
should be detected when trying to parse the given process because the<br>
constraints could not be compiled (at least, that happened when I tried<br>
something similar).<br>
<br>
KnowledgeBuilderErrors errors = kbuilder.getErrors();<br>
if (errors.size() &gt; 0) {<br>
 &nbsp;for (KnowledgeBuilderError error: errors) {<br>
 &nbsp; &nbsp;System.err.println(error);<br>
 &nbsp;}<br>
 &nbsp;throw new IllegalArgumentException(&quot;Could not parse knowledge.&quot;);<br>
}<br>
<br>
If you don't get any errors, could you sent me a self-contained example<br>
that shows this issue, so I can figure out what's going on?<br>
<br>
Thx,<br>
Kris<br>
<br>
Quoting Alan.Gairey@tessella.com:<br>
<br>
&gt; I have a requirement for a simple rule flow containing a &quot;status&quot;<br>
&gt; process <br>
&gt; variable; a work item sets the value of this variable via its Result<br>
&gt; <br>
&gt; Mapping. Following the work item is an XOR Split node, which can go<br>
&gt; to one <br>
&gt; of two following nodes, depending on the value of the status process<br>
&gt; <br>
&gt; variable. The relevant sections from the rule flow definition, as
<br>
&gt; currently written, are as follows:<br>
&gt; <br>
&gt; &nbsp; &lt;header&gt;<br>
&gt; &nbsp; &nbsp; &lt;variables&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &lt;variable name=&quot;status&quot; &gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;type <br>
&gt; name=&quot;org.drools.process.core.datatype.impl.type.StringDataType&quot;
/&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &lt;/variable&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; ...<br>
&gt; &nbsp; &nbsp; &lt;/variables&gt;<br>
&gt; &nbsp; &lt;/header&gt;<br>
&gt; <br>
&gt; &nbsp; &lt;nodes&gt;<br>
&gt; &nbsp; &nbsp; ...<br>
&gt; &nbsp; &nbsp; &lt;workItem id=&quot;4&quot; name=&quot;Test work item&quot;
x=&quot;352&quot; y=&quot;52&quot; width=&quot;80&quot;<br>
&gt; <br>
&gt; height=&quot;40&quot; &gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &lt;work name=&quot;TestItem&quot; &gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &lt;/work&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &lt;mapping type=&quot;out&quot; from=&quot;status&quot;
to=&quot;status&quot; /&gt;<br>
&gt; &nbsp; &nbsp; &lt;/workItem&gt;<br>
&gt; &nbsp; &nbsp; ...<br>
&gt; &nbsp; &nbsp; &lt;split id=&quot;9&quot; name=&quot;Split&quot; x=&quot;464&quot;
y=&quot;52&quot; width=&quot;80&quot; height=&quot;40&quot;<br>
&gt; <br>
&gt; type=&quot;2&quot; &gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &lt;constraints&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;constraint toNodeId=&quot;10&quot;
toType=&quot;DROOLS_DEFAULT&quot;<br>
&gt; name=&quot;error&quot; <br>
&gt; priority=&quot;1&quot; type=&quot;code&quot; dialect=&quot;java&quot;
<br>
&gt; &gt;status.equals(&quot;error&quot;)&lt;/constraint&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;constraint toNodeId=&quot;8&quot;
toType=&quot;DROOLS_DEFAULT&quot;<br>
&gt; name=&quot;success&quot; <br>
&gt; priority=&quot;1&quot; type=&quot;code&quot; dialect=&quot;java&quot;
<br>
&gt; &gt;status.equals(&quot;success&quot;)&lt;/constraint&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &lt;/constraints&gt;<br>
&gt; &nbsp; &nbsp; &lt;/split&gt;<br>
&gt; &nbsp; &nbsp; ...<br>
&gt; &nbsp; &lt;/nodes&gt;<br>
&gt; The Java code that implements the &quot;TestItem&quot; work item finishes
with<br>
&gt; the <br>
&gt; code:<br>
&gt; <br>
&gt; &nbsp; &nbsp; Map&lt;String, Object&gt; results = new HashMap&lt;String,
Object&gt;();<br>
&gt; &nbsp; &nbsp; results.put(&quot;status&quot;, status); &nbsp;// Value
of status can be<br>
&gt; &quot;success&quot; or <br>
&gt; &quot;error&quot;<br>
&gt; &nbsp;<br>
&gt;<br>
ksession.getWorkItemManager().completeWorkItem(stepInstance.getWorkItemId(),<br>
&gt; <br>
&gt; results);<br>
&gt; When I execute this process, no matter what the value of the status<br>
&gt; result <br>
&gt; returned by the work item, the node with ID 8 (the 'success' path)<br>
&gt; always <br>
&gt; executes.<br>
&gt; I hope it's clear what I'm trying to do (i.e. define a process<br>
&gt; variable, <br>
&gt; sets its value using the result from a work item, and then test its<br>
&gt; value <br>
&gt; in a Split node); can anyone help me out as to why it's not working?<br>
&gt; <br>
&gt; (Incidentally, this is Drools v5.1M1.)<br>
&gt; Many thanks,<br>
&gt; Alan<br>
<br>
<br>
<br>
<br>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm<br>
_______________________________________________<br>
rules-users mailing list<br>
rules-users@lists.jboss.org<br>
https://lists.jboss.org/mailman/listinfo/rules-users<br>
</font></tt>
<br>