[rules-users] How to reuse a result of a rule in an other rule

mjohansen mjohansen at lazboy.com
Thu Jul 21 17:18:24 EDT 2011


Basically, you can either update an object with the results of the first
rule, or create a new object.

Like:

rule "Hungry"
  when
    $person : Person(hoursSinceLunch>2 || donutsOnDesk==0 ||
candybarsInDrawer==0)
  then
    $person.setHungry(true);
    update($person);
end

rule "Food"
  when
    $person : Person(hungry==true)
  then
    $person.lookForFood()
end

or

rule "Hungry"
  when
    $person : Person(hoursSinceLunch>2 || donutsOnDesk==0 ||
candybarsInDrawer==0)
  then
     $hungry=new Hungry();
     $hungry.setPerson($person);
     insert($hungry);
end

rule "Food"
  when
    $person : Person()
    $hungry : Hungry(person==$person)
  then
    $person.lookForFood()
end
  

--
View this message in context: http://drools.46999.n3.nabble.com/How-to-reuse-a-result-of-a-rule-in-an-other-rule-tp3182344p3189730.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list