ItEr60S04ValidacionEProbasFuncionaisItEr59S04: [Bug #532] Fix bug, retrieve correctly the DayAssignments from the selected Criteria when in 'filter by criteria' mode.

This commit is contained in:
Jacobo Aragunde Pérez 2010-06-17 10:52:48 +02:00 committed by Javier Moran Rua
parent 3971221313
commit f1bfed4b51

View file

@ -220,11 +220,15 @@ public class ResourceLoadModel implements IResourceLoadModel {
if (filterByResources) {
result.addAll(groupsFor(resourcesToShow()));
} else {
result.addAll(groupsFor(genericAllocationsByCriterion()));
calculatedGenericAllocationsByCriterion =
genericAllocationsByCriterion();
result.addAll(groupsFor(calculatedGenericAllocationsByCriterion));
}
return result;
}
Map<Criterion, List<GenericResourceAllocation>> calculatedGenericAllocationsByCriterion;
private Map<Criterion, List<GenericResourceAllocation>> genericAllocationsByCriterion() {
if (!criteriaToShowList.isEmpty()) {
reattachCriteriaToShow();
@ -856,8 +860,22 @@ public class ResourceLoadModel implements IResourceLoadModel {
@Transactional(readOnly = true)
public List<DayAssignment> getDayAssignments() {
return dayAssignmentDAO.findByResources(scenarioManager.getCurrent(),
getResources());
if(filterByResources) {
return dayAssignmentDAO.findByResources(scenarioManager.getCurrent(),
getResources());
}
else {
List<DayAssignment> dayAssignments = new ArrayList<DayAssignment>();
for(Entry<Criterion, List<GenericResourceAllocation>> entry :
calculatedGenericAllocationsByCriterion.entrySet()) {
for(GenericResourceAllocation allocation : entry.getValue()) {
dayAssignments.addAll(allocation.getAssignments());
}
}
return dayAssignments;
}
}
@Override