<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">Op 07-02-13 15:15, André Fróes schreef:<br>
</div>
<blockquote
cite="mid:CAC8f_wVAQ1=q6WKhvNDTMFaFCwjsA+i5pyF+jfdQacq+GiohfA@mail.gmail.com"
type="cite">
<div dir="ltr">Hello!
<div style="">I'm still not getting good with drools rules, i'm
trying several examples and basic ones. Some i did without any
problem and understood plenty well, but when I try to make an
approach to what i'm aiming, I'm not able to.</div>
<div style=""><br>
</div>
<div style="">Right now I'm trying to compose this:</div>
<div style=""><br>
</div>
<div style="">When</div>
<div style=""> there's an workorder with skill</div>
<div style=""> and there's and engineer with the skill and
capable of doing that workorder</div>
<div style="">then</div>
<div style=""> the engineer should do it</div>
<div style=""><br>
</div>
<div style="">So i tried something like this:</div>
<div style=""><br>
</div>
<div style="">
<div>rule "assignSkillWOToSkilledEngineer"</div>
<div><span class="" style="white-space:pre"> </span>when</div>
<div><span class="" style="white-space:pre"> </span>$wo :
WorkOrder( $requiredSkill : requiredSkill )</div>
<div><span class="" style="white-space:pre"> </span>$engineer
: Engineer(skill == $requiredSkill)</div>
</div>
</div>
</blockquote>
there's no restriction that the WorkerOrder is assigned to that
engineer, so it matches with every engineer of that skill?<br>
<blockquote
cite="mid:CAC8f_wVAQ1=q6WKhvNDTMFaFCwjsA+i5pyF+jfdQacq+GiohfA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div style="">
<div><span class="" style="white-space:pre"> </span>then</div>
<div><span class="" style="white-space:pre"> </span>insertLogical(new
IntConstraintOccurrence("assignSkillWOToSkilledEngineer",
ConstraintType.NEGATIVE_HARD,</div>
<div><span class="" style="white-space:pre"> </span>1,
$engineer));</div>
</div>
</div>
</blockquote>
the cause $engineer is a problem: If an engineer combines with 2
workorders, it will only count for 1 point due the way insertLogical
work.<br>
Normally the causes are the planning entities involved.<br>
Try <br>
insertLogical(new
IntConstraintOccurrence("assignSkillWOToSkilledEngineer",
ConstraintType.NEGATIVE_HARD,
<div><span class="" style="white-space:pre"> </span>1, <span
class="" style="white-space:pre"></span>$wo));</div>
<br>
<blockquote
cite="mid:CAC8f_wVAQ1=q6WKhvNDTMFaFCwjsA+i5pyF+jfdQacq+GiohfA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div style="">
<div>end</div>
<div><br>
</div>
</div>
</div>
</blockquote>
I would write it like this (pseudo code):<br>
<br>
<div style="">
<div>rule "assignSkillWOToSkilledEngineer"</div>
<div><span class="" style="white-space:pre"> </span>when</div>
<div><span class="" style="white-space:pre"> </span>$wo :
WorkOrder( $requiredSkill : requiredSkill, $assignedEngineer :
assignedEngineer )</div>
<div><span class="" style="white-space:pre"> </span>not
EngineerSkillRelation(skill == $requiredSkill, engineer ==
$assignedEngineer)<br>
then<br>
insertLogical(new
IntConstraintOccurrence("assignSkillWOToSkilledEngineer",
ConstraintType.NEGATIVE_HARD,<br>
1, $wo));<br>
</div>
</div>
end<br>
<blockquote
cite="mid:CAC8f_wVAQ1=q6WKhvNDTMFaFCwjsA+i5pyF+jfdQacq+GiohfA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div style="">
<div style="">i get no exceptions, but the sort is not working
properly</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a></pre>
</blockquote>
<br>
</body>
</html>