You need to remember that a rule runs every time the patterns are matched.
For example:-
rule "example"
when
$a : ObjectA()
$b : ObjectB()
then
System.out.println("Rule 'example' ran");
end
Working Memory:-
1 - ObjectA
2 - ObjectA
3 - ObjectB
4 - ObjectB
The rule will run four times; once for each combination of ObjectA and ObjectB (1, 3) (1,
4) (2, 3) and (2, 4).
Object models are flattened in Working Memory so if you need to impose a relationship you
need to add this to the rule. For example:-
[one-to-one mapping] ObjectA has one child ObjectB.
Method suggestion (returns an instance of ObjectB): ObjectA.getObjectB();
rule "example"
when
$b : ObjectB()
$a : ObjectA(objectB == $b)
then
System.out.println("Rule 'example' ran");
end
[one-to-many mapping] ObjectA has many child ObjectB.
Method suggestion (returns a List): ObjectA.getObjectBs();
rule "example"
when
$b : ObjectB()
$a : ObjectA(objectBs contains $b)
then
System.out.println("Rule 'example' ran");
end
Check that this is not the cause of your multiple unexpected executions.
With kind regards,
Mike
________________________________
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of fakhfakh ismail
Sent: 13 April 2007 18:22
To: jboss rules
Subject: [rules-users] many response
Hello,
First sorry for my bad english
when I execute a regle I get many response I don't know why?
Example:
rule "userrole"
when
user1: BnUserValue(nameuser : name)
and
Role : BnRoleValue()
and
ActiviteOut : BnNodeValue(bnRole == Role,executor == nameuser )
and
ActiviteIn : BnNodeValue(bnRole == Role )
and
lien: BnEdgeValue(outBnNode == ActiviteOut,inBnNode ==ActiviteIn )
then
System.out.println("cette personne "+user1.getName()+ " ne peut pas
executer cette activiter");
end
the execution result
cette personne ismail ne peut pas executer cette activiter
cette personne ismail ne peut pas executer cette activiter
cette personne ismail ne peut pas executer cette activiter
cette personne ismail ne peut pas executer cette activiter
cette personne ismail ne peut pas executer cette activiter
cette personne ismail ne peut pas executer cette activiter
so the result is repeat 6 I don't know why?
thank for your help
Ismail
________________________________
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez
des connaissances, des opinions et des expériences des internautes sur Yahoo!
Questions/Réponses <
http://fr.rd.yahoo.com/evt=42054/*http://fr.answers.yahoo.com>
.