ItEr32S09ValidacionEProbasFuncionaisItEr31S12: [Bug #66] Removing other unnecessary methods from interface
This commit is contained in:
parent
e9751288b7
commit
c9ee274efa
4 changed files with 181 additions and 190 deletions
|
|
@ -247,77 +247,6 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
|||
// spring method injection
|
||||
protected abstract ITaskElementAdapter getTaskElementAdapter();
|
||||
|
||||
/**
|
||||
* Calculate the hours by day for all the {@link DayAssignment} in the list.
|
||||
*
|
||||
* @param dayAssignments
|
||||
* The list of {@link DayAssignment}
|
||||
* @return A map { day => hours } sorted by date
|
||||
*/
|
||||
private SortedMap<LocalDate, Integer> calculateHoursAdditionByDay(
|
||||
List<DayAssignment> dayAssignments) {
|
||||
SortedMap<LocalDate, Integer> map = new TreeMap<LocalDate, Integer>();
|
||||
|
||||
if (dayAssignments.isEmpty()) {
|
||||
return map;
|
||||
}
|
||||
|
||||
Collections.sort(dayAssignments, new Comparator<DayAssignment>() {
|
||||
|
||||
@Override
|
||||
public int compare(DayAssignment o1, DayAssignment o2) {
|
||||
return o1.getDay().compareTo(o2.getDay());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
for (DayAssignment dayAssignment : dayAssignments) {
|
||||
LocalDate day = dayAssignment.getDay();
|
||||
Integer hours = dayAssignment.getHours();
|
||||
|
||||
if (map.get(day) == null) {
|
||||
map.put(day, hours);
|
||||
} else {
|
||||
map.put(day, map.get(day) + hours);
|
||||
}
|
||||
}
|
||||
|
||||
if (loadChartFiller.zoomByDay()) {
|
||||
return map;
|
||||
} else {
|
||||
return loadChartFiller.groupByWeek(map);
|
||||
}
|
||||
}
|
||||
|
||||
private SortedMap<LocalDate, Integer> calculateHoursAdditionByDay(
|
||||
List<Resource> resources, Date start, Date finish) {
|
||||
SortedMap<LocalDate, Integer> map = new TreeMap<LocalDate, Integer>();
|
||||
|
||||
LocalDate end = new LocalDate(finish);
|
||||
|
||||
for (LocalDate date = new LocalDate(start); date.compareTo(end) <= 0; date = date
|
||||
.plusDays(1)) {
|
||||
Integer hours = 0;
|
||||
for (Resource resource : resources) {
|
||||
ResourceCalendar calendar = resource.getCalendar();
|
||||
if (calendar != null) {
|
||||
hours += calendar.getWorkableHours(date);
|
||||
} else {
|
||||
hours += SameWorkHoursEveryDay.getDefaultWorkingDay()
|
||||
.getWorkableHours(date);
|
||||
}
|
||||
}
|
||||
|
||||
map.put(date, hours);
|
||||
}
|
||||
|
||||
if (loadChartFiller.zoomByDay()) {
|
||||
return map;
|
||||
} else {
|
||||
return loadChartFiller.groupByWeek(map);
|
||||
}
|
||||
}
|
||||
|
||||
private org.zkoss.zk.ui.Component getChartLegend() {
|
||||
Div div = new Div();
|
||||
|
||||
|
|
@ -396,6 +325,76 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
|||
return plotInfo;
|
||||
}
|
||||
|
||||
private SortedMap<LocalDate, Integer> calculateHoursAdditionByDay(
|
||||
List<Resource> resources, Date start, Date finish) {
|
||||
SortedMap<LocalDate, Integer> map = new TreeMap<LocalDate, Integer>();
|
||||
|
||||
LocalDate end = new LocalDate(finish);
|
||||
|
||||
for (LocalDate date = new LocalDate(start); date.compareTo(end) <= 0; date = date
|
||||
.plusDays(1)) {
|
||||
Integer hours = 0;
|
||||
for (Resource resource : resources) {
|
||||
ResourceCalendar calendar = resource.getCalendar();
|
||||
if (calendar != null) {
|
||||
hours += calendar.getWorkableHours(date);
|
||||
} else {
|
||||
hours += SameWorkHoursEveryDay.getDefaultWorkingDay()
|
||||
.getWorkableHours(date);
|
||||
}
|
||||
}
|
||||
|
||||
map.put(date, hours);
|
||||
}
|
||||
|
||||
if (zoomByDay()) {
|
||||
return map;
|
||||
} else {
|
||||
return groupByWeek(map);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the hours by day for all the {@link DayAssignment} in the list.
|
||||
* @param dayAssignments
|
||||
* The list of {@link DayAssignment}
|
||||
* @return A map { day => hours } sorted by date
|
||||
*/
|
||||
private SortedMap<LocalDate, Integer> calculateHoursAdditionByDay(
|
||||
List<DayAssignment> dayAssignments) {
|
||||
SortedMap<LocalDate, Integer> map = new TreeMap<LocalDate, Integer>();
|
||||
|
||||
if (dayAssignments.isEmpty()) {
|
||||
return map;
|
||||
}
|
||||
|
||||
Collections.sort(dayAssignments, new Comparator<DayAssignment>() {
|
||||
|
||||
@Override
|
||||
public int compare(DayAssignment o1, DayAssignment o2) {
|
||||
return o1.getDay().compareTo(o2.getDay());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
for (DayAssignment dayAssignment : dayAssignments) {
|
||||
LocalDate day = dayAssignment.getDay();
|
||||
Integer hours = dayAssignment.getHours();
|
||||
|
||||
if (map.get(day) == null) {
|
||||
map.put(day, hours);
|
||||
} else {
|
||||
map.put(day, map.get(day) + hours);
|
||||
}
|
||||
}
|
||||
|
||||
if (zoomByDay()) {
|
||||
return map;
|
||||
} else {
|
||||
return groupByWeek(map);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,6 @@
|
|||
|
||||
package org.navalplanner.web.planner;
|
||||
|
||||
import java.util.SortedMap;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.zkforge.timeplot.Timeplot;
|
||||
import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
|
||||
import org.zkoss.ganttz.util.Interval;
|
||||
|
|
@ -38,8 +35,4 @@ public interface ILoadChartFiller {
|
|||
|
||||
void setZoomLevel(ZoomLevel zoomLevel);
|
||||
|
||||
boolean zoomByDay();
|
||||
|
||||
SortedMap<LocalDate, Integer> groupByWeek(SortedMap<LocalDate, Integer> map);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,8 +192,7 @@ public abstract class LoadChartFiller implements ILoadChartFiller {
|
|||
return date.dayOfWeek().withMinimumValue().plusDays(DAYS_TO_THURSDAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean zoomByDay() {
|
||||
protected boolean zoomByDay() {
|
||||
return zoomLevel.equals(ZoomLevel.DETAIL_FIVE);
|
||||
}
|
||||
|
||||
|
|
@ -210,8 +209,7 @@ public abstract class LoadChartFiller implements ILoadChartFiller {
|
|||
return maximunValueForChart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<LocalDate, Integer> groupByWeek(
|
||||
protected SortedMap<LocalDate, Integer> groupByWeek(
|
||||
SortedMap<LocalDate, Integer> map) {
|
||||
SortedMap<LocalDate, Integer> result = new TreeMap<LocalDate, Integer>();
|
||||
|
||||
|
|
|
|||
|
|
@ -325,114 +325,6 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
}
|
||||
}
|
||||
|
||||
private SortedMap<LocalDate, Integer> calculateHoursAdditionByDay(
|
||||
List<DayAssignment> dayAssignments) {
|
||||
return calculateHoursAdditionByDay(dayAssignments, false, null, null);
|
||||
}
|
||||
|
||||
private SortedMap<LocalDate, Integer> calculateHoursAdditionByDay(
|
||||
List<DayAssignment> dayAssignments, LocalDate minDate,
|
||||
LocalDate maxDate) {
|
||||
return calculateHoursAdditionByDay(dayAssignments, false, minDate,
|
||||
maxDate);
|
||||
}
|
||||
|
||||
private SortedMap<LocalDate, Integer> calculateHoursAdditionByDay(
|
||||
List<DayAssignment> dayAssignments, boolean calendarHours) {
|
||||
return calculateHoursAdditionByDay(dayAssignments, calendarHours, null,
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the hours by day for all the {@link DayAssignment} in the list.
|
||||
*
|
||||
* @param dayAssignments
|
||||
* The list of {@link DayAssignment}
|
||||
* @param calendarHours
|
||||
* If <code>true</code> the resource's calendar will be used to
|
||||
* calculate the available hours. Otherwise, the
|
||||
* {@link DayAssignment} hours will be used.
|
||||
* @param minDate
|
||||
* If it's not <code>null</code>, just {@link DayAssignment} from
|
||||
* this date will be used.
|
||||
* @param maxDate
|
||||
* If it's not <code>null</code>, just {@link DayAssignment} to
|
||||
* this date will be used.
|
||||
*
|
||||
* @return A map { day => hours } sorted by date
|
||||
*/
|
||||
private SortedMap<LocalDate, Integer> calculateHoursAdditionByDay(
|
||||
List<DayAssignment> dayAssignments, boolean calendarHours,
|
||||
LocalDate minDate, LocalDate maxDate) {
|
||||
SortedMap<LocalDate, Integer> map = new TreeMap<LocalDate, Integer>();
|
||||
|
||||
if (dayAssignments.isEmpty()) {
|
||||
return map;
|
||||
}
|
||||
|
||||
Collections.sort(dayAssignments, new Comparator<DayAssignment>() {
|
||||
|
||||
@Override
|
||||
public int compare(DayAssignment o1, DayAssignment o2) {
|
||||
return o1.getDay().compareTo(o2.getDay());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Set<Resource> resroucesAlreadyUsed = new HashSet<Resource>();
|
||||
|
||||
for (DayAssignment dayAssignment : dayAssignments) {
|
||||
LocalDate day = dayAssignment.getDay();
|
||||
Integer hours = 0;
|
||||
|
||||
if (minDate != null) {
|
||||
if (day.compareTo(minDate) < 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (maxDate != null) {
|
||||
if (day.compareTo(maxDate) > 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (calendarHours) {
|
||||
Resource resource = dayAssignment.getResource();
|
||||
|
||||
if (map.get(day) == null) {
|
||||
resroucesAlreadyUsed.clear();
|
||||
}
|
||||
|
||||
if (!resroucesAlreadyUsed.contains(resource)) {
|
||||
resroucesAlreadyUsed.add(resource);
|
||||
ResourceCalendar calendar = resource.getCalendar();
|
||||
if (calendar != null) {
|
||||
hours = calendar.getWorkableHours(dayAssignment
|
||||
.getDay());
|
||||
} else {
|
||||
hours = SameWorkHoursEveryDay.getDefaultWorkingDay()
|
||||
.getWorkableHours(dayAssignment.getDay());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
hours = dayAssignment.getHours();
|
||||
}
|
||||
|
||||
if (map.get(day) == null) {
|
||||
map.put(day, hours);
|
||||
} else {
|
||||
map.put(day, map.get(day) + hours);
|
||||
}
|
||||
}
|
||||
|
||||
if (loadChartFiller.zoomByDay()) {
|
||||
return map;
|
||||
} else {
|
||||
return loadChartFiller.groupByWeek(map);
|
||||
}
|
||||
}
|
||||
|
||||
private org.zkoss.zk.ui.Component getChartLegend() {
|
||||
Div div = new Div();
|
||||
|
||||
|
|
@ -553,6 +445,115 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
return plotInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the hours by day for all the {@link DayAssignment} in the list.
|
||||
*
|
||||
* @param dayAssignments
|
||||
* The list of {@link DayAssignment}
|
||||
* @param calendarHours
|
||||
* If <code>true</code> the resource's calendar will be used to
|
||||
* calculate the available hours. Otherwise, the
|
||||
* {@link DayAssignment} hours will be used.
|
||||
* @param minDate
|
||||
* If it's not <code>null</code>, just {@link DayAssignment} from
|
||||
* this date will be used.
|
||||
* @param maxDate
|
||||
* If it's not <code>null</code>, just {@link DayAssignment} to
|
||||
* this date will be used.
|
||||
*
|
||||
* @return A map { day => hours } sorted by date
|
||||
*/
|
||||
private SortedMap<LocalDate, Integer> calculateHoursAdditionByDay(
|
||||
List<DayAssignment> dayAssignments, boolean calendarHours,
|
||||
LocalDate minDate, LocalDate maxDate) {
|
||||
SortedMap<LocalDate, Integer> map = new TreeMap<LocalDate, Integer>();
|
||||
|
||||
if (dayAssignments.isEmpty()) {
|
||||
return map;
|
||||
}
|
||||
|
||||
Collections.sort(dayAssignments, new Comparator<DayAssignment>() {
|
||||
|
||||
@Override
|
||||
public int compare(DayAssignment o1, DayAssignment o2) {
|
||||
return o1.getDay().compareTo(o2.getDay());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Set<Resource> resroucesAlreadyUsed = new HashSet<Resource>();
|
||||
|
||||
for (DayAssignment dayAssignment : dayAssignments) {
|
||||
LocalDate day = dayAssignment.getDay();
|
||||
Integer hours = 0;
|
||||
|
||||
if (minDate != null) {
|
||||
if (day.compareTo(minDate) < 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (maxDate != null) {
|
||||
if (day.compareTo(maxDate) > 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (calendarHours) {
|
||||
Resource resource = dayAssignment.getResource();
|
||||
|
||||
if (map.get(day) == null) {
|
||||
resroucesAlreadyUsed.clear();
|
||||
}
|
||||
|
||||
if (!resroucesAlreadyUsed.contains(resource)) {
|
||||
resroucesAlreadyUsed.add(resource);
|
||||
ResourceCalendar calendar = resource.getCalendar();
|
||||
if (calendar != null) {
|
||||
hours = calendar.getWorkableHours(dayAssignment
|
||||
.getDay());
|
||||
} else {
|
||||
hours = SameWorkHoursEveryDay.getDefaultWorkingDay()
|
||||
.getWorkableHours(dayAssignment.getDay());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
hours = dayAssignment.getHours();
|
||||
}
|
||||
|
||||
if (map.get(day) == null) {
|
||||
map.put(day, hours);
|
||||
} else {
|
||||
map.put(day, map.get(day) + hours);
|
||||
}
|
||||
}
|
||||
|
||||
if (zoomByDay()) {
|
||||
return map;
|
||||
} else {
|
||||
return groupByWeek(map);
|
||||
}
|
||||
}
|
||||
|
||||
private SortedMap<LocalDate, Integer> calculateHoursAdditionByDay(
|
||||
List<DayAssignment> dayAssignments) {
|
||||
return calculateHoursAdditionByDay(dayAssignments, false, null,
|
||||
null);
|
||||
}
|
||||
|
||||
private SortedMap<LocalDate, Integer> calculateHoursAdditionByDay(
|
||||
List<DayAssignment> dayAssignments, LocalDate minDate,
|
||||
LocalDate maxDate) {
|
||||
return calculateHoursAdditionByDay(dayAssignments, false, minDate,
|
||||
maxDate);
|
||||
}
|
||||
|
||||
private SortedMap<LocalDate, Integer> calculateHoursAdditionByDay(
|
||||
List<DayAssignment> dayAssignments, boolean calendarHours) {
|
||||
return calculateHoursAdditionByDay(dayAssignments, calendarHours,
|
||||
null, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue