Kiran,
We don't have "syntax sugar" for group by yet, and so for cases
where your grouping expression is an attribute of a summarized object
and not an entity by itself, you need to use a trick. It can be
written in a single rule, but I recommend using a "registration" rule:
declare SaleType
type : String
end
rule "register types"
when
Sale( $type : type )
then
insertLogical( new SaleType( $type ) );
end
And then you can group by SaleType on your accumulation rules.
It is on our todo list to provide better support for this case.
Edson
2011/1/3 Kiran Ananthpur Bacche (kbacche) <kbacche(a)cisco.com>:
Hi Gabor,
Thanks for your response.
I looked at this example in the user guide. In this example, there are
two Event POJO (Order.java and OrderItem.java) that are injected.
The example I quoted initially is slightly different. There is only one
Event Pojo (Sale.java). The "type" can be a string or int attribute in
Sale.java that can hold any random value. So it is not possible to make
it a new Event POJO (Type.java), and insert all possible instances with
different possible values.
This requirement is for a CEP Engine. I used ESPER, and could achieve
this easily using the "group by" clause in the EPL language.
Withn DROOLs FUSION, Im not able to do the same.
Thanks
Kiran
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Gabor Szokoli
Sent: Monday, January 03, 2011 5:31 PM
To: Rules Users List
Subject: Re: [rules-users] Does Drools Fusion support "Group By" clause
?
Hi,
2011/1/3 Kiran Ananthpur Bacche (kbacche) <kbacche(a)cisco.com>:
> I want the rule to fire successfully only when the TotalSalesAmount
for
> _any_ given type exceeds 100.
I've never used "accumulate" myself, so I looked it up in the manual,
and there's an example that's exactly what you want :-)
(just substitute $order with your $type)
rule "Apply 10% discount to orders over US$ 100,00"
when
$order : Order()
$total : Number( doubleValue > 100 )
from accumulate( OrderItem( order == $order, $value : value
),
sum( $value ) )
then
# apply discount to $order
end
http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-expert/h
tml_single/index.html#d0e4893
Gabor
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @
www.jboss.com