Hi Guys,
I am new to drools and i have done some PoC of small things. Now i want to
implement a business functionality and it seems very complex to me. I didnt
get much time to go through docs but i went through it as much as can do.
but still no luck
My issue is I have list of employee objects it has methods say empId,
empPhone and empFName.
this employee class has overridden hashcode and equals method. It uses empId
and empPhone to check if user is right user.
I have hashMap of emp objects this map contains all employees of all depts
and locations.
I want to check if objects present in list are present in hashmap. if they
are present then i want to add them to different list and return
corresponding java code is as below
List <Emp> empList = new ArrayList<Emp>();
Map<Emp,Emp> map = new HashMap<Emp,Emp>();
for(Emp emp : empList){
  if(map.contains(emp)){
   // do something
  }
}

I need to convert above code in drools format in drl file. can I iterate
list and use contains in when clause ? so that i can put my actions in then.
through java i am providing drl with employeelist and hashmap
Please help i am in real trouble now

I tried doing 
rule "rule for emp"
when
 //$o : MyClass( id == "1", name == "name" )
 empDetails : TempStorage($object : empDetails)
 empTable:  TempStorage($mapObject : empTableData) 
 $mapObject.contains($object) 
 and
 Emp(empId  == $object.empId ,  empPhone == $object.empPhone)  from $object
 then
 System.out.println("hiiiii");
 end
but no luck i get exception as *Unable to resolve ObjectType
'$mapObject.contains' : [Rule name='calculation for 10%']*




--
View this message in context: 
http://drools.46999.n3.nabble.com/iterating-through-list-of-object-and-checking-if-object-is-present-in-Hashmap-tp4027505.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to