[rules-users] Concatenating rule conditions

Wolfgang Laun wolfgang.laun at gmail.com
Wed May 25 11:17:48 EDT 2011


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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110525/9c82088b/attachment.html 


More information about the rules-users mailing list