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
Not sure of what you exactly ...
If you want to combine tests, you can write this :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.Rule “test filter”$document: ArrayList() from collect ( Document (user.isPrivateName == $cm.isPrivateName, Payment.isLegal == $cm.isLegal) )
When
$cm: ConditionMatrix()
Then
//do something
End
You can add a method in ConditionMatrix that accepts a Document and write this rule :$document: ArrayList() from collect ( Document (eval($cm.accept(this)) ) )
Rule “test filter”
When
$cm: ConditionMatrix()
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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users