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@lists.jboss.org [mailto:rules-users-bounces@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@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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users