[rules-users] need some advice in defining rules

Brody bach brodybach at yahoo.com
Mon Apr 27 12:08:50 EDT 2009


Hi all,

I'm having difficulty in defining a rule for the following problem:
We need to check if within a week there are more than 5 objects of type
Reminder inserted into Memory.
(one day corresponds to one object)
The number of the inserted objects depends on the usage of the application.
That means there could be nothing, 1, 2, or any number of the objects.
Before, within a session, I inserted a list containg data from within one
week (7 days). 
Than I can check using the rule:
when:
$list : list(size > 5)
Reminder() from $list
no String(trim == "limit reached");
then
System.out.println("This rule fires");
insert new String("limit reached");

Now I need to insert a list containing data from a whole month, but I still
need to check whether within one week there are more than 5 reminders exist.

so, the constraint list> 5 can't be used anymore for a single list. I tried
to break the whole list in several smaller list, where each list represents
one week.
Now the problem is, if the rule fires for a certain week, than it won't work
for the following weeks anymore.

My idea is then to insert an integer containing specific number to the
current list, i.e. the calendar week (i.e insert new Integer(52)) and then
to prove this in LHS; but the problem is now how to prove the week number in
LHS? as I remeber, a function can only be called within an eval statement
and  in this case actually I should only prove the existence of an Integer

Hope my explanation is quite understandable and looking forward for any
hints

Regards

-- 
View this message in context: http://www.nabble.com/need-some-advice-in-defining-rules-tp23259683p23259683.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list