<br>&nbsp;&nbsp; Bryan,<br><br>&nbsp;&nbsp; The main decision here is how to do Date arithmetic, since java does not provide easy to use APIs for that. So, the simplest way IMO, from a rule authoring perspective, is to have a &quot;constraint object&quot; that contain both boundary dates of your rule. Lets call it &quot;Period&quot;.<br>
&nbsp;&nbsp; So, if you want to write your rule saying:<br><br>&quot;Take a break if you worked more than 10 days in the given period.&quot;<br><br>&nbsp;&nbsp;&nbsp; Just do:<br><br>rule &quot;take a break&quot;<br>when<br>&nbsp;&nbsp;&nbsp; Period( $sd : startDate, $ed : endDate )<br>
&nbsp;&nbsp;&nbsp; Number( intValue &gt; 10 ) from accumulate(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Day( date &gt;= $sd &amp;&amp; &lt;= $ed, status == Day.WORKED ),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; count( 1 ) )<br>then<br>&nbsp;&nbsp;&nbsp; // take a break<br>end<br><br>&nbsp;&nbsp;&nbsp; If your Day object is some kind of container object, use a chained from to iterate over them:<br>
<br>rule &quot;take a break&quot;<br>
when<br>
&nbsp;&nbsp;&nbsp; Period( $sd : startDate, $ed : endDate )<br>&nbsp;&nbsp;&nbsp; DailyReport( $days : days )<br>
&nbsp;&nbsp;&nbsp; Number( intValue &gt; 10 ) from accumulate(<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Day( date &gt;= $sd &amp;&amp; &lt;= $ed, status == Day.WORKED ) from $days,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; count( 1 ) )<br>
then<br>
&nbsp;&nbsp;&nbsp; // take a break<br>
end<br>
<br>&nbsp;&nbsp; Hope it helps.<br><br>&nbsp;&nbsp;&nbsp;&nbsp; Edson<br><br><div class="gmail_quote">2008/11/3 Bryan Hansen <span dir="ltr">&lt;<a href="mailto:bryankhansen@gmail.com">bryankhansen@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Not really sure how to go about writing this in a rule or whether or not the logic belongs in a rule (I think it does, but if you don&#39;t please comment as to why).<br><br>I have a list of objects that contain date objects. If the list contains 10 objects that date are before mine then I want them to take a break.<br>

<br>The business case is similar to that of an HR system. If they have worked too many days out of the last 12 then they need to take a break. <br><br>I am guessing it would have to use the &quot;collect&quot; attribute, but how would you do the date logic in a LHS clause?<br>

<br>Thanks for any guidance on this.<br>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">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>
<br></blockquote></div><br><br clear="all"><br>-- <br> &nbsp;Edson Tirelli<br> &nbsp;JBoss Drools Core Development<br> &nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>