ItEr56S11CUEscaladoPantallaCargaRecursosEmpresaItEr55S15: Order and show the Criterions using the type and the name in Resources Load panel.

This commit is contained in:
Jacobo Aragunde Pérez 2010-04-30 14:12:44 +02:00 committed by Javier Moran Rua
parent bcca6dd4dd
commit 8a2073b41b
2 changed files with 23 additions and 3 deletions

View file

@ -84,6 +84,26 @@ public class Criterion extends IntegrationEntity implements ICriterion {
return result;
}
public static List<Criterion> sortByTypeAndName(Collection<Criterion> criterions) {
List<Criterion> result = new ArrayList<Criterion>(criterions);
Collections.sort(result, new Comparator<Criterion>() {
@Override
public int compare(Criterion o1, Criterion o2) {
if (o1.getName() == null || o1.getType().getName() == null) {
return 1;
}
if (o2.getName() == null || o2.getType().getName() == null) {
return -1;
}
String name1 = o1.getType().getName() + " " + o1.getName();
String name2 = o2.getType().getName() + " " + o2.getName();
return name1.compareTo(name2);
}
});
return result;
}
public void updateUnvalidated(String name, Boolean active) {
if (!StringUtils.isBlank(name)) {

View file

@ -247,7 +247,7 @@ public class ResourceLoadModel implements IResourceLoadModel {
Map<Criterion, List<GenericResourceAllocation>> genericAllocationsByCriterion) {
List<LoadTimeLine> result = new ArrayList<LoadTimeLine>();
List<Criterion> criterions = Criterion
.sortByName(genericAllocationsByCriterion.keySet());
.sortByTypeAndName(genericAllocationsByCriterion.keySet());
for (Criterion criterion : criterions) {
List<GenericResourceAllocation> allocations = ResourceAllocation
.sortedByStartDate(genericAllocationsByCriterion
@ -396,8 +396,8 @@ public class ResourceLoadModel implements IResourceLoadModel {
private LoadTimeLine createPrincipal(Criterion criterion,
List<GenericResourceAllocation> orderedAllocations,
TimeLineRole<BaseEntity> role) {
return new LoadTimeLine(criterion.getName(), createPeriods(criterion,
orderedAllocations), "global-generic", role);
return new LoadTimeLine(criterion.getType().getName() + ": " + criterion.getName(),
createPeriods(criterion, orderedAllocations), "global-generic", role);
}
private List<LoadPeriod> createPeriods(Criterion criterion,