@Transactional
@Override
public List<ProjectAssignmentStatus> persistTimesheetWeek(Collection<TimesheetEntry> timesheetEntries,
TimesheetComment comment,
DateRange weekRange,
User forUser) {
Map<ProjectAssignment, List<TimesheetEntry>> timesheetRows = getTimesheetAsRows(timesheetEntries);
List<ProjectAssignmentStatus> errorStatusses = new ArrayList<>();
Seq<Interval> lockedDatesInRange = timesheetLockService.findLockedDatesInRange(weekRange.getDateStart(), weekRange.getDateEnd(), forUser);
List<Date> lockedDates = TimesheetLockService$.MODULE$.intervalToJavaDates(lockedDatesInRange);
for (Map.Entry<ProjectAssignment, List<TimesheetEntry>> entry : timesheetRows.entrySet()) {
try {
getTimesheetPersister().validateAndPersist(entry.getKey(), entry.getValue(), weekRange, lockedDates);
} catch (OverBudgetException e) {
errorStatusses.add(e.getStatus());
}
}
boolean wholeWeekLocked = TimesheetLockService$.MODULE$.isRangeLocked(weekRange.getDateStart(), weekRange.getDateEnd(), lockedDatesInRange);
if (!wholeWeekLocked &&
(!comment.getNewComment() || StringUtils.isNotBlank(comment.getComment()))) {
timesheetCommentDAO.persist(comment);
}
return errorStatusses;
}