Hi there,
Please assist
I have an several alert objects in working memory which have been logically
collected per case number using the following rule,
rule 'Group alerts for a specific case'
dialect 'java'
when
Alert( $caseNumber : caseNumber, $alertNo: alertNo )
not Alert( caseNumber == $caseNumber, alertNo < $alertNo )
$list : List( ) from collect($alert : Alert( caseNumber ==
$caseNumber))
then
System.out.println("******Printing list******: ");
System.out.println("******List hashCode: " + $list.hashCode());
for(Object o : $list){
System.out.println(o);
}
I then declare a fact CaseList with a property with name value and type
List, each time a new List is collected, I create a new CaseList and set
this list on this intance and logically insert this intance
CaseList caseList = new CaseList();
caseList.setValue($list);
insertLogical(caseList);
end
Sample output
******Printing list******:
******List hashCode: 342532614
Alert [caseNumber=1022621, alertNo=6]
Alert [caseNumber=1022621, alertNo=6]
Alert [caseNumber=1022621, alertNo=6]
Alert [caseNumber=1022621, alertNo=2]
Alert [caseNumber=1022621, alertNo=1]
Alert [caseNumber=1022621, alertNo=2]
Alert [caseNumber=1022621, alertNo=2]
Alert [caseNumber=1022621, alertNo=8]
******Printing list******:
******List hashCode: 890817600
Alert [caseNumber=1021567, alertNo=1]
Alert [caseNumber=1021567, alertNo=2]
Alert [caseNumber=1021567, alertNo=8]
******Printing list******:
******List hashCode: -1376001294
Alert [caseNumber=1012283, alertNo=1]
Alert [caseNumber=1012283, alertNo=2]
Alert [caseNumber=1012283, alertNo=6]
Alert [caseNumber=1012283, alertNo=2]
Alert [caseNumber=1012283, alertNo=8]
Alert [caseNumber=1012283, alertNo=2]
******Printing list******:
******List hashCode: -1069600305
Alert [caseNumber=55506677, alertNo=1]
Alert [caseNumber=55506677, alertNo=2]
Alert [caseNumber=55506677, alertNo=6]
I then have a different rule that checks for any CaseList objects in working
memory and needs to interrogate each instance and collected list to see
whether the list contains an alert with alertNo == 4 or 5 or 6 and does not
contain an alert with alertNo == 7 or == 8 and then creates a new inferred
fact HighPriority if this is the case which other rules act on.
I use the following rule to be able to do this logic and expect a single
HighPriority intance in working memory but there are several, am I doing it
wrong,
rule 'Determine if High priority'
dialect 'java'
when
$a1 : Alert( alertNo == 4 || == 5 || == 6 )
$a2 : Alert( alertNo == 7 || == 8 )
$m : CaseList( value contains $a1 && not contains $a2 )
then
HighPriority hp = new HighPriority();
hp.setValue(true);
insertLogical(hp);
end
--
View this message in context:
http://drools.46999.n3.nabble.com/Checking-whether-an-element-exists-as-w...
Sent from the Drools: User forum mailing list archive at
Nabble.com.