Hi Brody,
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
following
when
Week($number : weekNumber)
java.util.List(size > 5) from collect (Reminder(weekNumber ==
$number))
then
insert(new LimitedReach($number));
-- OR --
rule "Create summaries"
no-loop true
when
Reminder($weekNumber :weekNumber)
not (WeekSummary(weekNumber == $weekNumber)
then
insert(new WeekSummary($weekNumber))
rule "Summarize Reminders
no-loop true
when
Reminder($weekNumber : weekNumber)
$sum : WeekSummary(weekNumber == $weekNumber)
then
int numberReminders = $sum.getTotalReminders() + 1
modify($sum) {
totalReminders= numberReminders
}
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
you have.
On Mon, Apr 27, 2009 at 12:08 PM, Brody bach <brodybach(a)yahoo.com> wrote:
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-tp23259683p23259...
Sent from the drools - user mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users