0

I'm new to JBOSS DROOLS , i need to imp below pseudo code on DROOLS rule. Let me know any smart way imp DROOLS rule.

if(Prod_of_Interest == "Signature Card" || Prod_nm == "001")
    seg= '5555'
else if(Prod_of_Interest == "SBI Platinum Card" || Prod_nm == "002")
    seg= '6666'
else if(Prod_of_Interest ==SBI Platinum Card == "SBI Gold & More Card" || Prod_nm == "003")
    seg= '7777'
else if(Prod_of_Interest ==SBI Platinum Card == "Yatra SBI Card" || Prod_nm == "004")
    seg= '8888'
else if(Prod_of_Interest ==SBI Platinum Card == "SpiceJet SBI Card" || Prod_nm == "005")
    seg= '9999'
else if(Prod_of_Interest ==SBI Platinum Card == "SBI Maruti Card" || Prod_nm == "006")
    seg= '1111'
else if(Prod_of_Interest ==SBI Platinum Card == "TATA Card" || Prod_nm == "007")
    seg= '2222'
else if(Prod_of_Interest ==SBI Platinum Card == "SBI Oriental Bank of Commerce Platinum Card" || Prod_nm == "008")
    seg= '3333'

DROOLS rule

 rule "Card1"
    when
        CARD( Prod_of_Interest == Signature Car || Prod_nm : 001 )
    then
        Response s= new Response()
       s.setSeg( "5555" );     
 end 
Shivababa
  • 339
  • 1
  • 3
  • 8
  • If the set of rules in that style is expected to grow (i.e. more cards and products), you may wish to look at decision tables or templates, to avoid writing separate rules yourself. However, the way you have written that rule is pretty much valid, although you would need to have an "insertLogical(s)" to put the response object into working memory for retrieval or use in other rules. I think you might need to provide a bit more information about what you're trying to do. – Steve Nov 27 '13 at 08:57
  • Prod_of_Interest ==SBI Platinum Card == "SBI Gold & More Card" there are and && or and || between then? – Narkha Nov 29 '13 at 11:11

1 Answers1

0

Caution: A cascaded if is not equivalent to a set of rules reflecting those conditions. Rules will match and fire independently unless countermeasures are being taken.

This is not really an answer - please follow Steve's advice and provide more information.

laune
  • 31,114
  • 3
  • 29
  • 42