Drools Rules: How can I use a method on "when" section?
Posted
by manoelhc
on Stack Overflow
See other posts from Stack Overflow
or by manoelhc
Published on 2010-03-23T20:22:31Z
Indexed on
2010/03/25
3:13 UTC
Read the original article
Hit count: 396
Hi, I need to execute a method on "when" section of a DSLR file and I´m not sure if it´s possible. Example:
rule "WNPRules_10"
when
$reminder:Reminder(source == "HMI")
$user:User(isInAgeRange("30-100")==true)
Reminder(clickPercentual >= 10)
User(haveAtLeastOptIns("1,2,3,4") == true)
then
$reminder.setPriority(1);update($reminder);
end
(note: isInAgeRange() and haveAtLeastOptIns() are methods of User)
I tried with eval() and no errors appeared, but it didn´t execute. Like this:
rule "WNPRules_10"
when
$reminder:Reminder(source == "HMI")
$user:User(eval($user.isInAgeRange("30-100")==true))
Reminder(clickPercentual >= 10)
User(eval($user.haveAtLeastOptIns("1,2,3,4") == true))
then
$reminder.setPriority(1);update($reminder);
end
How can I resolve this problem?
© Stack Overflow or respective owner