Code refactor moving info about first and last day to MonthlyTimesheetModel
FEA: ItEr76S28UserDashboard
This commit is contained in:
parent
205c28a00c
commit
b2ec33fb07
3 changed files with 44 additions and 13 deletions
|
|
@ -40,8 +40,23 @@ public interface IMonthlyTimesheetModel {
|
|||
*/
|
||||
void initCreateOrEdit(LocalDate date);
|
||||
|
||||
/**
|
||||
* Returns the date of the monthly timesheet (only year and month should
|
||||
* take into account as the day is not important to define a monthly
|
||||
* timesheet).
|
||||
*/
|
||||
LocalDate getDate();
|
||||
|
||||
/**
|
||||
* Returns the first day of the month of the current monthly timesheet.
|
||||
*/
|
||||
LocalDate getFirstDay();
|
||||
|
||||
/**
|
||||
* Returns the last day of the month of the current monthly timesheet.
|
||||
*/
|
||||
LocalDate getLastDate();
|
||||
|
||||
/**
|
||||
* Returns resource bound to current user.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ public class MonthlyTimesheetController extends GenericForwardComposer
|
|||
|
||||
private RowRenderer rowRenderer = new RowRenderer() {
|
||||
|
||||
private LocalDate start;
|
||||
private LocalDate end;
|
||||
private LocalDate first;
|
||||
private LocalDate last;
|
||||
|
||||
@Override
|
||||
public void render(Row row, Object data) throws Exception {
|
||||
|
|
@ -96,9 +96,8 @@ public class MonthlyTimesheetController extends GenericForwardComposer
|
|||
}
|
||||
|
||||
private void initMonthlyTimesheetDates() {
|
||||
LocalDate date = monthlyTimesheetModel.getDate();
|
||||
start = date.dayOfMonth().withMinimumValue();
|
||||
end = date.dayOfMonth().withMaximumValue();
|
||||
first = monthlyTimesheetModel.getFirstDay();
|
||||
last = monthlyTimesheetModel.getLastDate();
|
||||
}
|
||||
|
||||
private void renderOrderElementRow(Row row, OrderElement orderElement) {
|
||||
|
|
@ -112,7 +111,7 @@ public class MonthlyTimesheetController extends GenericForwardComposer
|
|||
|
||||
private void appendInputsForDays(Row row,
|
||||
final OrderElement orderElement) {
|
||||
for (LocalDate day = start; day.compareTo(end) <= 0; day = day
|
||||
for (LocalDate day = first; day.compareTo(last) <= 0; day = day
|
||||
.plusDays(1)) {
|
||||
final LocalDate textboxDate = day;
|
||||
|
||||
|
|
@ -186,7 +185,7 @@ public class MonthlyTimesheetController extends GenericForwardComposer
|
|||
}
|
||||
|
||||
private void appendTotalForDays(Row row) {
|
||||
for (LocalDate day = start; day.compareTo(end) <= 0; day = day
|
||||
for (LocalDate day = first; day.compareTo(last) <= 0; day = day
|
||||
.plusDays(1)) {
|
||||
Cell cell = getCenteredCell(getDisabledTextboxWithId(getTotalRowTextboxId(day)));
|
||||
if (monthlyTimesheetModel.getResourceCapacity(day).isZero()) {
|
||||
|
|
@ -249,7 +248,7 @@ public class MonthlyTimesheetController extends GenericForwardComposer
|
|||
private void appendCapcityForDaysAndTotal(Row row) {
|
||||
EffortDuration totalCapacity = EffortDuration.zero();
|
||||
|
||||
for (LocalDate day = start; day.compareTo(end) <= 0; day = day
|
||||
for (LocalDate day = first; day.compareTo(last) <= 0; day = day
|
||||
.plusDays(1)) {
|
||||
EffortDuration capacity = monthlyTimesheetModel
|
||||
.getResourceCapacity(day);
|
||||
|
|
|
|||
|
|
@ -68,6 +68,10 @@ public class MonthlyTimesheetModel implements IMonthlyTimesheetModel {
|
|||
|
||||
private LocalDate date;
|
||||
|
||||
private LocalDate firstDay;
|
||||
|
||||
private LocalDate lastDay;
|
||||
|
||||
private List<OrderElement> orderElements;
|
||||
|
||||
private WorkReport workReport;
|
||||
|
|
@ -102,21 +106,24 @@ public class MonthlyTimesheetModel implements IMonthlyTimesheetModel {
|
|||
}
|
||||
this.date = date;
|
||||
|
||||
initDates();
|
||||
|
||||
initCapacityMap();
|
||||
|
||||
initOrderElements();
|
||||
initWorkReport();
|
||||
}
|
||||
|
||||
private void initDates() {
|
||||
firstDay = date.dayOfMonth().withMinimumValue();
|
||||
lastDay = date.dayOfMonth().withMaximumValue();
|
||||
}
|
||||
|
||||
private void initCapacityMap() {
|
||||
forceLoad(getWorker().getCalendar());
|
||||
|
||||
LocalDate date = getDate();
|
||||
LocalDate start = date.dayOfMonth().withMinimumValue();
|
||||
LocalDate end = date.dayOfMonth().withMaximumValue();
|
||||
|
||||
capacityMap = new HashMap<LocalDate, EffortDuration>();
|
||||
for (LocalDate day = start; day.compareTo(end) <= 0; day = day
|
||||
for (LocalDate day = firstDay; day.compareTo(lastDay) <= 0; day = day
|
||||
.plusDays(1)) {
|
||||
capacityMap.put(
|
||||
day,
|
||||
|
|
@ -185,6 +192,16 @@ public class MonthlyTimesheetModel implements IMonthlyTimesheetModel {
|
|||
return date;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate getFirstDay() {
|
||||
return firstDay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate getLastDate() {
|
||||
return lastDay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Worker getWorker() {
|
||||
return user.getWorker();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue