Hi Brody,<br><br>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<br>

<br>when<br>       Week($number : weekNumber)<br>       java.util.List(size &gt; 5)  from collect (Reminder(weekNumber == $number))<br>then<br>       insert(new LimitedReach($number));<br><br>-- OR --<br>       <br>rule &quot;Create summaries&quot;<br>

        no-loop true<br>when <br>        Reminder($weekNumber :weekNumber)<br>        not (WeekSummary(weekNumber == $weekNumber)<br>then<br>        insert(new WeekSummary($weekNumber))<br><br>rule &quot;Summarize Reminders<br>

     no-loop true<br>when<br>        Reminder($weekNumber : weekNumber)<br>        $sum : WeekSummary(weekNumber == $weekNumber)<br>then<br>        int numberReminders = $sum.getTotalReminders() + 1<br><br>        modify($sum) {<br>

             totalReminders= numberReminders <br>        }<br><br>then have a rule to enforce the Summaries aren&#39;t over the limit. More facts/attributes you have in WM to reason over, the more possible solutions you have.<br>
<br><div class="gmail_quote">On Mon, Apr 27, 2009 at 12:08 PM, Brody bach <span dir="ltr">&lt;<a href="mailto:brodybach@yahoo.com" target="_blank">brodybach@yahoo.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Hi all,<br>
<br>
I&#39;m having difficulty in defining a rule for the following problem:<br>
We need to check if within a week there are more than 5 objects of type<br>
Reminder inserted into Memory.<br>
(one day corresponds to one object)<br>
The number of the inserted objects depends on the usage of the application.<br>
That means there could be nothing, 1, 2, or any number of the objects.<br>
Before, within a session, I inserted a list containg data from within one<br>
week (7 days).<br>
Than I can check using the rule:<br>
when:<br>
$list : list(size &gt; 5)<br>
Reminder() from $list<br>
no String(trim == &quot;limit reached&quot;);<br>
then<br>
System.out.println(&quot;This rule fires&quot;);<br>
insert new String(&quot;limit reached&quot;);<br>
<br>
Now I need to insert a list containing data from a whole month, but I still<br>
need to check whether within one week there are more than 5 reminders exist.<br>
<br>
so, the constraint list&gt; 5 can&#39;t be used anymore for a single list. I tried<br>
to break the whole list in several smaller list, where each list represents<br>
one week.<br>
Now the problem is, if the rule fires for a certain week, than it won&#39;t work<br>
for the following weeks anymore.<br>
<br>
My idea is then to insert an integer containing specific number to the<br>
current list, i.e. the calendar week (i.e insert new Integer(52)) and then<br>
to prove this in LHS; but the problem is now how to prove the week number in<br>
LHS? as I remeber, a function can only be called within an eval statement<br>
and  in this case actually I should only prove the existence of an Integer<br>
<br>
Hope my explanation is quite understandable and looking forward for any<br>
hints<br>
<br>
Regards<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://www.nabble.com/need-some-advice-in-defining-rules-tp23259683p23259683.html" target="_blank">http://www.nabble.com/need-some-advice-in-defining-rules-tp23259683p23259683.html</a><br>


Sent from the drools - user mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>