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

Mark Proctor mproctor at codehaus.org
Mon Dec 20 06:15:12 EST 2010


Didn't you say you were on Drools 4? if so you can't use multiple patterns.

Mark
On 20/12/2010 10:35, AleBu 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?
>
>





More information about the rules-users mailing list