[rules-users] Handling maps in Drools
Manav
manav7574 at yahoo.com
Thu Aug 16 01:28:34 EDT 2012
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
More information about the rules-users
mailing list