[rules-users] Loop Drools on Multi Element
Wolfgang Laun
wolfgang.laun at gmail.com
Tue Feb 21 03:35:00 EST 2012
As an alternative to the CE forall, consider
rule setPriority
when
$order: OrderType( priority != "high" )
not OrderLineType( quantity <= 2 ) from $order.lineItem
then
modify( $order ){ setPriority( "high" ) }
end
-W
On 21/02/2012, FrankVhh <frank.vanhoenshoven at agserv.eu> wrote:
> Hi,
>
> See forall element in Drools manual:
> 5.8.3.6.1. Conditional Element forall
>
> It does exactly what you describe. For the record, you may want to insert
> all your line items separately to working memory.
>
> Kind regards,
> Frank
>
>
> aliosha79 wrote
>>
>> Hi,
>> i'm Alessio and i'm new in this forum. I'm learning to use drool in this
>> period and i'm facing a problem.
>> Briefly:
>> 1- i have an xml document with a repeated element i.e.:
>> <order>
>> <orderLine>
>> <lineItem>
>> <name>item1</name>
>> <quantity>35</quantity>
>> </lineItem>
>> <orderline>
>> <orderLine>
>> <lineItem>
>> <name>item2</name>
>> <quantity>65</quantity>
>> </lineItem>
>> <orderline>
>> <orderLine>
>> <lineItem>
>> <name>item3</name>
>> <quantity>52</quantity>
>> </lineItem>
>> <orderline>
>> <priority>Normal</priority>
>> </order>
>>
>> 2- i marshalled it in a java class named "OrderType" using jaxb library
>> 3- then i want to apply a rule stating: /IF EVERY LINEITEM QUANTITY IS
>> GREATER THAN 2
>> THEN SET PRIORITY TO HIGH/
>>
>> i can access every single order line Element using this rule:
>>
>> when
>> $Order : OrderType($Order.OrderLine[0].LineItem.Quantity.Value > 2)
>> then
>> $Order.getUBLRuleEnginePriority().setValue("High");
>>
>> $Order.addApplyedRule("hpRule");
>> end
>>
>> But how can i cycle on each of them writing the rule at point 3?
>> Thanks a lot.
>> Aliosha
>>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Loop-Drools-on-Multi-Element-tp3761638p3762858.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
More information about the rules-users
mailing list