[rules-users] Concatenating rule conditions

Wolfgang Laun wolfgang.laun at gmail.com
Wed May 25 12:04:03 EDT 2011


It's pointless to discuss (non-existent) technical solutions without knowing
what the problem is.

So far:

   - a set of Document objects should be selected for processing.
   - selection can be based on any of the Document properties
   - the actual property value is contained in an object ConditionMatrix

Why should processing of documents selected according to "privateName"
combined with those selected according to "legal"?

Otherwise, what is to be gained by "combining"?

-W


2011/5/25 Hezi Stern <hezis at delegatecom.com>

> Thanks for the reply, I think I was a bit vague with my question (my
> apologies on this) I will try to elaborate further
>
>
>
> I have several set of rules that filter, each filters a different set of
> conditions (e.g. User, Date, Country…).
>
> I would like to construct rules that based on conditions in the
> ConditionMatrix (in my example) I would like to set a specific rule set.
>
>
>
>
>
> A wishful thinking approach would be something like:
>
>
>
> Following are 2 filter rules
>
>
>
> Rule “filter user”
>
>
>
> When
>
>             $cm:                                      ConditionMatrix(),
>
>
>
> $document:                       ArrayList() from collect ( Document
> (user.isPrivateName  == $cm.user.isPrivateName) )
>
>
>
>
> Then
>
>
>
> End
>
>
>
>
>
>
>
> Rule “filter date”
>
>
>
> When
>
>             $cm:                                  ConditionMatrix(),
>
>
>
> $document:                       ArrayList() from collect ( Document
> (date.isLegal == $cm.date.isLegal) )
>
>
>
>
> Then
>
>                 //do something
>
> End
>
>
>
> The actual rule that utilized them would like :
>
>
>
> Rule “I am happy” extends “filter date”
>
>
>
> When
>
>                         $cm:     ConditionMatrix(),
>
>
>
> Then
>
>             //Do something
>
> End
>
>
>
> And a second rule can look like: (note that even if I can extend two rules
> then there is a conflict on $ document)
>
>
>
> Rule “I am sad” extends “filter date”,  “filter user”
>
>
>
> When
>
>                         $cm:     ConditionMatrix(),
>
>
>
> Then
>
>             //Do something
>
> End
>
>
>
> Hope this clearer now.
>
>
>
> Thanks
>
> Hezi
>
>
>
>
>
> *From:* rules-users-bounces at lists.jboss.org [mailto:
> rules-users-bounces at lists.jboss.org] *On Behalf Of *Wolfgang Laun
> *Sent:* Wednesday, May 25, 2011 6:18 PM
> *To:* Rules Users List
> *Subject:* Re: [rules-users] Concatenating rule conditions
>
>
>
> Just for the heck of it, here's two more ways for "comibining" those two
> rules. (Gee, what a vague specification!)
>
> # straightforwardly doing both in one
> rule comb1
> when
>    $cm: ConditionMatrix()
>    $docs1: ArrayList() from collect( Document( ... ) )
>    $docs2: ArrayList() from collect( Document( ... ) )
> then ... end
>
> # abstraction
> rule comb2
> when
>    $cm: ConditionMatrix()
>    $filter: Filter()
>    $docs: ArrayList() from collect( $d: Document() eval( $filter.pass( $cm,
> $d ) ) )
> then ... end
>
> -W
>
>
> 2011/5/25 Vincent Legendre <vincent.legendre at eurodecision.com>
>
> Not sure of what you exactly ...
>
> If you want to combine tests, you can write this :
>
> Rule “test filter”
> When
>       $cm:  ConditionMatrix()
>
>       $document:   ArrayList() from collect ( Document (user.isPrivateName
>  == $cm.isPrivateName, Payment.isLegal == $cm.isLegal)
> )
> Then
>                 //do something
> End
>
> If you want to make the filter more dynamic and write only one "collect"
> rule, I don't see any out-of-the-box method.
> You can add a method in ConditionMatrix that accepts a Document and write
> this rule :
>
>
> Rule “test filter”
> When
>       $cm:  ConditionMatrix()
>
>       $document:   ArrayList() from collect ( Document
> (eval($cm.accept(this)) )
> )
> Then
>                 //do something
> End
>
> Of course you have to implement the "accept" method in Java (and you can
> then do several sub-classes for you filters)
>
>
> _______________________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110525/ec19de89/attachment.html 


More information about the rules-users mailing list