Am I being blind or are "in" and "not in" not actually documented in
the drools expert user guide? In particular the fact that the syntax for the list is to
put it in round brackets (1,2,3) and not the square brackets [1,2,3] which you would
expect from the mvel documentation.
Also why can't memberOf work off an inline mvel list anyway?
Thomas
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-
bounces(a)lists.jboss.org] On Behalf Of Ansgar Konermann
Sent: 21 February 2010 22:37
To: Rules Users List
Subject: Re: [rules-users] memberOf mvel list
Hi Adam,
try operator "in" instead of "memberOf". AFAIK, "in" deals
with list
literals (which is what you want) whereas "memberof" can be used to
check whether some value is part of a collection given as variable
reference.
Kind regards
Ansgar
Am 21.02.2010 23:14, schrieb deaddowney:
> I'm using a map because this is a legacy class that is quite dynamic and can
> contain arbitrary tag/values. Ideally, if I knew all the attributes I would
> declare them as fields, but I'm stuck with this map at the moment.
> Regardless, using your explanation, why does
>
> when
> $person : Person(
> props[“AGE”]> 20,
> (props[“NAME”] =="Fred" ||
props["NAME"]
> == "Barney || props["NAME"] == "Wilma"])
> )
>
> work?
>
>
> Corneil du Plessis-2 wrote:
>
>> You are expecting map values to be elevated somehow from Object to Integer
>> and String.
>> By using typed attributes in the Person class you can overcome your
>> problem.
>>
>> Sent from my HTC (Android)
>>
>> On Feb 21, 2010 9:28 PM, "Adam Krieg"<spamcontrol(a)mac.com>
wrote:
>>
>> I’m new to Drools and having trouble accessing my Domain object which is
>> basically a container around a map.
>>
>> class Person {
>> Map props;
>> public Map getProps();
>> …. Extra stuff
>> }
>>
>>
>> I want to create a rule that will match when Age is greater than 20 and
>> name
>> is one of “Fred”, “Barney”, or “Wilma”. These entries are stored in the
>> Map props, so that to get age, you would call person.getProps().get(“AGE”)
>>
>>
>>
>> rule "My Rule"
>> dialect "mvel"
>> when
>> $person : Person(
>> props[“AGE”]> 20,
>> props[“NAME”] memberOf [“Fred”,
>> “Wilma”,
>> “Barney”]
>> )
>> then
>> System.out.println("found match”+$person);
>>
>> End
>>
>> But I am running into a parsing error:
>> no viable alternative at input ')' in rule "My Rule" in
pattern Person.
>>
>> The second condition seems to be the problem. Can I check for membership
>> inside a List I create inline in mvel?
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received
this message in error, please immediately notify the postmaster(a)nds.com and delete it from
your system as well as any copies. The content of e-mails as well as traffic data may be
monitored by NDS for employment and security purposes. To protect the environment please
do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United
Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603
8808 40-00
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received
this message in error, please immediately notify the postmaster(a)nds.com and delete it from
your system as well as any copies. The content of e-mails as well as traffic data may be
monitored by NDS for employment and security purposes.
To protect the environment please do not print this e-mail unless necessary.
An NDS Group Limited company.
www.nds.com