ItEr58S18CUEscaladoPantallaCargaRecursosEmpresaItEr57S10: Completed the construction of the name filter combo in the model.
Now it also works when changing the filter to 'by criteria'.
This commit is contained in:
parent
6e6ad1b1e9
commit
6d8effca44
3 changed files with 54 additions and 14 deletions
|
|
@ -72,6 +72,8 @@ public interface IResourceLoadModel {
|
|||
|
||||
List<Resource> getAllResourcesList();
|
||||
|
||||
List<Criterion> getAllCriteriaList();
|
||||
|
||||
int getPageSize();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -341,22 +341,44 @@ public class ResourceLoadController implements Composer {
|
|||
Combobox filterByNameCombo = resourcesLoadPanel.getPaginationFilterCombobox();
|
||||
filterByNameCombo.getChildren().clear();
|
||||
List<Resource> resources = resourceLoadModel.getAllResourcesList();
|
||||
int size = resources.size();
|
||||
List<Criterion> criteria = resourceLoadModel.getAllCriteriaList();
|
||||
int size;
|
||||
if(currentFilterByResources) {
|
||||
size = resources.size();
|
||||
}
|
||||
else {
|
||||
size = criteria.size();
|
||||
}
|
||||
int pageSize = resourceLoadModel.getPageSize();
|
||||
|
||||
if(size > pageSize) {
|
||||
int position = 0;
|
||||
while(position < size) {
|
||||
String firstName = resources.get(position).getName();
|
||||
String firstName;
|
||||
String lastName;
|
||||
int newPosition = position + pageSize;
|
||||
if(newPosition - 1 < size) {
|
||||
lastName = resources.get(newPosition - 1)
|
||||
.getName();
|
||||
if(currentFilterByResources) {
|
||||
firstName = resources.get(position).getName();
|
||||
if(newPosition - 1 < size) {
|
||||
lastName = resources.get(newPosition - 1)
|
||||
.getName();
|
||||
}
|
||||
else {
|
||||
lastName = resources.get(size - 1)
|
||||
.getName();
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastName = resources.get(size - 1)
|
||||
.getName();
|
||||
Criterion criterion = criteria.get(position);
|
||||
firstName = criterion.getType().getName() + ": " + criterion.getName();
|
||||
if(newPosition - 1 < size) {
|
||||
criterion = criteria.get(newPosition - 1);
|
||||
lastName = criterion.getType().getName() + ": " + criterion.getName();
|
||||
}
|
||||
else {
|
||||
criterion = criteria.get(size - 1);
|
||||
lastName = criterion.getType().getName() + ": " + criterion.getName();
|
||||
}
|
||||
}
|
||||
|
||||
Comboitem item = new Comboitem();
|
||||
|
|
|
|||
|
|
@ -115,6 +115,10 @@ public class ResourceLoadModel implements IResourceLoadModel {
|
|||
*/
|
||||
private List<Resource> resourcesToShowList = new ArrayList<Resource>();
|
||||
|
||||
/**
|
||||
* Contains the criteria to be shown when specified manually using
|
||||
* the Bandbox
|
||||
*/
|
||||
private List<Criterion> criteriaToShowList = new ArrayList<Criterion>();
|
||||
|
||||
private Date initDateFilter;
|
||||
|
|
@ -136,6 +140,11 @@ public class ResourceLoadModel implements IResourceLoadModel {
|
|||
*/
|
||||
private List<Resource> allResourcesList;
|
||||
|
||||
/**
|
||||
* Contains all the resources which have to be filtered page by page
|
||||
*/
|
||||
List<Criterion> allCriteriaList;
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void initGlobalView(boolean filterByResources) {
|
||||
|
|
@ -215,7 +224,7 @@ public class ResourceLoadModel implements IResourceLoadModel {
|
|||
.findGenericAllocationsBySomeCriterion(criteriaToShowList, initDateFilter, endDateFilter);
|
||||
}
|
||||
if (filter()) {
|
||||
List<Criterion> criterions = new ArrayList<Criterion>();
|
||||
allCriteriaList = new ArrayList<Criterion>();
|
||||
List<GenericResourceAllocation> generics = new ArrayList<GenericResourceAllocation>();
|
||||
List<Task> tasks = justTasks(filterBy
|
||||
.getAllChildrenAssociatedTaskElements());
|
||||
|
|
@ -224,13 +233,17 @@ public class ResourceLoadModel implements IResourceLoadModel {
|
|||
List<ResourceAllocation<?>> listAllocations = new ArrayList<ResourceAllocation<?>>(
|
||||
task.getSatisfiedResourceAllocations());
|
||||
for (GenericResourceAllocation generic : (onlyGeneric(listAllocations))) {
|
||||
criterions.addAll(generic.getCriterions());
|
||||
allCriteriaList.addAll(generic.getCriterions());
|
||||
}
|
||||
}
|
||||
allCriteriaList = Criterion.sortByTypeAndName(allCriteriaList);
|
||||
return resourceAllocationDAO
|
||||
.findGenericAllocationsBySomeCriterion(criterions, initDateFilter, endDateFilter);
|
||||
.findGenericAllocationsBySomeCriterion(allCriteriaList, initDateFilter, endDateFilter);
|
||||
} else {
|
||||
return resourceAllocationDAO.findGenericAllocationsByCriterion(initDateFilter, endDateFilter);
|
||||
Map<Criterion, List<GenericResourceAllocation>> toReturn =
|
||||
resourceAllocationDAO.findGenericAllocationsByCriterion(initDateFilter, endDateFilter);
|
||||
allCriteriaList = Criterion.sortByTypeAndName(toReturn.keySet());
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -252,6 +265,11 @@ public class ResourceLoadModel implements IResourceLoadModel {
|
|||
return allResourcesList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Criterion> getAllCriteriaList() {
|
||||
return allCriteriaList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
|
|
@ -292,9 +310,7 @@ public class ResourceLoadModel implements IResourceLoadModel {
|
|||
private List<LoadTimeLine> groupsFor(
|
||||
Map<Criterion, List<GenericResourceAllocation>> genericAllocationsByCriterion) {
|
||||
List<LoadTimeLine> result = new ArrayList<LoadTimeLine>();
|
||||
List<Criterion> criterions = Criterion
|
||||
.sortByTypeAndName(genericAllocationsByCriterion.keySet());
|
||||
for (Criterion criterion : criterions) {
|
||||
for (Criterion criterion : allCriteriaList) {
|
||||
List<GenericResourceAllocation> allocations = ResourceAllocation
|
||||
.sortedByStartDate(genericAllocationsByCriterion
|
||||
.get(criterion));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue