[rules-users] Using accumulate function
sanal
sanal.p at icthealth.com
Mon Apr 9 02:28:59 EDT 2012
Hi,
Iam trying to use the accumulate function of the drools.I need to
accumulate based on the result of a rule execution.
Eg: Suppose i have list of orders and another list of conditions
for a particular package.I need to check weather each of the order is part
of package or not.
Suppose a qty limit is set to 1 for a item in package definition and
the item is ordered 2 times.
While checking the condition, both of the item will go under package.
Actually for second record the rule should get executed based on result of
the 1 record's rule execution and so on.
So I require a looping rule execution.
How can i achive this using Drools.
Rule "Package Rate_21"
salience 65515
when
$objOrderedComponents:AccumulatedComponent()
$packageDefinition:PackageDefinition($packageId:packageId)
$accumulatedQty:Number()
from accumulate(
$accQtyComponent:OrderedComponent(packageChargeRecordId==$packageId, $AccQty
: componentQty) from
$objOrderedComponents.getOrderedComponentList(),sum($AccQty ) )
$orderedComponent:OrderedComponent($id1:componentKey,$qty:componentQty)
from $objOrderedComponents.getOrderedComponentList() and
$pkgComps:PackageComponent(componentKey==$id1,(quantityLmt
>=($qty+$accumulatedQty.intValue()))) from
$packageDefinition.getPackageComponentList()
then
$orderedComponent.setIsComponentApplicable(true);
$orderedComponent.setPackageChargeRecordId($packageId);
end
Regards
Sanal.P
--
View this message in context: http://drools.46999.n3.nabble.com/Using-accumulate-function-tp3896078p3896078.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
More information about the rules-users
mailing list