Op 07-02-13 15:15, André Fróes schreef:
Hello!
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.

Right now I'm trying to compose this:

When
   there's an workorder with skill
   and there's and engineer with the skill and capable of doing that workorder
then
   the engineer should do it

So i tried something like this:

rule "assignSkillWOToSkilledEngineer"
when
$wo : WorkOrder( $requiredSkill : requiredSkill  )
$engineer : Engineer(skill == $requiredSkill)
there's no restriction that the WorkerOrder is assigned to that engineer, so it matches with every engineer of that skill?
then
insertLogical(new IntConstraintOccurrence("assignSkillWOToSkilledEngineer", ConstraintType.NEGATIVE_HARD,
1, $engineer));
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.
Normally the causes are the planning entities involved.
Try
insertLogical(new IntConstraintOccurrence("assignSkillWOToSkilledEngineer", ConstraintType.NEGATIVE_HARD,
1, $wo));

end

I would write it like this (pseudo code):

rule "assignSkillWOToSkilledEngineer"
when
$wo : WorkOrder( $requiredSkill : requiredSkill, $assignedEngineer : assignedEngineer  )
not EngineerSkillRelation(skill == $requiredSkill, engineer == $assignedEngineer)
      then
                insertLogical(new IntConstraintOccurrence("assignSkillWOToSkilledEngineer", ConstraintType.NEGATIVE_HARD,
                  1, $wo));
end
i get no exceptions, but the sort is not working properly


_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users