<div dir="ltr">I found (i guess) a way to iterate over list, but it is not comparing and assigning the workorder now. I tried this way:<div>-----------------<br></div><div style>rule "requiredSkill"</div><div style>
when</div><div style> There is an unassigned workorder</div><div style> and the workorder has a requiredSkill other than null</div><div style><br></div><div style> and there is an engineer<br></div><div style>
and the engineer has a skill other than null<br></div><div style><br></div><div style> and engineer skill is the same as workorder skill<br></div><div style> then</div><div style> assign workorder to engineer<br>
</div><div style>engineer</div><div>-----------------</div><div style>this is how i tried implementing;</div><div>-----------------<br></div><div><div>rule "requiredSkill"</div><div><span class="" style="white-space:pre">        </span>when</div>
<div><span class="" style="white-space:pre">         </span>$workOrder : WorkOrder() </div><div><span class="" style="white-space:pre">        </span> $woReqSkill : SkillWorkOrder($requiredSkillWO : skill , eval(skill != null)) from $workOrder.requiredSkills </div>
<div><span class="" style="white-space:pre">        </span> </div><div><span class="" style="white-space:pre">        </span> $engineer : Engineer()</div><div><span class="" style="white-space:pre">        </span> $engineerSkill : SkillEngineer($engSkill : skill, eval(skill != null)) from $engineer.skillEngineerList</div>
<div><span class="" style="white-space:pre">        </span> </div><div><span class="" style="white-space:pre">        </span> exists SkillEngineer( $engineerSkill.skill == $woReqSkill.skill )</div><div><span class="" style="white-space:pre">        </span>then</div>
<div><span class="" style="white-space:pre">                </span>insertLogical(new IntConstraintOccurrence("requiredSkill", ConstraintType.NEGATIVE_HARD,</div><div><span class="" style="white-space:pre">                        </span>1, $engineer));</div>
<div>end</div></div><div>-----------------<br></div><div style>But all workorders are going to the same one, it is not validating if one is equals to other.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
2013/2/18 André Fróes <span dir="ltr"><<a href="mailto:arfmoraes@gmail.com" target="_blank">arfmoraes@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hello everyone!<div><br></div><div>How can I compare 2 lists with a rule?</div><div>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.</div>
<div><br></div><div>Example:</div><div><br></div><div>Engineer A have skill ABC 1</div><div>Engineer B have skill ABC 2</div><div>Engineer C have skill ABC 3</div><div><br></div><div>
WorkOrder A needs an engineer with skill ABC 3</div><div>WorkOrder B needs an engineer with skill ABC 1</div><div>WorkOrder C needs an engineer with skill ABC 2<br></div><div><br></div><div>The result should be this:</div>
<div><br></div><div>Engineer A will receive WorkOrder B</div><div>Engineer B will receive WorkOrder C<br></div><div>Engineer C will receive WorkOrder A<br></div><div>---------------</div><div>
<br></div><div>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:</div><div>
<br></div><div>WorkOrder attributes:</div><div>--------</div><div><div>private int requiredWorktime;</div><div>private Priority priority;(enum)</div><div>private Severity severity;(enum)</div><div>private List<SkillWorkOrder> requiredSkills;</div>
<div>--------</div><div>Engineer attributes:</div><div>--------</div><div><div>private int worktime;</div><div>private String name;</div><div>private List<SkillEngineer> skillEngineerList;</div><div>
--------</div><div>Skill attributes:</div><div>--------</div><div>private String name;</div><div>--------</div><div><br></div><div>both SkillEngineer and SkillWorkOrder are classes that simple receives the named class and a Skill:<br>
</div><div>Eg:</div><div><div>private Engineer engineer; //Or WorkOrder</div><div>private Skill skill;</div><div><br></div><div>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)</div>
</div><div><br></div></div></div></div>
</blockquote></div><br></div>