intellij-ideaoptaplannerdrools-planner

OptaPlanner code in IntelliJ: drools rule, wrong 1st argument in PAS: kcontext


I'm using Optaplanner 7.0.0 Beta 7 in Intellij. I have a problem with the drools rules in the example pas of optaplanner library.

Intellij says that it can't find the kcontext object as parameter in scoreHolder.addHardConstraintMatch. Intellij need the Object org.kie.api.runtime.rule.RuleContext but about the beta version I can only use org.kie.api.runtime.rule.KieContext.

How I can fix this in the drools rules? I am new in drools

// Department's maximumAge constraint
rule "departmentMaximumAge"
    when
        $department : Department(maximumAge != null, $maximumAge : maximumAge)
        $bedDesignation : BedDesignation(department == $department, patientAge > $maximumAge)
    then
        // Note: the original spec classified this as a soft constraint
        scoreHolder.addHardConstraintMatch(kcontext, -100 * $bedDesignation.getAdmissionPartNightCount());
end

Volker


Solution

  • This is a well known bug in IntelliJ. I've tried reaching out to JetBrains (Sergey) to contribute a fix, but with no response.