The initially posted rules "1" and "2" are best practice. You are using a
Production Rule Engine, and these rules are what they are made for.
Doing it in an event handler is not impossible, but it requires you to
implement logic which is (apparently) part of the application domain
("There must not be a T without at least one I." and "There must not be an I
without its T.") and, moreover, logic which is readily available by the Engine's
workings.
Don't reinvent the wheel, just start rolling along.
-W
I think I've got your use case: you are making XSLT on steroi^W some
kind of cheese that tastes stimulating and is dense in nutrients but
is in no way controversial.
It would allow user rules for removing stuff, and have built-in rules
for transitively removing unreferenced stuff, right?
Ahh, silly me, rule processing is externally initiated in Drools, it's
On Mon, Dec 6, 2010 at 12:19 PM, Bruno Freudensprung
<bruno.freudensprung@temis.com> wrote:
> I simply plan to read my XML and add the corresponding objects into
> the session, then to fire the rules.
not some kind of perpetual event engine.
Would a query work instead of the event listener then?
> Well... I wanted to delegate the whole "logic" to Drools and I imagined
> that I could "listen" to Drools' WorkingMemory's retraction events in
> order to remove the corresponding elements from the input XML.
I guess it would if the list of remaining stuff is good too...
Or you could mark the unneeded stuff instead of retracting, reason
over the marks, and be able to query the marked stuff directly:
rule "orphaned Type"
when
t : T(mark != true)
not I(type == t, mark == true)
then
modify (t) {setMark(true)}
end
rule "orphaned Instance"
when
t : T(mark == true)
I(type == t, mark != true)
then
modify(i) {setMark(true)}
end
// transform your rules "1" and "2" as well to sanitize input!
query "types to delete"
t : T(mark == true)
end
query "instances to delete"
i : I(mark == true)
end
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users