This rule works with 5.1.1: rule "Map test" when $rb : Certifications($reqCertificationKeys : requiredCertifications.keySet) $user : User( $userCertifications : userCertifications ) Number( $score : intValue ) from accumulate( $key: String( this memberOf ($userCertifications.keySet()) ) from $reqCertificationKeys, sum( $userCertifications.get( $key ) ) ) then System.out.println( "score is " + $score ); end
-W On 16/08/2012, Manav <manav7...@yahoo.com> wrote: > Hi, > > I am facing an issue with handling maps in LHS of drools. Appreciate your > help with the same. > > I am using Drools version 5.1. > > > I have two maps where one is a reference map that contains certifications > (key) and scores(value) required and other is map of user's actual > certifications and scores. Objective is to find the certifications from > users map based on keys in the reference map . Then for these certifications > sum the score values and check if they cross the threshold. > > While trying to do the first step i am facing an issue . My rule looks like > this :- > > rule "Map test" > when > $rb : Certifications($reqCertificationKeys : > requiredCertifications.keySet) > $user : User($userCertifications : userCertifications) > $arg : String() from $reqCertificationKeys > HashMap ($value : this[$arg] != null) from $userCertifications // Does > not work > then > System.out.println ("Hash Map" + $arg); > end > > However if i change the above line that has issues with below > > HashMap ($value : this["Java"] != null) from $userCertifications // > Works > > Is there a way to replace the key with a variable than with a fixed value ? > Is it possible to iterate the second map with the key values that we get > from the reference map ? > > Regards, > Manav > > _______________________________________________ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users