[rules-users] How to accumulate from objects in a collection?

Felipe Piccolini felipe.piccolini at bluesoft.cl
Thu Aug 2 18:28:17 EDT 2007


Hi,

    this is just a dumb question for drools-languaje gurus... like  
Edson :)

How ca I write a rule (CE in LHS) for accumulate atributes inside an  
object, but this objects are not facts,
they are inside a collection which is an attribute from a fact...  
pretty messy right?...lol..

well, the business problem is this.

I need to count (accumulate) vacation days used on previous vacation  
requests.
I have an User (which is one fact) having a collection of  
oldVacationRequests
and an actual VacationRequest (the another fact).
So the rules is like this: discount to the available days for  
vacation those used in previous
vacation request, and those days are the days between initDate and  
endDate in each
old vacation request with isAproved seted true and having endDate  
before the actual
vacation request initDate.

did I explain myself?...



so I need to know if this is possible I was trying to do something  
like this...but is obviously wrong...:)
rule "remove used vacation days"
	no-loop
	when
		vr: VacationRequestVO($days: availableDays , $iniDate: initDate )
		$u: UserVO( $vacReqList: vacationRequestList )
		$usedDays: Number (intValue > 1) from accumulate ( $ovr:  
VacationRequestVO( isAproved == true, endDate < $iniDate, $uDays:  
usedDays),
														from $vacReqList, count($uDays))
	then
		vr.setAvailableDays($days - $usedDays);
end

Thanks...

Felipe Piccolini M.
felipe.piccolini at bluesoft.cl




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070802/9e1a77a1/attachment.html 


More information about the rules-users mailing list