Within accumulate(...) and in similar constructs, the logical operators must be<br>written; the "and" is not implied.<br><br>OrderPart( $orderPartItemId: itemId, $orderPartItemAmount: amount ) from $orderParts<br>
<br> and<br><br>
Item( $itemPrice: price, id == $orderPartItemId )<br><br>-W<br><br><br><div class="gmail_quote">On 20 December 2010 11:35, AleBu <span dir="ltr"><<a href="mailto:aleboo@gmail.com">aleboo@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Hi Mark,<br>
Can you tell me what is wrong then with a rule below (WHEN part provided):<br>
when<br>
$order: Order( $orderId: id, $userId: userId, $orderParts: orderPart /*<br>
this is a collection */ )<br>
$user: User( id == $userId, $userOrderMoneyLimit: orderMoneyLimit )<br>
Double( $orderTotal: doubleValue ) from accumulate (<br>
OrderPart( $orderPartItemId: itemId, $orderPartItemAmount: amount ) from<br>
$orderParts<br>
Item( $itemPrice: price, id == $orderPartItemId ), // Line NNN<br>
init( double total=0; ),<br>
action( total += $itemPrice * $orderPartItemAmount; ),<br>
reverse( rval -= $itemPrice * $orderPartItemAmount; ),<br>
result( total )<br>
)<br>
<br>
I got an error:<br>
<br>
mismatched input 'Item' expecting ')' in rule "XXX"[NNN,53]: [ERR 102] Line<br>
NNN:53 mismatched input ',' expecting 'then' in rule "XXX"<br>
<br>
I tried to group both patterns with () but with the same result.<br>
Also, by changing rule to the one below (by removing second pattern and<br>
simulating $itemPrice):<br>
when<br>
$order: Order( $orderId: id, $userId: userId, $orderParts: orderPart /*<br>
this is a collection */ )<br>
$user: User( id == $userId, $userOrderMoneyLimit: orderMoneyLimit )<br>
Double( $orderTotal: doubleValue ) from accumulate (<br>
OrderPart( $orderPartItemId: itemId, $orderPartItemAmount: amount ) from<br>
$orderParts,<br>
init( double total=0; double $itemPrice=3.33; ),<br>
action( total += $itemPrice * $orderPartItemAmount; ),<br>
reverse( rval -= $itemPrice * $orderPartItemAmount; ),<br>
result( total )<br>
)<br>
<br>
Everything works fine.<br>
So, it looks like that problem is related to Second pattern. Is there some<br>
special syntax for it?<br>
<font color="#888888"><br>
<br>
--<br>
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Drools-4-0-Support-for-multiple-pattern-in-accumulate-source-pattern-tp53487p2119555.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Drools-4-0-Support-for-multiple-pattern-in-accumulate-source-pattern-tp53487p2119555.html</a><br>
Sent from the Drools - User mailing list archive at Nabble.com.<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br>