[rules-users] Roll Back Rule / Rule Transactions?
Mark Proctor
mproctor at codehaus.org
Tue Feb 13 13:49:05 EST 2007
You could use truth maintenance, this won't remove something from a
list, but it will remove a fact from the working memory when a rule is
no longer true.
Mark
Michael Suzio wrote:
> Anytime you modify a object, candidate rules are going to be
> re-examined. You may need some state variables in addition to this
> (to control when rules fire, avoid loops, etc), but the basic rules
> could be:
>
> rule AddVcr
> when
> $c: Cart(contents contains "TV", contents excludes "free VCR")
> then
> $c.add("free VCR");
> modify($c);
> end
>
> rule RemoveVcr
> when
> $c: Cart(contents excludes "TV")
> then
> $c.remove("free VCR");
> modify($c);
> end
>
> You can fill in the rest. Like I said, you probably need some state
> variables so things don't loop, need to exclude the case where a
> non-free VCR is legitimately in the cart, etc. But your basic
> question should be answered with this approach. Don't think
> procedurally, think in terms of a living system when the changes in
> objects trigger somewhat asynchronous cascades of matching rules.
> Calling modify() on a fact is like restarting the whole matching
> algorithm for any rules that had that fact included in their (possible
> candidate) constraints.
>
> On 2/13/07, *Matt Johnston* <MJohnston at pubgroup.com
> <mailto:MJohnston at pubgroup.com>> wrote:
>
> I am working on rules for an online shopping cart. Depending on the
> products in the cart, the customer may get certain discounts.
>
> If cart contains a TV, add a free VCR.
>
> I can apply these rules, but what about rolling them back?
>
> So in the example above, the rule automatically added a free VCR
> because
> the cart contained a TV. If the customer removes the TV, I need to
> roll
> back the VCR rule and also remove the VCR from the cart.
>
> Does anyone know how to do this? Is it possible?
>
> Matt Johnston
> Manager of Internet Content
> Publishing Group of America
> p: 615-468-6053
> f: 615-468-6153
>
> _______________________________________________
> 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
> <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/20070213/98dd3264/attachment.html
More information about the rules-users
mailing list