From 24555f43cbe4a771927ce973f3cd00826cc4e66c Mon Sep 17 00:00:00 2001 From: Susana Montes Pedreira Date: Wed, 12 Jan 2011 19:42:27 +0100 Subject: [PATCH] [Bug #788] changes the structure and labels in resource load view. Changes in resources load is filtered by criteria: * second level tag: one row per generic resource allocation with the criteria names of the resource allocation. * third level tag: one row per workers of the resource allocation with the name of the workers. FEA : ItEr68S04BugFixing --- .../web/resourceload/ResourceLoadModel.java | 65 ++++++++++++------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/resourceload/ResourceLoadModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/resourceload/ResourceLoadModel.java index e1604bec6..43100ea12 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/resourceload/ResourceLoadModel.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/resourceload/ResourceLoadModel.java @@ -32,8 +32,8 @@ import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import org.joda.time.LocalDate; import org.navalplanner.business.calendars.daos.IBaseCalendarDAO; @@ -284,16 +284,20 @@ public class ResourceLoadModel implements IResourceLoadModel { private List getCriterionsOn(Collection tasks) { Set result = new LinkedHashSet(); for (Task eachTask : tasks) { - for (GenericResourceAllocation eachAllocation : onlyGeneric(eachTask - .getSatisfiedResourceAllocations())) { - for (Criterion eachCriterion : eachAllocation.getCriterions()) { - result.add(eachCriterion); - } - } + result.addAll(getCriterionsOn(eachTask)); } return new ArrayList(result); } + private Set getCriterionsOn(Task task) { + Set result = new LinkedHashSet(); + for (GenericResourceAllocation eachAllocation : onlyGeneric(task + .getSatisfiedResourceAllocations())) { + result.addAll(eachAllocation.getCriterions()); + } + return result; + } + private List resourcesToShow() { if(!resourcesToShowList.isEmpty()) { return getResourcesToShowReattached(); @@ -421,6 +425,7 @@ public class ResourceLoadModel implements IResourceLoadModel { Map>> byOrder = byOrder(new ArrayList>( allocations)); + // REVISAR ESTO ANTES DE ACABAR if (filter()) { // build time lines for current order if (byOrder.get(filterBy) != null) { @@ -486,26 +491,43 @@ public class ResourceLoadModel implements IResourceLoadModel { List secondLevel = new ArrayList(); for (Entry>> entry : byTask.entrySet()) { + Task task = entry.getKey(); - Set criterions = task.getCriterions(); - TimeLineRole role = getCurrentTimeLineRole(task); - /** - * Each resource line has the same role than its allocated task, so - * that link with the resource allocation screen - */ - LoadTimeLine timeLine = new LoadTimeLine(buildTimeLine(criterions, - task, criterion, "global-generic", entry.getValue(), role), - buildTimeLinesForEachResource(criterion, onlyGeneric(entry - .getValue()), role)); - if (!timeLine.isEmpty()) { - secondLevel.add(timeLine); + Map, List> mapSameCriteria = getAllocationsWithSameCriteria((entry + .getValue())); + for (Entry, List> entrySameCriteria : mapSameCriteria + .entrySet()) { + Set criterions = entrySameCriteria.getKey(); + List genericAllocations = entrySameCriteria + .getValue(); + List> resourceAllocations = new ArrayList>( + genericAllocations); + TimeLineRole role = getCurrentTimeLineRole(task); + + /** + * Each resource line has the same role than its allocated task, + * so that link with the resource allocation screen + */ + LoadTimeLine timeLine = new LoadTimeLine(buildTimeLine( + criterions, task, criterion, "global-generic", + resourceAllocations, role), + buildTimeLinesForEachResource(criterion, + genericAllocations, role)); + if (!timeLine.isEmpty()) { + secondLevel.add(timeLine); + } } - } return secondLevel; } + private Map, List> getAllocationsWithSameCriteria( + List> genericAllocations) { + return GenericResourceAllocation + .byCriterions(onlyGeneric(genericAllocations)); + } + private List buildTimeLinesForEachResource( Criterion criterion, List allocations, TimeLineRole role) { @@ -533,8 +555,7 @@ public class ResourceLoadModel implements IResourceLoadModel { private String getDescriptionResourceWithCriterions(Resource resource) { Set criterionSatisfactions = resource .getCriterionSatisfactions(); - return resource.getShortDescription() - + getCriterionSatisfactionDescription(criterionSatisfactions); + return resource.getShortDescription(); } private String getCriterionSatisfactionDescription(