[rules-users] Stateful session and non-existence of Facts

Leonardo Gomes leonardo.f.gomes at gmail.com
Mon Nov 30 14:03:45 EST 2009


Hi Wolfgang,

Thanks for the reply.

Leo.

On Fri, Nov 27, 2009 at 7:38 AM, Wolfgang Laun <wolfgang.laun at gmail.com>wrote:

> 2009/11/26 Leonardo Gomes <leonardo.f.gomes at gmail.com>
>
>>
>>
>> On Tue, Nov 24, 2009 at 10:42 PM, Leonardo Gomes <
>> leonardo.f.gomes at gmail.com> wrote:
>>
>>> H
>>>
>>> Now, let's say FactA(1) indicates a fact of type FactA and id = 1.
>>>
>>> - Then, in the beginning, I insert FactA(1) and FactA(2) in my working
>>> memory and fire the rules.
>>>
>>> rule "test non existence"
>>> when
>>>     not FactA( id == 4 )
>>> then
>>>     output.add("there's no FactA id 4");
>>>
>>> - This rule is fired and the message is added to my output object.
>>>
>>> Later on, I have a notification that a FactA has changed, then I:
>>> - retract all FactAs from my working memory
>>> - clear all FactA-related messages from my output object
>>> - reload FactAs (let's say now I have FactA(1), FactA(3), but NOT
>>> FactA(4))
>>> - reinsert them in the WM
>>> - fire the rules
>>>
>>> The rule that checks that there's no FactA(4) doesn't refire.
>>>
>>
> Why should it? The truth of the non-existance of FactA(4) has been
> established, and this truth never changed, certainly not by removing any
> FactA(n) and also not by inserting any FactA(x) with x!= 4.
>
> As a solution, you could
> - establish an explicit fact, asserted in rule "test non existence" and
> retracted by a rule checking the negated condition;
> - add a Trigger fact to rule "test non existence" which you modify after
> each reload of the FactA set
> - do something else which I'm not clever enough to think about at the
> moment
>
> -W
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20091130/8f62d7a0/attachment.html 


More information about the rules-users mailing list