ItEr27S07CUVistaRecursosTempoPorProxectoItEr26S08: Checking there are workers matched by criterion at allocation

This commit is contained in:
Óscar González Fernández 2009-09-30 12:08:45 +02:00
parent 7ae8c6b75d
commit 481707ee17
2 changed files with 28 additions and 4 deletions

View file

@ -212,6 +212,14 @@ class FormBinder {
_("at least one no empty allocation is needed"));
}
public void markNoWorkersMatchedByCriterion(GenericAllocationDTO generic) {
Decimalbox decimalbox = resourcesPerDayInputsByAllocationDTO
.get(generic);
throw new WrongValueException(
decimalbox,
_("there are no workers for required criterions. So the generic allocation can't be done"));
}
public void setAllocationsList(Listbox allocationsList) {
this.allocationsList = allocationsList;
}

View file

@ -120,10 +120,13 @@ public class ResourceAllocationsBeingEdited {
}
public void checkInvalidValues() {
if (thereIsNoEmptyGenericResourceAllocation()
&& noWorkersForCriterion()) {
formBinder.markNoWorkersMatchedByCriterion(getGenericAllocation());
}
if (thereIsJustOneEmptyGenericResourceAllocation()) {
formBinder
.markGenericAllocationMustBeNoZeroOrMoreAllocations(currentAllocations
.get(0));
.markGenericAllocationMustBeNoZeroOrMoreAllocations(getGenericAllocation());
}
if (formBinder.getCalculatedValue() != CalculatedValue.NUMBER_OF_HOURS
&& formBinder.getAssignedHours() == 0) {
@ -134,6 +137,19 @@ public class ResourceAllocationsBeingEdited {
}
}
private boolean noWorkersForCriterion() {
return resourcesMatchingCriterions.isEmpty();
}
private boolean thereIsNoEmptyGenericResourceAllocation() {
return !getGenericAllocation().isEmptyResourcesPerDay();
}
private GenericAllocationDTO getGenericAllocation() {
return (GenericAllocationDTO) currentAllocations
.get(0);
}
private boolean thereIsLeastOneNoEmptyAllocation() {
for (AllocationDTO allocationDTO : currentAllocations) {
if (!allocationDTO.isEmptyResourcesPerDay()) {
@ -145,8 +161,8 @@ public class ResourceAllocationsBeingEdited {
private boolean thereIsJustOneEmptyGenericResourceAllocation() {
return currentAllocations.size() == 1
&& currentAllocations.get(0).isGeneric()
&& currentAllocations.get(0).isEmptyResourcesPerDay();
&& getGenericAllocation().isGeneric()
&& getGenericAllocation().isEmptyResourcesPerDay();
}
public AggregateOfResourceAllocations doAllocation() {