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
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to