<br> Bryan,<br><br> 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 "constraint object" that contain both boundary dates of your rule. Lets call it "Period".<br>
So, if you want to write your rule saying:<br><br>"Take a break if you worked more than 10 days in the given period."<br><br> Just do:<br><br>rule "take a break"<br>when<br> Period( $sd : startDate, $ed : endDate )<br>
Number( intValue > 10 ) from accumulate(<br> Day( date >= $sd && <= $ed, status == Day.WORKED ),<br> count( 1 ) )<br>then<br> // take a break<br>end<br><br> If your Day object is some kind of container object, use a chained from to iterate over them:<br>
<br>rule "take a break"<br>
when<br>
Period( $sd : startDate, $ed : endDate )<br> DailyReport( $days : days )<br>
Number( intValue > 10 ) from accumulate(<br>
Day( date >= $sd && <= $ed, status == Day.WORKED ) from $days,<br>
count( 1 ) )<br>
then<br>
// take a break<br>
end<br>
<br> Hope it helps.<br><br> Edson<br><br><div class="gmail_quote">2008/11/3 Bryan Hansen <span dir="ltr"><<a href="mailto:bryankhansen@gmail.com">bryankhansen@gmail.com</a>></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'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 "collect" 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> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>