ItEr54S12CUVistaRecursosTempoPorProxectoItEr53S14: sorts the criterions by name in the resource load screen.
This commit is contained in:
parent
47477c594a
commit
1f2938ee96
2 changed files with 31 additions and 8 deletions
|
|
@ -21,9 +21,13 @@
|
|||
package org.navalplanner.business.resources.entities;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
|
@ -62,6 +66,24 @@ public class Criterion extends IntegrationEntity implements ICriterion {
|
|||
|
||||
}
|
||||
|
||||
public static List<Criterion> sortByName(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) {
|
||||
return 1;
|
||||
}
|
||||
if (o2.getName() == null) {
|
||||
return -1;
|
||||
}
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public void updateUnvalidated(String name, Boolean active) {
|
||||
|
||||
if (!StringUtils.isBlank(name)) {
|
||||
|
|
|
|||
|
|
@ -240,15 +240,16 @@ public class ResourceLoadModel implements IResourceLoadModel {
|
|||
private List<LoadTimeLine> groupsFor(
|
||||
Map<Criterion, List<GenericResourceAllocation>> genericAllocationsByCriterion) {
|
||||
List<LoadTimeLine> result = new ArrayList<LoadTimeLine>();
|
||||
for (Entry<Criterion, List<GenericResourceAllocation>> entry : genericAllocationsByCriterion
|
||||
.entrySet()) {
|
||||
List<Criterion> criterions = Criterion
|
||||
.sortByName(genericAllocationsByCriterion.keySet());
|
||||
for (Criterion criterion : criterions) {
|
||||
List<GenericResourceAllocation> allocations = ResourceAllocation
|
||||
.sortedByStartDate(entry.getValue());
|
||||
TimeLineRole<BaseEntity> role = getCurrentTimeLineRole(entry
|
||||
.getKey());
|
||||
LoadTimeLine group = new LoadTimeLine(createPrincipal(entry
|
||||
.getKey(), allocations,role), buildSecondLevel(entry.getKey(),
|
||||
allocations));
|
||||
.sortedByStartDate(genericAllocationsByCriterion
|
||||
.get(criterion));
|
||||
TimeLineRole<BaseEntity> role = getCurrentTimeLineRole(criterion);
|
||||
LoadTimeLine group = new LoadTimeLine(createPrincipal(criterion,
|
||||
allocations, role),
|
||||
buildSecondLevel(criterion, allocations));
|
||||
if (!group.isEmpty()) {
|
||||
result.add(group);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue