Lionel:

    What is suppose to happen is the rules should fire in this order:

    Assign task rule
    Audit Task Rule
    Route Task Rule
    Suspend Task Rule


    I've re-numbered the rules to show this sequence.


        <!-- priority and no recursive rule -->
   <rule name="AssignTask" salience="-1" no-loop="true">
      <!-- What is being passed into the rule -->
      <parameter identifier="taskVO">
         <class>TaskVO</class>
      </parameter>
       <!--  What conditions must be true before rule is asserted -->
      <java:condition>taskVO.getIdentifiersList() != null || 
taskVO.isIdentifiersListEmpty() == false</java:condition>
      <java:condition>taskVO.containsIdentifier("CONTRACT", "S#1234567890") == 
true</java:condition>
      
      <!-- What does the rule does for us -->
      <java:consequence>
          taskVO.setDepartment("DPT1");
          taskVO.setDptCode(lookupDeptCode("DPT1"));
          taskVO.setWorkBasket("rray");
          taskVO.setTaskType("ADFPAYCHK");
          taskVO.setTskCode(lookupTaskTypeCode("ADFPAYCHK"));
          taskVO.setActionStep("INDEX");
          taskVO.setActCode(lookupActStepCode("INDEX"));
          taskVO.setStatus("OPEN");
          //printTaskVO(taskVO);
          <!-- Firing any other rules based on changes -->
          drools.modifyObject(taskVO);
      </java:consequence>    
   </rule>
   
      <!-- priority and no recursive rule -->
   <rule name="AuditTask" salience="0" no-loop="true">
      <!-- What is being passed into the rule -->
      <parameter identifier="taskVO">
         <class>TaskVO</class>
      </parameter>
       <!--  What conditions must be true before rule is asserted -->
      <java:condition>taskVO.getStatus().equalsIgnoreCase("OPEN") == 
true</java:condition>
      <java:condition>taskVO.getTaskType().equalsIgnoreCase("ADFPAYCHK") == 
true</java:condition>
      <java:condition>taskVO.containsIdentifier("CONTRACT", "S#1234567890") == 
true</java:condition>
      
      
      <!-- What does the rule does for us -->
      <java:consequence>
          ident = new IdentifierVO();
                  ident.setTaskId("t1234567890");
                  ident.addField("COMPANY20060313-0000001");
                  ident.addFieldName("AUDIT NBR");
                  ident.addFieldSize(45);
                  ident.setIdDesc("AUDIT NBR");
                  taskVO.addIdentifier(ident);
                  taskVO.setActionStep("PROCESS");
          //printTaskVO(taskVO);
          <!-- Firing any other rules based on changes -->
          drools.modifyObject(taskVO);
      </java:consequence>    
   </rule>
   
        <!-- priority and no recursive rule -->
   <rule name="RouteTask" salience="1" no-loop="true">
      <!-- What is being passed into the rule -->
      <parameter identifier="taskVO">
         <class>TaskVO</class>
      </parameter>
       <!--  What conditions must be true before rule is asserted -->
      <java:condition>taskVO.getStatus().equalsIgnoreCase("OPEN") == true 
</java:condition>
      <java:condition>taskVO.getTaskType().equalsIgnoreCase("ADFPAYCHK") == 
true</java:condition>
      <java:condition>taskVO.containsIdentifier("AUDIT NBR", 
"COMPANY20060313-0000001") == true</java:condition>

      
      <!-- What does the rule does for us -->
      <java:consequence>
          taskVO.setWorkBasket("mightymouse");
          taskVO.setStatus("REVIEW");
          //printTaskVO(taskVO);
          <!-- Firing any other rules based on changes -->
          drools.modifyObject(taskVO);
      </java:consequence>    
   </rule>
   
   
   
         <!-- priority and no recursive rule -->
   <rule name="SuspendTask" salience="2" no-loop="true">
      <!-- What is being passed into the rule -->
      <parameter identifier="taskVO">
         <class>TaskVO</class>
      </parameter>
       <!--  What conditions must be true before rule is asserted -->
      <java:condition>taskVO.getTaskType().equals("ADFPAYCHK") == 
true</java:condition>
      <java:condition>taskVO.getStatus().equalsIgnoreCase("REVIEW") == 
true</java:condition>
      <java:condition>taskVO.getCaseDesc().equalsIgnoreCase("missing 
signature") == true</java:condition>
      
      <!-- What does the rule does for us -->
      <java:consequence>
          taskVO.setStatus("SUSPEND");
          taskVO.setSuspOper("MightyMouse");
          taskVO.setCaseDesc("missing signature");
          taskVO.setCaseId("C1234567890");
          DroolsMail mail = new DroolsMail();
           try{
              mail.postMail(loadMailReceipients(),
                               "Drools Dispatch Mail",
                               "This is a Drools Test",
                               "[EMAIL PROTECTED]");
           }catch (MessagingException me){
              me.printStackTrace();
           }
          //printTaskVO(taskVO);
          <!-- Firing any other rules based on changes -->
          drools.modifyObject(taskVO);
      </java:consequence>    
   </rule>




-----Original Message-----
From: Lionel Port [mailto:[EMAIL PROTECTED]
Sent: Monday, March 13, 2006 11:13 PM
To: [email protected]
Subject: Re: [drools-user] Chaining Rules


>From the look of it.
If that last rule you defined is activated it will fire first and set the
status to "suspend", so no other rule is fired.
If not you will likely have the rules firing in the following sequence
RouteTask, AssignTask, AuditTask, AssignTask, AuditTask, AssignTask,
AuditTask... forever.
Or have I missed the ending condition.

On 3/14/06, Geoffrey Wiseman <[EMAIL PROTECTED]> wrote:
>
> On 3/13/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> >    Maybe I am not seeing the error in my ways.  I have four rules.  I am
> > chaining them together.  Each rule acts upon the object in a different
> > way.  I have set up the no-loop attribute so no rule is fired more than
> > once.  I have also assigned a priority for each of the rules so they
> will
> > execute in sequence. I have four Conflict resolvers loaded (Salience,
> > Recency, Simplicity, Load).  After I have performed a said operation
> within
> > a rule, I call the function    drools.modifyObject(taskVO) for updating
> > the fact.  However, I am not seeing the final results with all the
> > information getting into the object after all the four rules have fired:
> >
>
> Ok, so what ARE you seeing?   Are any of the rules firing?  Did you try
> adding an event listener to trace the rules?
>
> --
> Geoffrey Wiseman
>
>

Reply via email to