[rules-users] Does Drools Fusion support "Group By" clause ?

Kiran Ananthpur Bacche (kbacche) kbacche at cisco.com
Mon Jan 3 07:41:14 EST 2011


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 at lists.jboss.org
[mailto:rules-users-bounces at 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 at 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 at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




More information about the rules-users mailing list