Re: [rules-users] Write Assumptions for NESTED ListObject
The Java code as shown has a somewhat unlikely flavour, with OrderLineMeasure containing the field ListOrderLineMeasure. And the names used in the rules don't match the Java code, e.g., getUBLRuleEnginePriority(). And why should a String field quantity indicate the size of a List? But see below for a (better) way of writing these rules. On 26/06/2012, aliosha79 alex_orl1...@yahoo.it wrote: Hi i have these simple three POJO class. The first is an OrderType that cointains a List or OrderLineType and each orderline cointains a list of measures. /public class OrderType { protected ListOrderLineType OrderLine; protected String priority; public void set public ListOrderlineType get publicgetPriority()... publicsetPriority()... } public class OrderLineType { protected String Quantity; protected ListOrderLineMeasure OrderLineMeasure; public void set public ListOrderLineMeasure get publicgetQuantity()... publicsetQuantity()... } public class OrderLineMeasure { protected int measure; protected ListOrderLineMeasure OrderLineMeasure; publicgetMeasure()... publicsetMeasure()... } / I want to write an assumption stating that: *If an ORDER contains at least 3 orderLine... the order must have the High Priority.* In can do that writing this rule: ___ /when $Order : OrderType ($orderLineList :orderLine) OrderLineType(Quantity.Value = 3 ) from $orderLineList then $Order.getUBLRuleEnginePriority().setValue(high); end/ Your rule would fire once for each OrderLine containing a quantity of more than 2, which is quite another thing than an order with at least 3 order lines. rule moreThanThree when $order : OrderType( orderLines.size() = 3, priority != high ) then modify( $order ){ setPriority( high ) } end You can access orderLines.size() without the need for from. Testing priority != high ensures that the rule does not loop if you use modify to notify the Engine that something has changed (which you probably should do). Now how can i write the assumption? if i want a rule stating: *If an ORDER contains at least 3 orderLine and Each OrderLine contains more than 12 measures... the order must have the High Priority.* Really thanks for your help. Regards. Alessio rule moreThanThreeTwelve when $order: OrderType( orderLines.size() = 3, priority != high ) not OrderLineType( measures.size() 12 ) from $order.getOrderLines() then System.out.println( 3/12 ); modify( $order ){ setPriority( high ) } end Here from is required to extract the OrderLineType objects. The not checks that they all have a List with at least 12 elements. -W -- View this message in context: http://drools.46999.n3.nabble.com/Write-Assumptions-for-NESTED-List-Object-tp4018241.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Write Assumptions for NESTED ListObject
Sorry, Laune, you've right, i bag your pardon as my first post was not so clear. Now i have re-edited it... maybe now the question is clearer. Can you read it again? I don't need to use .size() indeed... my real problem is to access the nested list properties.. In this case i can access the Quantity proterty of OrderLine... but i don't know how to access the measure proverty value in the nested OrderLineMeasure. Thanks a lot -- View this message in context: http://drools.46999.n3.nabble.com/Write-Assumptions-for-NESTED-List-Object-tp4018241p4018249.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Write Assumptions for NESTED ListObject
if i have well understood the DRL code the solution, in a form more compliant with my needs, could be something like this: when $order: OrderType( $orderLineList: this.orderLine, priority != high ) $measureList: measure from $orderLineList not ( this.measure 12 ) from $measureList then modify( $order ){ setPriority( high ) } end Is it right? i night to not use the get... methods... but directly to point the variables (this.measure... this.orderLine ... i already tried this form and it works). Is it correct? Really thanks for your help. Alessio -- View this message in context: http://drools.46999.n3.nabble.com/Write-Assumptions-for-NESTED-List-Object-tp4018241p4018254.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Write Assumptions for NESTED ListObject
Kindly take my rule as it was written, except for the necessary adjustments for the names of the getter methods. -W On 26/06/2012, aliosha79 alex_orl1...@yahoo.it wrote: if i have well understood the DRL code the solution, in a form more compliant with my needs, could be something like this: when $order: OrderType( $orderLineList: this.orderLine, priority != high ) $measureList: measure from $orderLineList not ( this.measure 12 ) from $measureList then modify( $order ){ setPriority( high ) } end Is it right? i night to not use the get... methods... but directly to point the variables (this.measure... this.orderLine ... i already tried this form and it works). Is it correct? Really thanks for your help. Alessio -- View this message in context: http://drools.46999.n3.nabble.com/Write-Assumptions-for-NESTED-List-Object-tp4018241p4018254.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Write Assumptions for NESTED ListObject
Laune, i need to know if this form is correct: when $order: OrderType( $orderLineList: this.orderLine, priority != high ) $measureList: measure from $orderLineList not ( this.measure 12 ) from $measureList then modify( $order ){ setPriority( high ) } end The reason is that i'm implementing a rule editor for my work in a way that, according to a selected xsd element from a displayed tree, i have to build the right line of DRL code. So i m forced for many reason to use a form similar to the one written above. The pattern i'm using (and at this point i cannot change it anymore) is something like this: declaring $variableList accessing the list using (this.property == value) FROM $variableList it's a big costraint... i know... but i have to work this way. So should the previous rule work? Really thanks. Alessio -- View this message in context: http://drools.46999.n3.nabble.com/Write-Assumptions-for-NESTED-List-Object-tp4018241p4018256.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Write Assumptions for NESTED ListObject
On 26/06/2012, aliosha79 alex_orl1...@yahoo.it wrote: Laune, i need to know if this form is correct: when $order: OrderType( $orderLineList: this.orderLine, priority != high ) (You could omit this.) $measureList: measure from $orderLineList This is incorrect DRL syntax. You have to extract (using from) the elements of orderLine which are of class OrderLineType, and from these you can extract measure. not ( this.measure 12 ) from $measureList This is ncorrect DRL syntax. then modify( $order ){ setPriority( high ) } end Using variables bound to the List fields: when $order: OrderType( $orderLineList: orderLines, priority != high ) $olt: OrderLineType( $measures: measures ) from $orderLineList not Measure( measure 12 ) from $measures then The reason is that i'm implementing a rule editor for my work in a way that, according to a selected xsd element from a displayed tree, i have to build the right line of DRL code. So i m forced for many reason to use a form similar to the one written above. The pattern i'm using (and at this point i cannot change it anymore) is something like this: declaring $variableList accessing the list using (this.property == value) FROM $variableList You'll *have* to add a class name up front, e.g. SomeType(property == value) FROM $variableList -W it's a big costraint... i know... but i have to work this way. So should the previous rule work? Really thanks. Alessio -- View this message in context: http://drools.46999.n3.nabble.com/Write-Assumptions-for-NESTED-List-Object-tp4018241p4018256.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Write Assumptions for NESTED ListObject
oh... ok i'll try this and i let you know. Really thanks for your help. Regards. Alessio -- View this message in context: http://drools.46999.n3.nabble.com/Write-Assumptions-for-NESTED-List-Object-tp4018241p4018260.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Write Assumptions for NESTED ListObject
thanks for help... but it's not a nonsense... it has a great importance for me, as i have a lot of constraints to respect... the work consists of a collage of section of code for building a correct rule. So it's really different for me to use a form or a word instead of another. Thanks again. -- View this message in context: http://drools.46999.n3.nabble.com/Write-Assumptions-for-NESTED-List-Object-tp4018241p4018264.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Write Assumptions for NESTED ListObject
On 26/06/2012, aliosha79 alex_orl1...@yahoo.it wrote: thanks for help... but it's not a nonsense... it has a great importance for me, as i have a lot of constraints to respect... You'll have to obey the DRL syntax rules, and you are bound to follow the givens of your data model. In both respects, your posts exhibit errors and misfeasance - sorry, but that's the way it is. -W the work consists of a collage of section of code for building a correct rule. So it's really different for me to use a form or a word instead of another. Thanks again. -- View this message in context: http://drools.46999.n3.nabble.com/Write-Assumptions-for-NESTED-List-Object-tp4018241p4018264.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Write Assumptions for NESTED ListObject
ok don't worry... you was really helpful ... i know what to do ;) ... i'll let you know. Thanks again. -- View this message in context: http://drools.46999.n3.nabble.com/Write-Assumptions-for-NESTED-List-Object-tp4018241p4018267.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users