[rules-users] [newbie] Using rules to enforce constraints?
Steven Williams
stevenw at objectconsulting.com.au
Thu Feb 22 19:35:43 EST 2007
Hi Scott,
You could do the second rule many different ways. One that springs to mind
is to assert a Transaction object at the start of a transaction and use
that, ie.:
when
c: Customer (status == "suspended")
Transaction(transactionType == TransactionType.NEW_ORDER, customer == c)
then
...
Something along those lines - basically just think about what information
you have at the instigation of the transaction that would allow you to
determine the type of the transaction and the customer and assert them. If
you are only asserting one customer into the WM then you could do away with
needing a customer property on the Transaction object as you could assume
it.
cheers
Steve
On 2/23/07, Scott Finnie <scott.finnie at virgin.net> wrote:
>
> Doh!
>
> rule 2 should of course read
>
> "A suspended customer may /not/ place any orders"
>
> Sorry.
>
> Scott Finnie wrote:
> > Hi,
> >
> > Apologies if this has been covered somewhere, couldn't find it in the
> > archives.
> >
> > I'm wondering about ability / sensibility of above. For example, say I
> > want to model the following rules:
> >
> > 1. A customer must be suspended if they default on a payment
> > 2. A suspended customer may place any orders
> >
> > Now the first one I can readily map to the when/then format of
> > production rules. But I can't see how to elegantly represent the second
> > one - at least not in a transactionally clean manner. I could write:
> >
> > when
> > c: Customer (status == "suspended")
> > o: Order ( customer == c)
> > then
> > o.reject() #etc.
> >
> > But that's not really what I want to achieve. Rather, I'd like the
> > check enforced before the order was created, not after.
> >
> > Or maybe I'm just thinking wrong? Main influence is RDBMS, where I'd
> > write a trigger that would stop the transaction completing if violated.
> >
> > Hope that makes sense, and thanks in advance.
> >
> > - Scoot.
> >
> > _______________________________________________
> > rules-users mailing list
> > 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
>
--
Steven Williams
Supervising Consultant
Object Consulting
Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501
stevenw at objectconsulting.com.au
www.objectconsulting.com.au
consulting | development | training | support
our experience makes the difference
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070223/99207819/attachment.html
More information about the rules-users
mailing list