1 Reply Latest reply on Mar 26, 2012 1:23 PM by wtimpany

    intermediateCatchEvent - conditionalEventDefinition using drools

    wtimpany

      Hi, hopefully someone can point me in the correct direction.  

       

      I have a Fact that I want to check in an Intermediate Catch Event, I want to compare that Fact to a hardcoded "Yes/No" value and to a Process Instance variable that is in the ksession.

       

      The process instance variable called "currentInstanceId" needs to be checked as part of the condition match.   I have hardcoded the "currentInstanceId" into the condition for the moment (and this works for testing). But I need to replace the hard coded "35036-1" is with a comparison to the id in the current process scope.

       

      Any help would be appreciated.

       

      FYI: the logic that I am trying to implement is: process goes along until a point is reached, where the process should wait until an Asset does not have any Infrastructure associated.  The process should wait until a matching Fact is inserted into working memory.  e.g. matching InstanceInfrastructureFact() is inserted with values matching the wait condition.

       

      Java Excerpt

       

      InstanceInfrastructureFact instanceInfrastructureFact = new InstanceInfrastructureFact();
      instanceInfrastructureFact.setExists("No");
      instanceInfrastructureFact.setInstanceId("35036-1");
      ksession.insert(instanceInfrastructureFact); 
      

       

       

       

      BPMN Excerpt

       

          <intermediateCatchEvent id="_5" name="Wait Until - Has Production Infrastructure is false" >
            <conditionalEventDefinition>
              <condition xsi:type="tFormalExpression" language="http://www.jboss.org/drools/rule">InstanceInfrastructureFact(exists == "No", instanceId == "35036-1")</condition>
            </conditionalEventDefinition>
          </intermediateCatchEvent>
      
      
        • 1. Re: intermediateCatchEvent - conditionalEventDefinition using drools
          wtimpany

          I have managed to find a solution that works for me with a bit of googling, and inspecting the example applications.

           

          With the Script Task and the updated Condition Definition, inserting my Facts triggers the Condition.

           

           

          Script Task preceding the Condition

           

          // -- set variable in kcontext
          
          kcontext.setVariable("instanceId", wsb.getInstanceId());
           
          // -- insert ProcessInstance into KnowledgeRuntime
          kcontext.getKnowledgeRuntime().insert(kcontext.getProcessInstance());
          

           

           

          Updated BPMN Task

           

           

          <intermediateCatchEvent id="_5" name="Wait Until - Has Production Infrastructure is false" >
             <conditionalEventDefinition>
                <condition xsi:type="tFormalExpression" language="http://www.jboss.org/drools/rule">$processInstance : WorkflowProcessInstance() $instanceId : String() from (String)$processInstance.getVariable("instanceId"); InstanceInfrastructureFact(exists == "No", instanceId == $instanceId);</condition>
             </conditionalEventDefinition>
          </intermediateCatchEvent>