[rules-users] Using collect to group by

Heyns, Juan Juan.Heyns at lonplats.com
Thu Sep 20 03:47:43 EDT 2007


Hello,



I am trying to achieve something like a SQL statement equivalent of:



SELECT    r.property1 AS p1, r.property2 AS p2,
SOME_CALCULATION(r.property3) AS p3

FROM      right AS r

GROUP BY  p2, p3



I am not sure if this is valid SQL since I am grouping by a calculated
value, but that aside.



I am asserting the Rights objects into the working memory and then would
like to execute a rule on the objects based

on a grouping of objects. The first property is directly accessible from
the object right.getProperty2() but the

second property is only accessible through a lookup
MyClass.staticMethod(right.getProperty3()).



As far as I have it the rule should make use of something like collect
or accumulate but I do not know how to

achieve this without also asserting the properties objects into the
memory as well. And even if I assert the properties

objects into the working memory I do not know how to group by the second
property.



rule "Calculate something"

     no-loop

     when

           $rights: ArrayList( )

                   from collect( Right( ) );



     then

           // execute rule

end



Could you please give me some assistance?



Regards

Juan



"Employees of Lonmin Platinum ("Lonplats") are not authorised to conclude
electronic transactions or to enter into electronic agreements on behalf
of Lonplats. Any electronic signature (other than an advanced electronic
signature as defined in the Electronic Communications and Transactions
Act of 2003) added to a data message (such as an email or an attachment
to an (email) ostensibly on behalf of Lonplats by a Lonplats employee shall
not be legally binding on Lonplats and Lonplats shall incur no liability of
any nature whatsoever, directly or indirectly, arising from such act on the
part of it's employee. It is further recorded that nothing (other than an
advanced electronic signature) inserted into any data message
emanating from Lonplats shall be construed as constituting an electronic
signature"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070920/71da47b7/attachment.html 


More information about the rules-users mailing list