[Bug #1026] Fix bug

In several places specific and generic allocations are divided
disrupting the previous order. Reordering after the division.

FEA: ItEr74S04BugFixing
This commit is contained in:
Óscar González Fernández 2011-04-26 18:01:33 +02:00
parent e5fe70f03d
commit c1006c0ad2
2 changed files with 27 additions and 0 deletions

View file

@ -23,15 +23,38 @@ package org.zkoss.ganttz.data.resourceload;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import org.apache.commons.collections.ComparatorUtils;
import org.apache.commons.lang.Validate;
import org.joda.time.LocalDate;
import org.zkoss.ganttz.util.Interval;
public class LoadTimeLine {
@SuppressWarnings("unchecked")
private static final Comparator<LocalDate> nullSafeComparator = ComparatorUtils
.nullLowComparator(ComparatorUtils.naturalComparator());
public static Comparator<LoadTimeLine> byStartAndEndDate() {
return new Comparator<LoadTimeLine>() {
@Override
public int compare(LoadTimeLine o1, LoadTimeLine o2) {
int result = nullSafeComparator.compare(o1.getStartPeriod(),
o2.getStartPeriod());
if (result == 0) {
return nullSafeComparator.compare(o1.getEndPeriod(),
o2.getEndPeriod());
}
return result;
}
};
}
private final String conceptName;
private final List<LoadPeriod> loadPeriods;

View file

@ -26,6 +26,7 @@ import static org.navalplanner.web.I18nHelper._;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
@ -457,6 +458,7 @@ public class ResourceLoadModel implements IResourceLoadModel {
result.addAll(buildSubLevels(criterion, ResourceAllocation.getOfType(
GenericResourceAllocation.class, allocations)));
result.add(buildRelatedSpecificAllocations(criterion, allocations));
Collections.sort(result, LoadTimeLine.byStartAndEndDate());
return result;
}
@ -507,6 +509,7 @@ public class ResourceLoadModel implements IResourceLoadModel {
onlyGeneric(allocations)));
result.addAll(buildTimeLinesForEachResource(criterion,
onlySpecific(allocations), getCurrentTimeLineRole(order)));
Collections.sort(result, LoadTimeLine.byStartAndEndDate());
return result;
}
@ -755,6 +758,7 @@ public class ResourceLoadModel implements IResourceLoadModel {
onlySpecific(sortedByStartDate)));
result.addAll(buildTimeLinesForEachCriterion(resource,
onlyGeneric(sortedByStartDate)));
Collections.sort(result, LoadTimeLine.byStartAndEndDate());
return result;
}