I think what you are looking for is the following.  Someone please correct me if I am incorrect.

 

when

Order($discount : discount > 10, $items: items)

Item(grade > 3) from $items

then

System.err.print(“Discount is not allowed with items having grade 3 or higher”);

 

 

This would fire when an Order has a discount greater than 10 and an  item with a grade greater than 3.

Not sure why you even need the $discount variable.  You could just do Order(discount > 10, $items : items) for the first line of the when clause.

 

 

From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Shabbir Dhari
Sent: Tuesday, February 23, 2010 5:27 PM
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Using Collections in LHS

 

Hi W

I know about case sensitivity issue. How can I combine both Order and Item in one condition. I tried all possibilities but getting syntax error.

For example:

Order ($items : items, $discount : discount > 10, Item(grade > 3) from $items) // gives error

 

Can please code this condition correctly for me?

 

Dhari

 


Date: Tue, 23 Feb 2010 13:43:01 +0100
From: wolfgang.laun@gmail.com
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Using Collections in LHS

Discount is a field of Order and must not appear in an Item(...).
Probably you want:
   Order  ( $discount : Discount > 10,...

Also, most likely, all your fields need to be written with a lower case initial letter,
   Order  ( $discount : discount > 10, $items : items)

-W

On Tue, Feb 23, 2010 at 1:11 PM, dhari <sdhari@hotmail.com> wrote:


In this scenario I do have typical Order and Items data structure. I want to
implement various business rules where I want to check both Order attributes
and Item attributes together.

Order [ Date, Discount, Amount, Customer, Type, Items]
Item [ Quantity, Rate, ExpiresDate, Grade ]

I am trying to implements following rules but all gives me syntax error. I
wondering if someone can help me in.


rule one
   when
       Order  ( $discount : Discount, $items : Items)
       Item ($discount > 10 && Grade > 3) from $items
   then
       System.err.print(Discount is not allowed with items having grade 3 or
higher)
end

rule two
   when
       Order  ( $discount : Discount, $items : Items)
       Item ($discount  > 20 || Quantity < 5 ) from $items
   then
       //do some thinge
end
--
View this message in context: http://n3.nabble.com/Using-Collections-in-LHS-tp386923p386923.html
Sent from the Drools - User mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

 


Find out now Link all your email accounts and social updates with Hotmail.