Here is an example:
$av: List() from accumulate ( $a: Alarm( ...select "interesting" alarms... ),
init( List<Alarm> alarms = new ArrayList<Alarm>(); )
action( alarms.add($a); )
reverse( alarms.remove($a); )
result(alarms) )
To select "interesting" alarms, separate the constraints for fields
"activation" and
"geofenceCustomer" with a comma (which acts like a logical "and").
-W
2011/9/28 Hari Kishan <HariKishan.Tammana(a)pass-consulting.com>:
@wolfgang Yesterday you told me to use accumulate instead of collect.
But i
could not find the right way to use accumulate here. Please see below my
rules when condition [ collect function(Bold & Italic) ] and please tell me
how can i use accumulate there. If possible change the conditional element
to accumulate with appropriate changes. when // "Sensor Data Idem Stream" is
where Mule sends the Sensordata facts // for each Alarm / Sensordata
combination that is identified via the vehicle id $sd : SensorDataIdem ($vid
: vehicleId) from entry-point "Sensor Data Idem Stream" // Set a references
for later on the initial facts $av : AlarmVehicle(vehicleId == $vid) //The
Condition to be added to get the active Alarms from the List of Alarms
eval($av!=null && $av.getAlarms()!=null && $av.getAlarms().size()>0)
$alarms
: ArrayList(size>0) from collect ( Alarm( ( (activation ==
AlarmConstants.ALWAYS_ACTIVE) || (activation ==
AlarmConstants.ACTIVE_ONLY_ONTOUR && $sd.onTour == true) || (activation ==
AlarmConstants.ACTIVE_ONLY_NOT_ONTOUR && $sd.onTour == false) || (activation
== AlarmConstants.ACTIVE_ONLY_ONMOVING && $sd.onMove == true) || (activation
== AlarmConstants.ACTIVE_ON_TIME_WINDOW ) ) && ( ( (geofenceCustomer == 0)
|| (geofenceCustomer == 1 && $sd.inCustomerGeoFence == true) ||
(geofenceCustomer == 2 && $sd.inCustomerGeoFence == false) ) && (
(geofenceDepot == 0) || (geofenceDepot == 1 && $sd.inDepotGeoFence == true)
|| (geofenceDepot == 2 && $sd.inDepotGeoFence == false) ) ) ) from
$av.getAlarms() ) eval($alarms!=null) then ...........
________________________________
View this message in context: Re: [rules-users] Getting Exception while
running rules continuously on the Event Streams from Mule Component.
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users