I found (i guess) a way to iterate over list, but it is not comparing and assigning the workorder now. I tried this way:-----------------rule "requiredSkill"whenThere is an unassigned workorderand the workorder has a requiredSkill other than nulland there is an engineerand the engineer has a skill other than nulland engineer skill is the same as workorder skillthenassign workorder to engineer
engineer-----------------this is how i tried implementing;-----------------rule "requiredSkill"when$workOrder : WorkOrder()$woReqSkill : SkillWorkOrder($requiredSkillWO : skill , eval(skill != null)) from $workOrder.requiredSkills$engineer : Engineer()$engineerSkill : SkillEngineer($engSkill : skill, eval(skill != null)) from $engineer.skillEngineerListexists SkillEngineer( $engineerSkill.skill == $woReqSkill.skill )theninsertLogical(new IntConstraintOccurrence("requiredSkill", ConstraintType.NEGATIVE_HARD,1, $engineer));end-----------------But all workorders are going to the same one, it is not validating if one is equals to other.2013/2/18 André Fróes <arfmoraes@gmail.com>Hello everyone!How can I compare 2 lists with a rule?I upgraded my basic model to a more complex one now, but now I hit a wall. My WorkOrder have a List of skills, and my Engineer also have a list of Skills and I have to compare one with another.Example:Engineer A have skill ABC 1Engineer B have skill ABC 2Engineer C have skill ABC 3WorkOrder A needs an engineer with skill ABC 3WorkOrder B needs an engineer with skill ABC 1WorkOrder C needs an engineer with skill ABC 2The result should be this:Engineer A will receive WorkOrder BEngineer B will receive WorkOrder CEngineer C will receive WorkOrder A---------------I am able to sort it by time, but not by skill, and I don't know how to loop over each list to find if one have the skills needed to fulful the other. These are my classes involved:WorkOrder attributes:--------private int requiredWorktime;private Priority priority;(enum)private Severity severity;(enum)private List<SkillWorkOrder> requiredSkills;--------Engineer attributes:--------private int worktime;private String name;private List<SkillEngineer> skillEngineerList;--------Skill attributes:--------private String name;--------both SkillEngineer and SkillWorkOrder are classes that simple receives the named class and a Skill:
Eg:private Engineer engineer; //Or WorkOrderprivate Skill skill;Is it possible to iterate over these 2 lists, by drool rule, to check wich engineer have most coincidences with an workorder? (Eg: if and Engineer have skill ABC1, ABC2 and a WorkOrder needs an engineer with skill ABC1, ABC2 and ABC3 he would be choseng among the others because his skills)