On 08/01/2013, devan.vanreenen(a)gmail.com <devan.vanreenen(a)gmail.com> wrote:
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,
Do you need just a single HighPriority() irrespective of the number of
cases where there is 4/5/6 but no 7/8? Or do you need one for each
caseNumber?
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 )
This logic is wrong. It detects (repeatedly) a CaseList where there is
4, 5, or 6 which does not contain an Alert with *any* caseNumber with
an alertNo of 7 or 8.
The following rule creates a *single* HighPriority fact, no matter how
many matching cases there are.
rule find456no78
when
not HighPriority()
Alert( $c: caseNumber, alertNo == 4 || == 5 || == 6 )
not Alert( caseNumber == $c, alertNo == 7 || == 8 )
then
insert( new HighPriority( true ) );
System.out.println( "high prio for " + $c );
end
If you need one HighPriority for each case, store the caseNumber in
the HighPriority fact and constrain accordingly.
-W
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.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users