[jboss-jira] [JBoss JIRA] (DROOLS-1251) An accumulate with 2 constraints should accept "and", not just "&&" and ", "

Geoffrey De Smet (JIRA) issues at jboss.org
Wed Aug 10 08:58:00 EDT 2016


Geoffrey De Smet created DROOLS-1251:
----------------------------------------

             Summary: An accumulate with 2 constraints should accept "and", not just "&&" and ","
                 Key: DROOLS-1251
                 URL: https://issues.jboss.org/browse/DROOLS-1251
             Project: Drools
          Issue Type: Enhancement
          Components: core engine
            Reporter: Geoffrey De Smet
            Assignee: Mario Fusco
            Priority: Minor


This rule:

{code}
// Identical shiftTypes during a weekend
rule "identicalShiftTypesDuringWeekend"
    when
        $contractLine : BooleanContractLine(contractLineType == ContractLineType.IDENTICAL_SHIFT_TYPES_DURING_WEEKEND,
            enabled == true, $contract : contract)
        $employee : Employee(contract == $contract, $weekendLength : weekendLength)
        ShiftDate(dayOfWeek == DayOfWeek.SUNDAY, $sundayIndex : dayIndex)
        $shiftType : ShiftType()
        accumulate(
            $assignment : ShiftAssignment(
                weekend == true,
                weekendSundayIndex == $sundayIndex,
                employee == $employee,
                shiftType == $shiftType);
            $weekendAssignmentTotal : count($assignment);
            $weekendAssignmentTotal > 0 and $weekendAssignmentTotal < $weekendLength
        )
    then
        scoreHolder.addSoftConstraintMatch(kcontext,
                ($weekendAssignmentTotal.intValue() - $weekendLength) * $contractLine.getWeight());
end
{code}


throws

{code}
java.lang.IllegalStateException: There are errors in a score DRL:
Error Messages:
Message [id=1, level=ERROR, path=org/optaplanner/examples/nurserostering/solver/nurseRosteringScoreRules.drl, line=452, column=0
   text=[ERR 102] Line 452:40 mismatched input 'and' in rule "identicalShiftTypesDuringWeekend"]
Message [id=2, level=ERROR, path=org/optaplanner/examples/nurserostering/solver/nurseRosteringScoreRules.drl, line=0, column=0
   text=Parser returned a null Package]
---
{code}


More specifically:

{code}
        accumulate(
            ...;
            $weekendAssignmentTotal : count($assignment);
            $weekendAssignmentTotal > 0 and $weekendAssignmentTotal < $weekendLength // FAILS
        )
{code}
{code}
        accumulate(
            ...;
            $weekendAssignmentTotal : count($assignment);
            $weekendAssignmentTotal > 0 && $weekendAssignmentTotal < $weekendLength // WORKS
        )
{code}
{code}
        accumulate(
            ...;
            $weekendAssignmentTotal : count($assignment);
            $weekendAssignmentTotal > 0, $weekendAssignmentTotal < $weekendLength // WORKS
        )
{code}




--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list