[rules-users] Insert new facts in WorkingMemory event handler
Bruno Freudensprung
bruno.freudensprung at temis.com
Mon Dec 6 05:37:53 EST 2010
Hi Michael,
Thanks for you answer! Following you suggestion I've taken a look at at
"logical insertions" and on one hand I have to say that it looks like
what I need, but on the other hand it is not clear to me how to
"implement it".
If you have some time to take a look, here are the objects in my session:
- one T object (something that can be considered as a "type" object)
- many I objects (something that can be considered as "instance"
objects), I objects have one "type" field beeing a T (there is no link
from T to Is)
Those facts are inserted into the session and I have the impression that
we are not speaking here of logical insertions: they have to be here, it
is the input data the user has to write rules on.
The user can decide to retract the T object: in this case all I objects
have to be retracted as well.
The user can decide to retract some I objects: when all of them have
been retracted, the T object should be retracted as well.
The first "solution" I imagined was to have high-salience rules:
rule "1"
when
t : T
not I(type == t)
then
retract t
rule "2"
when
i : I(t : type)
not Type (this == t)
then
retract i
The other solution I imagined (that I have not tried) was to retract
facts using a WorkingMemoryEventHandler.
However as I am a Drools' absolute beginner (not only to Drools, but to
the rule paradigm itself), I was wondering what is the "most natural
way" for you guys to implement that behavior :-).
Bruno.
Michael Anstis a écrit :
> Would the other retractions be automatically provided for by Drools'
> Truth Maintenance?
>
> Otherwise, passing a StatefulKnowledgeSession to a
> WorkingMemoryEventHandler subclass and invoking it's methods should,
> IMO, not be an issue.
>
> Have you tried it and experienced issues?
>
> On 6 December 2010 09:32, Bruno Freudensprung
> <bruno.freudensprung at temis.com <mailto:bruno.freudensprung at temis.com>>
> wrote:
>
> Hi everyone,
>
> Do you know if it is possible to insert/modify/retract facts in a
> working memory event handler?
>
> Here is my use case actually: I want my users to be able to write
> rules
> like "When ... Then retract X" without having to bother with the
> consequences of retracting X on the other objects of the sessions
> (some
> of them might be retracted as well). These consequences can be
> expressed
> by rules, but I would like them to be kind of "part of the framework"
> and it would be easier for users if those rules were implicitly
> defined.
>
> Many thanks in advance for any hint,
> Best regards,
>
> Bruno.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101206/2800cfbd/attachment.html
More information about the rules-users
mailing list