]
Geoffrey De Smet updated DROOLS-1251:
-------------------------------------
Affects Version/s: 6.4.0.Final
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
Affects Versions: 6.4.0.Final
Reporter: Geoffrey De Smet
Assignee: Mario Fusco
Priority: Minor
Specifically:
{code}
accumulate(
...;
$t : count($assignment);
$t > 0 and $t < $weekendLength // FAILS
)
{code}
{code}
accumulate(
...;
$t : count($assignment);
$t > 0 && $t < $weekendLength // WORKS
)
{code}
{code}
accumulate(
...;
$t : count($assignment);
$t > 0, $t < $weekendLength // WORKS
)
{code}
----
Full reproducer from optaplanner-examples employee rostering example, 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}