[rules-users] Convert logic to DRL rules
Bill Zhang
billzhang2006 at gmail.com
Sat Feb 17 09:39:07 EST 2007
Hello,
I am a new Drools user trying to convert the following simple logic into DRL:
IF (Person.Age > 35 OR Person.Age < 25) AND (Person.ZipCode = 23546 or
Person.ZipCode = 68590)
THEN
Person.Status = "KT";
I found that it is not easy to convert the above logic into ONE DRL rule.
I tried something like this
when
$a: Person(age>35) or Person (age<25)
$b: Person(Zipcode==23456) or Person (ZipCode == 68590)
$c: $a and $b
Then
$c.setStatus("KT")
But looks like I can not use
$c: $a and $b
becaue in Drools, you can only bind variable to column, not to other varaibles.
Please advise how to do this. I would imagine this should be quite
simple, maybe I missed something quite obvious.
I know that I can write custom Java method to do this, but if I do
that, I suppose I lose the power of RETEOO pattern matching (pattern resuing,
etc.). So I prefer not to do that.
I also understand I can break the above logic into 4 rules and that
would be quite easy, but our business user is not used to think in
that way. Also, we have more complex logic than the above. So what I
want is to see if there is a way to convert this
kind of logic in ONE DRL rule.
Thanks in advance.
Bill
More information about the rules-users
mailing list