Can you put the week number on the reminder object and assert all the
reminders into working memory? That would give you a lot more options. For
example, if you were to do that, you could construct a rule like the
Week($number : weekNumber)
java.util.List(size > 5) from collect (Reminder(weekNumber ==
-- OR --
rule "Create summaries"
not (WeekSummary(weekNumber == $weekNumber)
rule "Summarize Reminders
Reminder($weekNumber : weekNumber)
$sum : WeekSummary(weekNumber == $weekNumber)
int numberReminders = $sum.getTotalReminders() + 1
then have a rule to enforce the Summaries aren't over the limit. More
facts/attributes you have in WM to reason over, the more possible solutions
On Mon, Apr 27, 2009 at 12:08 PM, Brody bach <brodybach(a)yahoo.com> wrote:
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:
$list : list(size > 5)
Reminder() from $list
no String(trim == "limit reached");
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
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
Now the problem is, if the rule fires for a certain week, than it won't
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
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
View this message in context:
Sent from the drools - user mailing list archive at Nabble.com
rules-users mailing list