I have a requirement for a simple rule flow containing a "status" process 
variable; a work item sets the value of this variable via its Result 
Mapping. Following the work item is an XOR Split node, which can go to one 
of two following nodes, depending on the value of the status process 
variable. The relevant sections from the rule flow definition, as 
currently written, are as follows:

  <header>
    <variables>
      <variable name="status" >
        <type 
name="org.drools.process.core.datatype.impl.type.StringDataType" />
      </variable>
      ...
    </variables>
  </header>

  <nodes>
    ...
    <workItem id="4" name="Test work item" x="352" y="52" width="80" 
height="40" >
      <work name="TestItem" >
      </work>
      <mapping type="out" from="status" to="status" />
    </workItem>
    ...
    <split id="9" name="Split" x="464" y="52" width="80" height="40" 
type="2" >
      <constraints>
        <constraint toNodeId="10" toType="DROOLS_DEFAULT" name="error" 
priority="1" type="code" dialect="java" 
>status.equals("error")</constraint>
        <constraint toNodeId="8" toType="DROOLS_DEFAULT" name="success" 
priority="1" type="code" dialect="java" 
>status.equals("success")</constraint>
      </constraints>
    </split>
    ...
  </nodes>
The Java code that implements the "TestItem" work item finishes with the 
code:

    Map<String, Object> results = new HashMap<String, Object>();
    results.put("status", status);  // Value of status can be "success" or 
"error"
 
ksession.getWorkItemManager().completeWorkItem(stepInstance.getWorkItemId(), 
results);
When I execute this process, no matter what the value of the status result 
returned by the work item, the node with ID 8 (the 'success' path) always 
executes.
I hope it's clear what I'm trying to do (i.e. define a process variable, 
sets its value using the result from a work item, and then test its value 
in a Split node); can anyone help me out as to why it's not working? 
(Incidentally, this is Drools v5.1M1.)
Many thanks,
Alan
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to