Edson,
That worked beautifully !
Drools is looking more and more promising for what we need to do.
Thanks for all your help,
Gurvinder
-----Original Message-----
From: Edson Tirelli-4 [via Drools - Java Rules Engine] [[hidden email]]
Sent: Sat 1/29/2011 10:59 PM
To: Gurvinder Narula1
Subject: Re: How to write a rule that fires when it matches against specific facts in working memory.
  Up to Drools 5, the accumulate function API supports only a single argument to the function, but that argument can be an array or a list. So what I do on my own implementations is to pass the $param as one element of the array and $o as the other. It is not ideal, but it is how you can do that in Drools 5. In Drools 6 I will change the API to support multiple parameters, but I've been postponing that because when I do it, it will break existing implementations of the interface.
  Anyway, if you are using the MVEL dialect, creating a list is as simple as wrapping it in [ ], as you could see in my previous e-mail.
$options : List() from accumulate(Â
    $op : Option(),
    matchAll( [ ${param}, $op ] ) )
   Edson
2011/1/29 groovenarula <[hidden email]>
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 <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?by-user=t>
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
________________________________
If you reply to this email, your message will be added to the discussion below:
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-tp2294599p2380361.html
To unsubscribe from How to write a rule that fires when it matches against specific facts in working memory., click here <http://drools-java-rules-engine.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2294599&code=Z25hcnVsYTFAbGEtei1ib3kuY29tfDIyOTQ1OTl8MjAzMTM1NDY2Mw==> .