Ich habe derzeit diese Einschränkung:
Code: Select all
Constraint weeklyMinutesMustNotBeLessThanEmploymentRuleMinimum(ConstraintFactory constraintFactory) {
return constraintFactory
.forEach(Shift.class)
.filter(shift -> shift.getEmployee().getEmploymentRule().getMinimumMinutesPerWeek() != null)
.groupBy(Shift::getEmployee,
shift -> extractFirstDayOfWeek(DateTimeUtils.WEEK_START_DAY, shift.getStartDateTime()),
sumDuration(shift -> Duration.ofMinutes(shift.getLengthInMinutes())))
.complement(Employee.class, "firstDayOfWeek" ,employee -> Duration.ZERO)
.filter((employee, firstDayOfWeek, totalWorkingTime) ->
totalWorkingTime.toMinutes() < (long) employee.getEmploymentRule().getMinimumMinutesPerWeek())
.penalizeLong(CONSTRAINT_LEVEL_WEEK_MINUTES_MUST_NOT_BE_LESS_THAN_EMPLOYMENT_RULE_MINIMUM,
(employee, firstDayOfWeek, totalWorkingTime) ->
employee.getEmploymentRule().getMinimumMinutesPerWeek() - totalWorkingTime.toMinutes())
.asConstraint(CONSTRAINT_WEEK_MINUTES_MUST_NOT_BE_LESS_THAN_EMPLOYMENT_RULE_MINIMUM);
}
Ist es möglich, komplement() mit einem abgeleiteten groupBy-Schlüssel wie firstDayOfWeek zu verwenden?
Mobile version