|
You want to see how I tackled the "Or" problem??
Just have a look at this single line taken out from my
dsl...
[when]- Orkeyvalue with key "{keya}" having value
"{valuea}" Ormaybe Orkeyvalue with key "{keyb}" having value "{valueb}" Ormaybe
Orkeyvalue with key "{keyc}" having value "{valuec}" Ormaybe Orkeyvalue with key
"{keyd}" having value "{valued}" Ormaybe Orkeyvalue with key "{keye}" having
value "{valuee}"=$kvp : keyValuePairMap ->
(((("{valuea}").equals($kvp.get("{keya}"))) || ((("{valuea}"=="0") ||
("{valuea}"=="OTH") || ("{valuea}"=="NA") || ("{valuea}"=="01/01/1900") ||
("{valuea}"=="N")) && ($kvp.get("{keya}")==null)))) ||
(((("{valueb}").equals($kvp.get("{keyb}"))) || ((("{valueb}"=="0") ||
("{valueb}"=="OTH") || ("{valueb}"=="NA") || ("{valueb}"=="01/01/1900") ||
("{valueb}"=="N")) && ($kvp.get("{keyb}")==null)))) ||
(((("{valuec}").equals($kvp.get("{keyc}"))) || ((("{valuec}"=="0") ||
("{valuec}"=="OTH") || ("{valuec}"=="NA") || ("{valuec}"=="01/01/1900") ||
("{valuec}"=="N")) && ($kvp.get("{keyc}")==null)))) ||
(((("{valued}").equals($kvp.get("{keyd}"))) || ((("{valued}"=="0") ||
("{valued}"=="OTH") || ("{valued}"=="NA") || ("{valued}"=="01/01/1900") ||
("{valued}"=="N")) && ($kvp.get("{keyd}")==null)))) ||
(((("{valuee}").equals($kvp.get("{keye}"))) || ((("{valuee}"=="0") ||
("{valuee}"=="OTH") || ("{valuee}"=="NA") || ("{valuee}"=="01/01/1900") ||
("{valuee}"=="N")) && ($kvp.get("{keye}")==null))))
this
is just a line to handle something like
some_constraint
and
name is "peter" or name is "john" or
name is "paul" or name is "tom" or name is "mat"
and
some_other_constraint
as I also should handle cases as
name
is "peter" or name is "john" or name is not "paul" or name is "tom" or name is
"mat" name
is "peter" or name is "john" or name is "paul" or name
is not "tom" or name is "mat"
.....
I ended up with 32+16+8+4+2 lines in the dsl to handle all possible
combinations of "ors" and "nots" with a maximum of 5 ors, any additional "n"
number of "ors" will need (n-1 number of lines)*2 additional lines in the
DSL
So,
basically, the rule engine can do whatever you're want as long as you're ready
to spend hours constructing a proper dsl file.
Tip:
When constructing a dsl for these combinations, put the combinations in
descending order, in our case:
5 ors
-> 4 ors ..... -> 1 or
This
has to be done as such because if you put
player1 or player2 (1)
and
then
player
1 or player2 or player3 (2)
in
your dsl, whenver you put
player1 or player2 or player3
in
your rule, it will give you an error "OR not expected" as the match was done
against line (1) i/of (2)
Brgrds,
Matias
From: gabriel quennesson [mailto:[EMAIL PROTECTED] Sent: 08 November 2006 13:42 To: [email protected] Subject: Re: [drools-user] Drools limitations for football managers? when Player1 (name matches "Roy|Bob") Player2(name matches "Tom|Eric") ... Player11(name matches "Paulo|Ryan") then doStuff(); endIn some trickier cases, you could use functions to perform other forms of matching. Or you could just write the rule the exact way you did with "and" and "or" keywords, which is documented in Drools (I wasn't able to successfully write such a rule, though). Regards, Gabriel John Cocktolstoy a écrit : Hi,
|
- [drools-user] Drools limitations for football managers? John Cocktolstoy
- Re: [drools-user] Drools limitations for football ... gabriel quennesson
- Re: [drools-user] Drools limitations for footb... John Cocktolstoy
- Re: [drools-user] Drools limitations for f... gabriel quennesson
- Re: [drools-user] Drools limitations f... John Cocktolstoy
- Re: [drools-user] Drools limitati... Edson Tirelli
- Re: [drools-user] Drools limi... gabriel quennesson
- Re: [drools-user] Drools ... Edson Tirelli
- Re: [drools-user] Drools ... gabriel quennesson
- Re: [drools-user] Drools ... Michael Neale
- RE: [drools-user] Drools limitations for football ... matias.zaya.mendez
