[rules-users] How to write constraint about a Map inside a Map?

Amir Rafique Amir.Rafique at netsolpk.com
Mon Jan 14 07:37:12 EST 2008


Hi all

After getting value from map. How can I change value against any particular
key in Map or how can I insert new value in Map.

Please help me out.

Thanks


Felipe Piccolini wrote:
> 
> Edson,
> 
>      Im so sorry, stupid me.... I dont know what happened but this  
> doesnt worked yesterday...
> dont remember the error, but now is working... must be murphy and his  
> dominating laws :)
> 
> Thanks for reply :)
> 
> Confirm:  $mf: MyFact( map['mapKey']['innerKey'] == "InnerValue" ) //  
> DOes work !! :)
> 
> On 25-07-2007, at 8:53, Edson Tirelli wrote:
> 
>>
>>     What error are you getting?
>>
>>     I just tested this in MVELSH and it works:
>>
>> mvel$ map["outerKey"]["innerKey"]
>> OUT: innerValue
>>
>>     []s
>>     Edson
>>
>>
>> 2007/7/24, Felipe Piccolini <felipe.piccolini at bluesoft.cl>:
>> Suppouse I have a Map attribute and one of the values is another  
>> Map...how can I check a member of the inner Map?
>>
>> class MyFact{
>>      Map map;
>>      public MyFact(){
>>            this.map = new HashMap();
>>      }
>>
>>      ....setter and getter...
>>
>> }
>>
>> -- test --
>> MyFact myFact = new MyFact();
>>
>> Map innerMap = new HashMap();
>> innerMap.put("innerKey", new String("InnerValue"));
>>
>> Map map = new HashMap();
>> map.put("mapKey", innerMap);
>>
>> myFact.setMap(map);
>>
>> .... set the RuleBase and insert myFact as a fact for the  
>> WorkingMemory...
>>
>> -------
>>
>> Now... how should I write the rule to check the innerKey ??
>>
>> rule "test InnerMap"
>>      when
>>            $mf: MyFact( map['mapKey']['innerKey'] ==  
>> "InnerValue" ) // doesnt work...
>>     ....
>>
>>            $mf: MyFact( map['mapKey'].this['innerKey'] ==  
>> "InnerValue" ) // doesnt work...
>> 	   $mf: MyFact( map['mapKey'].['innerKey'] == "InnerValue" ) //  
>> doesnt work...
>> 	   $mf: MyFact( $innerMap: map['mapKey'], $innerMap['innerKey'] ==  
>> "InnerValue" ) // doesnt work...
>>            $mf: MyFact( $innerMap: map['mapKey'] -> ($innerMap 
>> ['innerKey'] == "InnerValue" )) // doesnt work...
>>
>>
>> Thanks.
>>
>> Felipe Piccolini M.
>> felipe.piccolini at bluesoft.cl
>>
>>
>>
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>>
>>
>> -- 
>>   Edson Tirelli
>>   Software Engineer - JBoss Rules Core Developer
>>   Office: +55 11 3529-6000
>>   Mobile: +55 11 9287-5646
>>   JBoss, a division of Red Hat @ www.jboss.com
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 
> Felipe Piccolini M.
> felipe.piccolini at bluesoft.cl
> 
> 
> 
> 
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-write-constraint-about-a-Map-inside-a-Map--tp11773884p14800932.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list