[rules-users] Constraints over Lists
Phani Saripalli
saripalli.phani at gmail.com
Tue Jan 22 05:03:34 EST 2013
Hi, I have a query reg. writing constraints over lists.
Precisely heres what I m doing
//Imports
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.ArrayList;
//My methods - functions
function boolean isDefined(Object ob) {
return ob != null;
}
function boolean neqq(List l1, List l2) {
return l1 != l2;
}
//List declaration
declare Project
@typesafe (false)
list1 : List
list2 : List
end
//Initial declaration rule
rule " Config rule "
agenda-group "Group Config"
dialect "mvel"
no-loop true
lock-on-active true
when
P : Project()
then
modify(P) {
list1 = new java.util.ArrayList(java.util.Arrays.asList(10, 15, 20, 25)),
list2 = new java.util.ArrayList(java.util.Arrays.asList(11, 2, 3, 4, 5,
10, 9, 8, 7))
};
update(P);
end
//Rule-constraint
rule "listEq1"
agenda-group "Group 2"
dialect "mvel"
no-loop true
lock-on-active true
when
P : Project( isDefined(P.list1)
&& neqq(P.list1, new java.util.ArrayList(java.util.Arrays.asList(1, 2, 3)))
)
then
System.out.println("Lists are not equal - 1");
end
//Rule - constraint 2
rule "listEq2"
agenda-group "Group 2"
dialect "mvel"
no-loop true
lock-on-active true
when
P : Project( isDefined(P.list1) && isDefined(P.list2)
&& neqq(P.list1, P.list2)
)
then
System.out.println("Lists are not equal - 2");
end
******************
If I remove the rule "listEq1", everything works fine, other it raises
several exceptions like
- Exception executing consequence for rule " Config rule "
- cannot invoke method asList
- cannot invoke method neqq
Can anyone tell me whats going on here, whats the reason for this.
Many thanks :)
Phani
--
View this message in context: http://drools.46999.n3.nabble.com/Constraints-over-Lists-tp4021715.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
More information about the rules-users
mailing list