Replaced method IResourceSearchModel.byLimiting(boolean) with .byResourceType(ResourceType).
A lot of dependent code had to be updated. FEA: ItEr66OTS04XestionRecursosEstratexicosItEr65OTS07
This commit is contained in:
parent
6d48769a46
commit
bc4c59e006
9 changed files with 42 additions and 33 deletions
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.navalplanner.web.common.components;
|
||||
|
||||
import org.navalplanner.business.resources.entities.ResourceType;
|
||||
import org.navalplanner.business.resources.entities.Worker;
|
||||
import org.navalplanner.web.planner.allocation.INewAllocationsAdder;
|
||||
import org.navalplanner.web.resources.search.AllocationSelectorController;
|
||||
|
|
@ -51,8 +52,8 @@ public abstract class AllocationSelector extends HtmlMacroComponent {
|
|||
}
|
||||
}
|
||||
|
||||
public void setLimitingResourceFilter(boolean limitingResource) {
|
||||
getController().setLimitingResourceFilter(limitingResource);
|
||||
public void setResourceTypeFilter(ResourceType type) {
|
||||
getController().setResourceTypeFilter(type);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import org.navalplanner.business.planner.entities.allocationalgorithms.Resources
|
|||
import org.navalplanner.business.resources.entities.Criterion;
|
||||
import org.navalplanner.business.resources.entities.Resource;
|
||||
import org.navalplanner.business.resources.entities.ResourceEnum;
|
||||
import org.navalplanner.business.resources.entities.ResourceType;
|
||||
import org.navalplanner.business.workingday.ResourcesPerDay;
|
||||
import org.navalplanner.web.resources.search.IResourceSearchModel;
|
||||
|
||||
|
|
@ -78,11 +79,15 @@ public class GenericAllocationRow extends AllocationRow {
|
|||
result.setNonConsolidatedResourcesPerDay(resourceAllocation
|
||||
.getNonConsolidatedResourcePerDay());
|
||||
|
||||
ResourceType type = resourceAllocation.isLimiting() ?
|
||||
ResourceType.LIMITING_RESOURCE :
|
||||
ResourceType.NON_LIMITING_RESOURCE;
|
||||
|
||||
result.criterions = resourceAllocation.getCriterions();
|
||||
result.resources = new ArrayList<Resource>(searchModel
|
||||
.searchBy(resourceAllocation.getResourceType())
|
||||
.byCriteria(resourceAllocation.getCriterions())
|
||||
.byLimiting(resourceAllocation.isLimiting()).execute());
|
||||
.byResourceType(type).execute());
|
||||
result.setName(Criterion
|
||||
.getCaptionForCriterionsFrom(resourceAllocation));
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import org.navalplanner.business.planner.entities.DerivedAllocation;
|
|||
import org.navalplanner.business.planner.entities.ResourceAllocation;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.business.resources.entities.ResourceEnum;
|
||||
import org.navalplanner.business.resources.entities.ResourceType;
|
||||
import org.navalplanner.web.I18nHelper;
|
||||
import org.navalplanner.web.common.IMessagesForUser;
|
||||
import org.navalplanner.web.common.Util;
|
||||
|
|
@ -150,8 +151,8 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
super.doAfterCompose(comp);
|
||||
allResourcesPerDay = new Decimalbox();
|
||||
allResourcesPerDay.setWidth("80px");
|
||||
newAllocationSelector.setLimitingResourceFilter(false);
|
||||
newAllocationSelectorCombo.setLimitingResourceFilter(false);
|
||||
newAllocationSelector.setResourceTypeFilter(ResourceType.NON_LIMITING_RESOURCE);
|
||||
newAllocationSelectorCombo.setResourceTypeFilter(ResourceType.NON_LIMITING_RESOURCE);
|
||||
newAllocationSelector.allowSelectMultipleResources(true);
|
||||
initAllocationLabels();
|
||||
makeReadyInputsForCalculationTypes();
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.navalplanner.business.planner.entities.ResourceAllocation;
|
||||
import org.navalplanner.business.resources.entities.ResourceType;
|
||||
import org.navalplanner.web.common.IMessagesForUser;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.navalplanner.web.common.components.AllocationSelector;
|
||||
|
|
@ -87,8 +88,8 @@ public class LimitingResourceAllocationController extends GenericForwardComposer
|
|||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
limitingNewAllocationSelector.setLimitingResourceFilter(true);
|
||||
limitingNewAllocationSelectorCombo.setLimitingResourceFilter(true);
|
||||
limitingNewAllocationSelector.setResourceTypeFilter(ResourceType.LIMITING_RESOURCE);
|
||||
limitingNewAllocationSelectorCombo.setResourceTypeFilter(ResourceType.LIMITING_RESOURCE);
|
||||
limitingNewAllocationSelector.allowSelectMultipleResources(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
|
||||
import org.navalplanner.business.resources.entities.Criterion;
|
||||
import org.navalplanner.business.resources.entities.Resource;
|
||||
import org.navalplanner.business.resources.entities.ResourceType;
|
||||
import org.navalplanner.web.planner.allocation.INewAllocationsAdder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
|
|
@ -38,7 +39,7 @@ public abstract class AllocationSelectorController extends
|
|||
@Autowired
|
||||
protected IResourceSearchModel resourceSearchModel;
|
||||
|
||||
protected boolean limitingResource = false;
|
||||
protected ResourceType type = ResourceType.NON_LIMITING_RESOURCE;
|
||||
|
||||
public AllocationSelectorController() {
|
||||
|
||||
|
|
@ -57,8 +58,8 @@ public abstract class AllocationSelectorController extends
|
|||
|
||||
public abstract void addTo(INewAllocationsAdder allocationsAdder);
|
||||
|
||||
public void setLimitingResourceFilter(boolean limitingResource) {
|
||||
this.limitingResource = limitingResource;
|
||||
public void setResourceTypeFilter(ResourceType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ import org.navalplanner.business.resources.entities.CriterionType;
|
|||
import org.navalplanner.business.resources.entities.Machine;
|
||||
import org.navalplanner.business.resources.entities.Resource;
|
||||
import org.navalplanner.business.resources.entities.ResourceEnum;
|
||||
import org.navalplanner.business.resources.entities.ResourceType;
|
||||
import org.navalplanner.business.resources.entities.Worker;
|
||||
|
||||
/**
|
||||
|
|
@ -60,13 +61,13 @@ public interface IResourceSearchModel {
|
|||
IResourcesQuery<T> byCriteria(Collection<? extends Criterion> criteria);
|
||||
|
||||
/**
|
||||
* Restrict resources to the ones having the provided limiting value. By
|
||||
* default, if this method is not called, the resources are restricted
|
||||
* to the ones not limiting.
|
||||
* @param limiting
|
||||
* Restrict resources to the ones having the provided type. By default
|
||||
* if this method is not called, the resources are restricted to the
|
||||
* type NON_LIMITING_RESOURCE.
|
||||
* @param type
|
||||
* @return this same object in order to cascade calls
|
||||
*/
|
||||
IResourcesQuery<T> byLimiting(boolean limiting);
|
||||
IResourcesQuery<T> byResourceType(ResourceType type);
|
||||
|
||||
/**
|
||||
* Retrieve the list of resources that match the restrictions specified.
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||
import org.navalplanner.business.resources.entities.Criterion;
|
||||
import org.navalplanner.business.resources.entities.Resource;
|
||||
import org.navalplanner.business.resources.entities.ResourceEnum;
|
||||
import org.navalplanner.business.resources.entities.ResourceType;
|
||||
import org.navalplanner.web.common.components.bandboxsearch.BandboxMultipleSearch;
|
||||
import org.navalplanner.web.common.components.finders.FilterPair;
|
||||
import org.navalplanner.web.common.components.finders.ResourceAllocationFilterEnum;
|
||||
|
|
@ -42,8 +43,6 @@ public class NewAllocationSelectorComboController extends
|
|||
|
||||
private BandboxMultipleSearch bdLimitingAllocationSelector;
|
||||
|
||||
private boolean limitingResource = false;
|
||||
|
||||
public NewAllocationSelectorComboController() {
|
||||
|
||||
}
|
||||
|
|
@ -60,7 +59,7 @@ public class NewAllocationSelectorComboController extends
|
|||
*/
|
||||
private List<? extends Resource> searchResources(List<Criterion> criterions) {
|
||||
return query(inferType(criterions)).byCriteria(criterions)
|
||||
.byLimiting(limitingResource).execute();
|
||||
.byResourceType(type).execute();
|
||||
}
|
||||
|
||||
private static ResourceEnum inferType(List<Criterion> criterions) {
|
||||
|
|
@ -138,17 +137,17 @@ public class NewAllocationSelectorComboController extends
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setLimitingResourceFilter(boolean limitingResource) {
|
||||
this.limitingResource = limitingResource;
|
||||
public void setResourceTypeFilter(ResourceType type) {
|
||||
super.setResourceTypeFilter(type);
|
||||
setResourceFinder();
|
||||
|
||||
}
|
||||
|
||||
private void setResourceFinder() {
|
||||
if (limitingResource) {
|
||||
if (type == ResourceType.LIMITING_RESOURCE) {
|
||||
bdLimitingAllocationSelector
|
||||
.setFinder("limitingResourceAllocationMultipleFiltersFinder");
|
||||
} else {
|
||||
} else if (type == ResourceType.NON_LIMITING_RESOURCE) {
|
||||
bdLimitingAllocationSelector
|
||||
.setFinder("nonLimitingResourceAllocationMultipleFiltersFinder");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ public class NewAllocationSelectorController extends
|
|||
}
|
||||
|
||||
private List<? extends Resource> getAllResources() {
|
||||
return query().byLimiting(limitingResource).execute();
|
||||
return query().byResourceType(type).execute();
|
||||
}
|
||||
|
||||
private IResourcesQuery<?> query() {
|
||||
|
|
@ -189,7 +189,7 @@ public class NewAllocationSelectorController extends
|
|||
List<Criterion> criteria = getSelectedCriterions();
|
||||
List<Resource> selectedWorkers = getSelectedWorkers();
|
||||
refreshListBoxResources(query().byCriteria(criteria)
|
||||
.byLimiting(limitingResource).execute());
|
||||
.byResourceType(type).execute());
|
||||
listBoxResources.renderAll(); // force render so list items has the
|
||||
// value property so the resources can be
|
||||
// selected
|
||||
|
|
@ -262,7 +262,7 @@ public class NewAllocationSelectorController extends
|
|||
private void searchResources(String name, List<Criterion> criterions) {
|
||||
final List<? extends Resource> resources = query().byName(name)
|
||||
.byCriteria(criterions)
|
||||
.byLimiting(limitingResource)
|
||||
.byResourceType(type)
|
||||
.execute();
|
||||
refreshListBoxResources(resources);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public class ResourceSearchModel implements IResourceSearchModel {
|
|||
|
||||
private List<Criterion> criteria = null;
|
||||
|
||||
private boolean limiting = false;
|
||||
private ResourceType type = ResourceType.NON_LIMITING_RESOURCE;
|
||||
|
||||
public Query(Class<T> klass) {
|
||||
this.klass = klass;
|
||||
|
|
@ -107,8 +107,8 @@ public class ResourceSearchModel implements IResourceSearchModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IResourcesQuery<T> byLimiting(boolean limiting) {
|
||||
this.limiting = limiting;
|
||||
public IResourcesQuery<T> byResourceType(ResourceType type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ public class ResourceSearchModel implements IResourceSearchModel {
|
|||
|
||||
private Criteria buildCriteria(Session session) {
|
||||
Criteria result = session.createCriteria(klass);
|
||||
result.add(eq("limitingResource", limiting));
|
||||
result.add(eq("resourceType", type));
|
||||
addQueryByName(result);
|
||||
addFindRelatedWithSomeOfTheCriterions(result);
|
||||
result.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
|
||||
|
|
@ -222,9 +222,9 @@ public class ResourceSearchModel implements IResourceSearchModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IResourcesQuery<Resource> byLimiting(boolean limiting) {
|
||||
searchWorkers.byLimiting(limiting);
|
||||
searchMachines.byLimiting(limiting);
|
||||
public IResourcesQuery<Resource> byResourceType(ResourceType type) {
|
||||
searchWorkers.byResourceType(type);
|
||||
searchMachines.byResourceType(type);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -271,4 +271,4 @@ public class ResourceSearchModel implements IResourceSearchModel {
|
|||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue