[rules-dev] Better way to use And and Or

rules-dev at lists.jboss.org rules-dev at lists.jboss.org
Mon Jan 8 14:12:43 EST 2007


   Hi,

   In Drools 3.0, having the RCVRCOUNTRY and SNDRCOUNTRY as attributes 
of the same bean, there is no better way of doing than:

when

m:   ( (TransactionBean(RCVRCOUNTRY == "IRAQ", SNDRCOUNTRY == "US", AMOUNT >
"3000")) ||
 (TransactionBean(RCVRCOUNTRY == "IRAQ", SNDRCOUNTRY == "UK", AMOUNT >
"3000")) ||
 (TransactionBean(RCVRCOUNTRY == "IRAQ", SNDRCOUNTRY == "CAN", AMOUNT >
"3000")) ||
 (TransactionBean(RCVRCOUNTRY == "IRAN", SNDRCOUNTRY == "US", AMOUNT >
"3000")) ||
 (TransactionBean(RCVRCOUNTRY == "IRAN", SNDRCOUNTRY == "UK", AMOUNT >
"3000")) ||
 (TransactionBean(RCVRCOUNTRY == "IRAN", SNDRCOUNTRY == "CAN", AMOUNT >
"3000")) )

then

end

   In next version you can do:

when
  m: TransactionBean( RCVRCOUNTRY == "IRAQ" |== "IRAN", SNDRCOUNTRY == 
"US" |== "CAN" |== "UK" )
then
end

   []s
   Edson



rules-dev at lists.jboss.org wrote:

>Hi, 
>I am using Drools 3.0
>For below rule 
>
>RCVRCOUNTRY == IRAQ,IRAN 
>SNDRCOUNTRY == US,CAN,UK 
>AMOUNT > 3000 
>i have to compile the drl with this 
>
>m:   (TransactionBean(RCVRCOUNTRY == "IRAQ", SNDRCOUNTRY == "US", AMOUNT >
>"3000")) 
>m: (TransactionBean(RCVRCOUNTRY == "IRAQ", SNDRCOUNTRY == "UK", AMOUNT >
>"3000")) 
>m: (TransactionBean(RCVRCOUNTRY == "IRAQ", SNDRCOUNTRY == "CAN", AMOUNT >
>"3000")) 
>m: (TransactionBean(RCVRCOUNTRY == "IRAN", SNDRCOUNTRY == "US", AMOUNT >
>"3000")) 
>m: (TransactionBean(RCVRCOUNTRY == "IRAN", SNDRCOUNTRY == "UK", AMOUNT >
>"3000")) 
>m: (TransactionBean(RCVRCOUNTRY == "IRAN", SNDRCOUNTRY == "CAN", AMOUNT >
>"3000")) 
>
>Is there any other easier / better way to express this as a valid DRL? using
>|
>
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com





More information about the rules-dev mailing list