[rules-users] how do you select from a global List in decisiontable

Greg Barton greg_barton at yahoo.com
Thu Jan 13 23:27:21 EST 2011


Using globals in rule conditions is generally a bad idea.  This is because changes to the globals are not tracked automatically so rule firing is 1) not responsive to data changes, and 2) somewhat random when change happens.  Basically, avoid it.

GreG

On Jan 13, 2011, at 15:56, Gregory Mace <gregorymace at earthlink.net> wrote:

> Here is a simple example where 'otherPersonList' is a global java.util.List:
> 
> RuleTable Are friends having fun
> CONDITION						CONDITION					ACTION
> person: Person,  op: Person from otherPersonList	
> person.getRelationShip(op)				op.getActivity()				System.out.println("$param");
> FRIEND							PLAYING						Your friend is having fun
> ENEMY							WORKING						Not your friend and not having fun
> 
> which produces the following drl output:
> 
> #From row number: 31
> rule "Friends are having fun_31"
> 	
> 	when
> 		person: Person, op : Person from otherPersonList(person.getRelationShip(op) == "FRIEND", op.getActivity() == "PLAYING")
> 	then
> 		System.out.println("Your friend is having fun ");
> end
> 
> #From row number: 32
> rule "Friends are having fun_32"
> 	
> 	when
> 		person: Person, op : Person from otherPersonList(person.getRelationShip(op) == "ENEMY", op.getActivity() == "WORKING")
> 	then
> 		System.out.println("Not your friend and not having fun");
> end
> 
> shouldn't the 'from' be after the statement like this:?
> 
> person: Person, op : Person(person.getRelationShip(op) == "ENEMY", op.getActivity() == "WORKING") from otherPersonList
> 
> Thx
> 
> On Jan 13, 2011, at 11:47 AM, Wolfgang Laun wrote:
> 
>> I think I understand your question, but I'm not sure how to answer it. ;-)
>> 
>> What, exactly, are you trying to do? "Pulling" from a list means what?
>> 
>> -W 
>> 
>> 
>> On 13 January 2011 20:34, Gregory Mace <gregorymace at earthlink.net> wrote:
>> I believe I have the list set up correctly as a variable, but I am not sure how to set up a condition that pulls from a global list.  Any examples?
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>> 
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> _______________________________________________
> 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/20110113/ac783621/attachment.html 


More information about the rules-users mailing list