<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV>Here's the modified rule : </DIV>
<DIV> </DIV>
<DIV>rule "Test Accumulate Function"<BR>when<BR> $p : ProductType ($name : name)<BR> $min_score : Number ()<BR> from accumulate (Client (productTypeExperience.keySet contains $name,<BR> $score : productTypeExperience[$name]),<BR> min (((ExperienceLevel)$score).value()))<BR>then<BR> System.out.println ("$min_score" + $min_score);<BR>end</DIV>
<DIV> </DIV>
<DIV>and the runtime exception that i am getting is </DIV>
<DIV>Caused by: org.drools.RuntimeDroolsException:<BR> [Error: unable to resolve method: java.util.HashMap.$name() [arglength=0]]<BR>[Near : {... Unknown ....}]</DIV>
<DIV> </DIV>
<DIV>Regards,<BR>Manav</DIV>
<DIV><BR> </DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><BR>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><FONT face=Tahoma size=2>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Edson Tirelli <tirelli@post.com><BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> Manav <manav7574@yahoo.com>; Rules Users List <rules-users@lists.jboss.org><BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Mon, August 16, 2010 7:46:54 PM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: [rules-users] Accumulate in Drools<BR></FONT><BR>
<DIV> You can't use the cast and the method call in a regular constraint. You can use it as part of an expression. So:</DIV>
<DIV><BR></DIV>
<DIV> $min_score : Number ()<BR> from accumulate (Client (productTypeExperience.keySet contains $name,<BR> $score : productTypeExperience[$name],<BR> min ( ((ExperienceLevel)$score).value() ) )</DIV>
<DIV><BR></DIV>
<DIV> We are working on the support of free form expressions on constraints for Drools 6 (not sure we can make it for 5.2).</DIV>
<DIV><BR></DIV>
<DIV> Edson</DIV><BR><BR>
<DIV class=gmail_quote>2010/8/15 Manav <SPAN dir=ltr><<A href="mailto:manav7574@yahoo.com" target=_blank rel=nofollow ymailto="mailto:manav7574@yahoo.com">manav7574@yahoo.com</A>></SPAN><BR>
<BLOCKQUOTE class=gmail_quote style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi,<BR>I am trying my hand at the accumulate function in Drools 5.x but the drl fails<BR>to compile.<BR>Not sure what's wrong with it. Please help.<BR>This is the sample that i am working with<BR><BR>rule "Test Accumulate Function"<BR>when<BR> $p : ProductType ($name : name)<BR> $min_score : Number ()<BR> from accumulate (Client (productTypeExperience.keySet contains $name,<BR> $score :<BR>((ExperienceLevel)productTypeExperience[$name]).value()),<BR> min ($score))<BR>then<BR> System.out.println ("$min_score" + $min_score);<BR>end<BR>Regards,<BR><FONT color=#888888>Manav<BR></FONT>
<DIV>
<DIV></DIV>
<DIV class=h5><BR><BR><BR><BR>_______________________________________________<BR>rules-users mailing list<BR><A href="mailto:rules-users@lists.jboss.org" target=_blank rel=nofollow ymailto="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 rel=nofollow>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/" target=_blank rel=nofollow>www.jboss.com</A><BR></DIV></DIV></div><br>
</body></html>