Refactor showSelectedAllocations
FEA: ItEr60S04ValidacionEProbasFuncionaisItEr59S04
This commit is contained in:
parent
fedfeeaeef
commit
6e9e8956d3
2 changed files with 30 additions and 18 deletions
|
|
@ -21,8 +21,10 @@
|
|||
package org.navalplanner.web.common.components;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.resources.entities.Criterion;
|
||||
import org.navalplanner.business.resources.entities.ResourceEnum;
|
||||
import org.navalplanner.business.resources.entities.Worker;
|
||||
import org.navalplanner.web.I18nHelper;
|
||||
import org.navalplanner.web.planner.allocation.INewAllocationsAdder;
|
||||
|
|
@ -55,6 +57,11 @@ public class NewAllocationSelector extends AllocationSelector {
|
|||
IResourceSearchModel resourceSearchModel) {
|
||||
return resourceSearchModel.searchWorkers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asCaption(List<Criterion> criterions) {
|
||||
return Criterion.getCaptionFor(ResourceEnum.WORKER, criterions);
|
||||
}
|
||||
},
|
||||
GENERIC_MACHINES(_("generic machines allocation")) {
|
||||
@Override
|
||||
|
|
@ -71,6 +78,12 @@ public class NewAllocationSelector extends AllocationSelector {
|
|||
IResourceSearchModel resourceSearchModel) {
|
||||
return resourceSearchModel.searchMachines();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asCaption(List<Criterion> criterions) {
|
||||
return Criterion
|
||||
.getCaptionFor(ResourceEnum.MACHINE, criterions);
|
||||
}
|
||||
},
|
||||
SPECIFIC(_("specific allocation")) {
|
||||
@Override
|
||||
|
|
@ -84,6 +97,11 @@ public class NewAllocationSelector extends AllocationSelector {
|
|||
IResourceSearchModel resourceSearchModel) {
|
||||
return resourceSearchModel.searchBoth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asCaption(List<Criterion> criterions) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -129,6 +147,8 @@ public class NewAllocationSelector extends AllocationSelector {
|
|||
|
||||
public abstract IResourcesQuery<?> doQueryOn(
|
||||
IResourceSearchModel resourceSearchModel);
|
||||
|
||||
public abstract String asCaption(List<Criterion> criterions);
|
||||
}
|
||||
|
||||
public NewAllocationSelectorController getController() {
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
package org.navalplanner.web.resources.search;
|
||||
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
|
|
@ -452,27 +450,21 @@ public class NewAllocationSelectorController extends
|
|||
}
|
||||
|
||||
public void showSelectedAllocations() {
|
||||
List<String> result = new ArrayList<String>();
|
||||
allocationSelectedItems.setValue(buildSelectedAllocationsString());
|
||||
}
|
||||
|
||||
private String buildSelectedAllocationsString() {
|
||||
|
||||
if (currentAllocationType == AllocationType.SPECIFIC) {
|
||||
for (Object each : listBoxResources.getSelectedItems()) {
|
||||
result.add(((Resource) ((Listitem) each).getValue())
|
||||
.getShortDescription());
|
||||
List<String> result = new ArrayList<String>();
|
||||
for (Resource each : getSelectedResourcesOnListbox()) {
|
||||
result.add(each.getShortDescription());
|
||||
}
|
||||
return StringUtils.join(result, ",");
|
||||
} else {
|
||||
for (Treeitem each : (Set<Treeitem>) criterionsTree
|
||||
.getSelectedItems()) {
|
||||
Object node = ((CriterionTreeNode) each.getValue()).getData();
|
||||
if (node instanceof Criterion) {
|
||||
result.add(((Criterion) node).getCompleteName());
|
||||
}
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
result.add(_("[generic all workers]"));
|
||||
}
|
||||
List<Criterion> criterions = getSelectedCriterions();
|
||||
return currentAllocationType.asCaption(criterions);
|
||||
}
|
||||
|
||||
allocationSelectedItems.setValue(StringUtils.join(result, ","));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue