Bug #1559: Remove WorkReportLines with zero effort in personal timesheets

FEA: ItEr77S04BugFixing
This commit is contained in:
Manuel Rego Casasnovas 2012-11-13 12:22:49 +01:00
parent 38cbd25d06
commit c9a638e4f3

View file

@ -431,9 +431,14 @@ public class PersonalTimesheetModel implements IPersonalTimesheetModel {
// saved as it will not be possible to find it later with
// WorkReportDAO.getPersonalTimesheetWorkReport() method.
} else {
Set<WorkReportLine> deletedWorkReportLinesSet = removeWorkReportLinesWithEffortZero();
Set<OrderElement> orderElements = sumChargedEffortDAO
.getOrderElementsToRecalculateTimsheetDates(
workReport.getWorkReportLines(), null);
workReport.getWorkReportLines(),
deletedWorkReportLinesSet);
sumChargedEffortDAO
.updateRelatedSumChargedEffortWithDeletedWorkReportLineSet(deletedWorkReportLinesSet);
sumChargedEffortDAO
.updateRelatedSumChargedEffortWithWorkReportLineSet(workReport
.getWorkReportLines());
@ -446,6 +451,19 @@ public class PersonalTimesheetModel implements IPersonalTimesheetModel {
resetModifiedFields();
}
private Set<WorkReportLine> removeWorkReportLinesWithEffortZero() {
Set<WorkReportLine> toRemove = new HashSet<WorkReportLine>();
for (WorkReportLine line : workReport.getWorkReportLines()) {
if (line.getEffort().isZero()) {
toRemove.add(line);
}
}
for (WorkReportLine line : toRemove) {
workReport.removeWorkReportLine(line);
}
return toRemove;
}
private void resetModifiedFields() {
modified = false;
modifiedMap = new HashMap<OrderElement, Set<LocalDate>>();