<div><br></div>   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&#39;ve been postponing that because when I do it, it will break existing implementations of the interface.<div>
<br></div><div>   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.</div><div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><div>
$options : List() from accumulate( </div><div>      $op : Option(),</div><div>      matchAll( [ ${param}, $op ] ) )</div></span><div><br></div><div>    Edson</div><br><div class="gmail_quote">2011/1/29 groovenarula <span dir="ltr">&lt;<a href="mailto:gnarula1@la-z-boy.com">gnarula1@la-z-boy.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
Edson,<br>
<br>
I did manage to use the &#39;CollectSetAccumulateFunction&#39; as a template for the<br>
MatchAll and have also successfully &#39;called&#39; the accumulate function from a<br>
rule written in a .drl file. But I&#39;m stuck at one point - how to send the<br>
value of $param to the accumulate method ? From what I understand, the<br>
accumulate method is invoked for each fact - so if I write<br>
<br>
     MatchAll( $o ) it will invoke the accumulate method and passing $o fact<br>
to the method via the &#39;Object value&#39; parameter.<br>
<br>
So far so go, however, I&#39;m stuck on how to pass the value of &#39;$param&#39; to the<br>
accumulate method (or any other method like init, getResult for that<br>
matter).<br>
<br>
One option I can think of is to change the definition of the Option fact to<br>
include a &#39;param&#39; field and then write a rule that sets the value of that<br>
field to $param (so every Options param field would get set to the value of<br>
$param). I can then extract that in the accumulate method it self. But is<br>
there a better way that I might be missing ?<br>
<br>
Thanks in advance,<br>
Gurvinder<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="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" target="_blank">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</a><br>

</font><div class="im">Sent from the Drools - User mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
</div><div><div></div><div class="h5"><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>