Hi,

I am using Drools 5.5.0 Final Expert to do Alarm Co-relation. I was trying
to collect the facts in to the ArrayList collection. My drl file will look
like below. From the Rule I calling an Java method to access the collected
facts.

/rule "Rule [Alarm Collection]"
no-loop
   when
        $alarmColl : ArrayList() from collect(Alarm 
                 ( 
                        JustInserted == true;
                 ))
                 
        then
        // act on $alarmColl
end/

while in my Java code I am loop through the collection to set an attribute
of the Alarm Object. But while I am trying to set this attribute in the
collection, the collection is getting updated and indexes are changed. Due
to which all the objects are not updated. Even I tried using the iterator to
access the ArrayList collection. Still the same issue.

/
while(index < alarmColl.size()){
                        Alarm alarmObj=alarmColl.get(index)
        
                        if(alarmObj.isJustInserted()) {
                                alarmObj.setJustInserted(false);
                                theScenario.getSession().update(alarmObj);
                        }
                        index++;
}/
                        
                        
How can I update the objects in collection without changing the index or any
other way to achieve this.




--
View this message in context: 
http://drools.46999.n3.nabble.com/Problem-with-Collection-tp4029219.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to