JBoss Community

Process variables, rules, Gateway constraints

created by Gary Struthers in jBPM - View the full discussion

I followed Accessing process variables in rule-task http://community.jboss.org/message/607839#607839

But I'm starting a new thread because I have new problems and that thread was marked as answered.

I'm missing something important about how to handle variables in rules and constraints but I can't find it.

 

A JUnit4 test fails when I call fireAllRules()

org.drools.RuntimeDroolsException: Unexpected exception executing action org.jbpm.process.instance.event.DefaultSignalManager$SignalAction@3e4ac866

          at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1000)

          at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:733)

          at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:702)

          at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)

 

  @Test

          public void assignApplication() throws Exception {

  // given

                    StatefulKnowledgeSession kSession = createKnowledgeSession(getKbase());

                    String ready = new String("false");

                    String assignLHS = new String("true");

                    Map<String, Object> params = new HashMap<String, Object>();

                    params.put("ready", ready);

                    params.put("assignLHS", assignLHS);

                    ProcessInstance pi = kSession.startProcess("dummy", params);

                    this.assertNodeTriggered(pi.getId(), "Start","AddPiFact", "Assign Application");

                    kSession.fireAllRules();

 

AddPiFact is a script immediately after Start with this action:

import org.drools.runtime.KnowledgeContext

import org.drools.runtime.KnowledgeRuntime

 

kcontext.getKnowledgeRuntime().insert(kcontext.getProcessInstance());

 

The rule is supposed to set "ready" if "assignLHS" is true

import org.drools.runtime.process.WorkflowProcessInstance

 

rule "applicationReady"

    ruleflow-group "assignApplication"

    when

        $process: WorkflowProcessInstance()

        $assignLHS :String() from (String)$process.getVariable("assignLHS");

        eval($assignLHS == "true");

    then

        $process.setVariable("ready", "true");

        update($process);

end

 

I want an XOR Gateway to use "ready" in its Constraints but if I write it like

return ready.compareIgnoreCase("true");

 

The KnowledgeBuilder has an error that "ready" can't be resolved.

Reply to this message by going to Community

Start a new discussion in jBPM at Community