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(a)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(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users