[rules-users] How to write a rule that fires when it matches against specific facts in working memory.

groovenarula gnarula1 at la-z-boy.com
Sat Jan 29 09:22:32 EST 2011


Edson,

I did manage to use the 'CollectSetAccumulateFunction' as a template for the
MatchAll and have also successfully 'called' the accumulate function from a
rule written in a .drl file. But I'm stuck at one point - how to send the
value of $param to the accumulate method ? From what I understand, the
accumulate method is invoked for each fact - so if I write 

     MatchAll( $o ) it will invoke the accumulate method and passing $o fact
to the method via the 'Object value' parameter. 

So far so go, however, I'm stuck on how to pass the value of '$param' to the
accumulate method (or any other method like init, getResult for that
matter).

One option I can think of is to change the definition of the Option fact to
include a 'param' field and then write a rule that sets the value of that
field to $param (so every Options param field would get set to the value of
$param). I can then extract that in the accumulate method it self. But is
there a better way that I might be missing ?

Thanks in advance,
Gurvinder
    
-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2369936.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list