ItEr27S07CUVistaRecursosTempoPorProxectoItEr26S08: It checks before doing an allocation that there isn't just one empty generic resource allocation

This commit is contained in:
Óscar González Fernández 2009-09-28 19:27:30 +02:00
parent 2e057952c8
commit 320fe4a34f
2 changed files with 26 additions and 0 deletions

View file

@ -1,11 +1,14 @@
package org.navalplanner.web.planner.allocation;
import static org.navalplanner.web.I18nHelper._;
import java.util.HashMap;
import java.util.Map;
import org.navalplanner.business.planner.entities.AggregateOfResourceAllocations;
import org.navalplanner.business.planner.entities.CalculatedValue;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
@ -178,4 +181,12 @@ class FormBinder {
applyButton.setDisabled(false);
}
public void markGenericAllocationMustBeNoZeroOrMoreAllocations(
AllocationDTO allocation) {
Decimalbox decimalbox = resourcesPerDayInputsByAllocationDTO
.get(allocation);
throw new WrongValueException(decimalbox,
_("it must be no zero or must add more allocations"));
}
}

View file

@ -119,7 +119,22 @@ public class ResourceAllocationsBeingEdited {
return result;
}
public void checkInvalidValues() {
if (thereIsJustOneEmptyGenericResourceAllocation()) {
formBinder
.markGenericAllocationMustBeNoZeroOrMoreAllocations(currentAllocations
.get(0));
}
}
private boolean thereIsJustOneEmptyGenericResourceAllocation() {
return currentAllocations.size() == 1
&& currentAllocations.get(0).isGeneric()
&& currentAllocations.get(0).isEmptyResourcesPerDay();
}
public AggregateOfResourceAllocations doAllocation() {
checkInvalidValues();
List<ResourceAllocationWithDesiredResourcesPerDay> allocations = asResourceAllocations();
switch (calculatedValue) {
case NUMBER_OF_HOURS: