[rules-users] Using count()
Mark Proctor
mproctor at codehaus.org
Tue Jul 31 17:20:23 EDT 2007
Sounds like what you really want is collect
$tickets : ArrayList( $i : size ) from collect( Ticket(status ==
"Escalate", customer == customer ) )
Mark
tom at bergstein-soraic.de wrote:
>
> Thank you, Mark.
>
>
>
>
>
>
>
> I guess I succeeded with your hint using following rule:
>
>
>
>
>
> rule "Test some counting"
>
>
>
> no-loop true
>
>
>
> when
>
>
>
> &nb sp; customer : Customer()
>
>
>
> $i : Number( intValue > 5 )
>
>
>
> from accumulate( $t : Ticket(status == "Escalate", customer
> == customer ), count( $t )) &! nbsp;
>
>
>
> then
>
>
>
>
>
>
>
> ; System.out.println( "Num : " + $i + " " + customer );
>
>
>
>
>
>
>
> end
>
>
>
>
>
> This there any way to get access to the counted Tickets in the "then"
> part? Do I have to perfrom a query?
>
>
>
>
>
>
>
>
>
>
>
> ---- Mark wrote: ------
>
> look at hte Shopping Example, I use sum() there, but the concept is
> the same:
>
> rule "determine 10% discount if total purcahses is over 100"
> no-loop tr! ue
> when
> &n bsp; $c : Customer()
> $i : Double(doubleValue > 100) from accumulate ( Purchase(
> customer == $c, $price : product.price ),
>
> sum( $price ) )
> then
> $c.setDiscount( 10 );
> insertLogical( new Discount($c, 10) );
> end
>
> Mark
> tom at bergstein-soraic.de wrote:
>> Does anybody have a good example about using count()?
>> ------------------------------------------------------------------------
>> _______________________________________________ rules-users mailing list rules-users at lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070731/0acc2b1b/attachment.html
More information about the rules-users
mailing list