Thanks Jeffery.  I'll try this but what if I have more complex condition e.g.


Order ($discount : discount, $items : items)
Item(grade > 3 && (quantity < 5 || $discount > 10)) from $items



Date: Tue, 23 Feb 2010 15:14:18 -0800
From: [hidden email]
To: [hidden email]
Subject: Re: Using Collections in LHS

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: [hidden email] [mailto:[hidden email]] On Behalf Of Shabbir Dhari
Sent: Tuesday, February 23, 2010 5:27 PM
To: [hidden email]
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: [hidden email]
To: [hidden email]
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 <[hidden email]> 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
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users

 


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


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users



View message @ http://n3.nabble.com/Using-Collections-in-LHS-tp386923p412055.html
To unsubscribe from Drools - Java Rules Engine, click here.



Get straight to the Point Find a great deal on your next car.

View this message in context: RE: Using Collections in LHS
Sent from the Drools - User mailing list archive at Nabble.com.