[rules-dev] Rule syntax to accumulate time segments over a limited set of date ranges

Bill Hainaut billhainaut at gmail.com
Fri May 7 12:13:39 EDT 2010


This seems to do the trick.  I hate the ugly date math, but otherwise, I'm
satisfied:

	$s : SeatAssignment ( )
	$mission : CrewSegment( taskBeingTested == true )
        $total : Number( doubleValue > 56 ) 
               from accumulate( CrewSegment( personId == $s.personId,
endDate.time <= $mission.endDate.time, startDate.time >
($mission.endDate.time - (7L * 24L * 60L * 60L * 1000L)), $crewHours :
crewHours ),
                                sum( $crewHours ) )



Bill Hainaut wrote:
> 
> Drools Experts:
> 
> I have a list of the following fact objects sent to my rules:
> 
> CrewSegment
> Date startDate
> Date endDate
> double crewHours
> int personId
> 
> along with an object to designate seats:
> 
> SeatAssignment
> int seatId
> int personId
> 
> Here is the rule I want to enforce in English: No crew member (uniquely  
> identified by personId) can have more than 56 hours of total crewHours in  
> any 7 day period. The rule I've written so far is:
> 
> when
> $s : SeatAssignment ( )
> $total : Number( doubleValue > 56 )
> from accumulate( CrewSegment( personId == $s.personId, $crewHours :  
> crewHours ),
> sum( $crewHours ) )
> 
> This rule nicely catches any instance where more than 56 hours are  
> committed by a person, but does not limit the time period to 7 days.
> 
> How do I limit the search to be sure that it is 56 hours WITHIN 7 days,
> and  
> not just 56 hours total over ANY time period?
> 
> Thanks in advance for any help you can provide!!!
> 
> Bill
> 
> _______________________________________________
> rules-dev mailing list
> rules-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
> 
> 

-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rule-syntax-to-accumulate-time-segments-over-a-limited-set-of-date-ranges-tp782165p784099.html
Sent from the Drools - Dev mailing list archive at Nabble.com.


More information about the rules-dev mailing list