[rules-users] Drools 4.0, Support for multiple pattern in accumulate source pattern

Wolfgang Laun wolfgang.laun at gmail.com
Mon Dec 20 06:28:29 EST 2010


Within accumulate(...) and in similar constructs, the logical operators must
be
written; the "and" is not implied.

OrderPart( $orderPartItemId: itemId, $orderPartItemAmount: amount ) from
$orderParts

                     and

                     Item( $itemPrice: price, id == $orderPartItemId )

-W


On 20 December 2010 11:35, AleBu <aleboo at gmail.com> wrote:

>
> Hi Mark,
> Can you tell me what is wrong then with a rule below (WHEN part provided):
>        when
>                $order: Order( $orderId: id, $userId: userId, $orderParts:
> orderPart /*
> this is a collection */ )
>                $user: User( id == $userId, $userOrderMoneyLimit:
> orderMoneyLimit )
>                Double( $orderTotal: doubleValue ) from accumulate (
>                        OrderPart( $orderPartItemId: itemId,
> $orderPartItemAmount: amount ) from
> $orderParts
>                        Item( $itemPrice: price, id == $orderPartItemId ),
> // Line NNN
>                        init( double total=0; ),
>                        action( total += $itemPrice * $orderPartItemAmount;
> ),
>                        reverse( rval -= $itemPrice * $orderPartItemAmount;
> ),
>                        result( total )
>                )
>
> I got an error:
>
> mismatched input 'Item' expecting ')' in rule "XXX"[NNN,53]: [ERR 102] Line
> NNN:53 mismatched input ',' expecting 'then' in rule "XXX"
>
> I tried to group both patterns with () but with the same result.
> Also, by changing rule to the one below (by removing second pattern and
> simulating $itemPrice):
>        when
>                $order: Order( $orderId: id, $userId: userId, $orderParts:
> orderPart /*
> this is a collection */ )
>                $user: User( id == $userId, $userOrderMoneyLimit:
> orderMoneyLimit )
>                Double( $orderTotal: doubleValue ) from accumulate (
>                        OrderPart( $orderPartItemId: itemId,
> $orderPartItemAmount: amount ) from
> $orderParts,
>                        init( double total=0; double $itemPrice=3.33; ),
>                        action( total += $itemPrice * $orderPartItemAmount;
> ),
>                        reverse( rval -= $itemPrice * $orderPartItemAmount;
> ),
>                        result( total )
>                )
>
> Everything works fine.
> So, it looks like that problem is related to Second pattern. Is there some
> special syntax for it?
>
>
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/Drools-4-0-Support-for-multiple-pattern-in-accumulate-source-pattern-tp53487p2119555.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> 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/20101220/218b50f2/attachment.html 


More information about the rules-users mailing list