Hi Antonio,<br />Documentation states that the complement to "not" is "exists",
whereas "not" keyword is used to match the absence of a fact (in Working
Memory), and "exists" keyword is used to test the existence of one or
more facts (in Working memory).<br /> <br />
So if you want to test that a fact is not in working memory, then you
should use the <br />
not(MyClass()) pattern.<br /> <br />
Hope this helps,<br />
Francois.<br /> <br />
Antonio Neto <antoniosouzaneto@gmail.com> a écrit :<br /> <br />
> Any idea? Please...<br />
><br />
> 2010/5/4 Antonio Neto <antoniosouzaneto@gmail.com><br />
><br />
>> Hi all,<br />
>><br />
>> I don't know exactly why I have a problem in my "exists" function. I've<br />
>> tried many different ways, but it does not work. Anybody could help me,<br />
>> please?<br />
>><br />
>><br />
>> I have the following rules:<br />
>><br />
>> *rule "diff"<br />
>> when<br />
>> $var1: EReference(name == "employee")<br />
>> $var2: EClass(name == "Company", EAllReferences contains $var1)<br />
>> not (exists( EPackage(EClassifiers contains $var2 ) ))<br />
>> then<br />
>> insertLogical(new IntConstraintOccurrence("diff", 10));<br />
>> end<br />
>><br />
>> rule "ClassesNotReferenced"<br />
>> when<br />
>> $q1 : EClass();<br />
>> $q2 : EPackage(EClassifiers contains $q1);<br />
>> not( exists ( EReference(EType == $q1) ));<br />
>> then<br />
>> insertLogical(new IntConstraintOccurrence("ClassesNotReferenced",<br />
>> 1, $q1));<br />
>> end*<br />
>><br />
>><br />
>> and in my facts (and my EPackage) I have 4 instances of EClass "Company"<br />
>> with a EReference "employee", and another EClass "Person". I still have a<br />
>> "move" that removes EClasses in my Drools Solver.<br />
>><br />
>> I need to have only one classe "Company" after processing. But it removes<br />
>> only the EClass "Person", when it was supposed to remove one EClass "Person"<br />
>> and 3 ECLasses "Company". Leaving one EClass "Company" in the end.<br />
>><br />
>> The problem is: when Drools tries to remove a EClass "Person" it thinks<br />
>> that the EClass "Company" does not exists. But in fact there are 3 others.<br />
>><br />
>> Any clue about it, please ?<br />
>><br />
>> Thanks<br />
>><br />
>> Bests regards<br />
>><br />
>> Antonio<br />
>><br />
>><br />
>><br />
><br />