ItEr27S06CUAsignacionGrupoRecursosAPlanificacionItEr26S07: When accepting the allocation ResourceAllocationsBeingEdited do the computation
This commit is contained in:
parent
79d01b14fe
commit
1810d92ae2
3 changed files with 18 additions and 17 deletions
|
|
@ -154,7 +154,11 @@ class FormBinder {
|
|||
}
|
||||
|
||||
public int getAssignedHours() {
|
||||
return assignedHoursComponent.getValue();
|
||||
Integer result = assignedHoursComponent.getValue();
|
||||
if (result == null) {
|
||||
throw new RuntimeException("assignedHoursComponent returns null");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setDeleteButtonFor(SpecificAllocationDTO data,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.orders.daos.IHoursGroupDAO;
|
||||
import org.navalplanner.business.orders.entities.HoursGroup;
|
||||
import org.navalplanner.business.planner.daos.IResourceAllocationDAO;
|
||||
|
|
@ -13,7 +12,6 @@ import org.navalplanner.business.planner.daos.ITaskElementDAO;
|
|||
import org.navalplanner.business.planner.entities.ResourceAllocation;
|
||||
import org.navalplanner.business.planner.entities.SpecificResourceAllocation;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.allocationalgorithms.ResourceAllocationWithDesiredResourcesPerDay;
|
||||
import org.navalplanner.business.resources.daos.IResourceDAO;
|
||||
import org.navalplanner.business.resources.entities.Criterion;
|
||||
import org.navalplanner.business.resources.entities.CriterionSatisfaction;
|
||||
|
|
@ -83,7 +81,7 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
public void save() {
|
||||
planningState.reassociateResourcesWithSession(resourceDAO);
|
||||
removeDeletedAllocations();
|
||||
mergeDTOsToTask();
|
||||
doTheAllocation();
|
||||
}
|
||||
|
||||
private void removeDeletedAllocations() {
|
||||
|
|
@ -94,19 +92,14 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
}
|
||||
}
|
||||
|
||||
private void mergeDTOsToTask() {
|
||||
ResourceAllocationsBeingEdited taskModifying = resourceAllocationsBeingEdited
|
||||
private void doTheAllocation() {
|
||||
ResourceAllocationsBeingEdited allocator = resourceAllocationsBeingEdited
|
||||
.taskModifying();
|
||||
List<ResourceAllocationWithDesiredResourcesPerDay> resourceAllocations = taskModifying
|
||||
.asResourceAllocations();
|
||||
if (task.isFixedDuration()) {
|
||||
ResourceAllocation.allocating(resourceAllocations).withResources(
|
||||
getResourcesMatchingCriterions()).allocateOnTaskLength();
|
||||
} else {
|
||||
LocalDate end = ResourceAllocation.allocating(resourceAllocations)
|
||||
.withResources(getResourcesMatchingCriterions())
|
||||
.untilAllocating(task.getHoursSpecifiedAtOrder());
|
||||
ganttTask.setEndDate(end.toDateTimeAtStartOfDay().toDate());
|
||||
allocator.doAllocation();
|
||||
Integer newDaysDuration = allocator.getDaysDuration();
|
||||
if (task.getDaysDuration() != newDaysDuration) {
|
||||
task.setDaysDuration(newDaysDuration);
|
||||
ganttTask.setEndDate(task.getEndDate());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ public class ResourceAllocationsBeingEdited {
|
|||
case NUMBER_OF_HOURS:
|
||||
ResourceAllocation.allocating(allocations).withResources(
|
||||
resourcesMatchingCriterions).allocateOnTaskLength();
|
||||
daysDuration = task.getDaysDuration();
|
||||
break;
|
||||
case END_DATE:
|
||||
LocalDate end = ResourceAllocation.allocating(allocations)
|
||||
|
|
@ -188,8 +189,11 @@ public class ResourceAllocationsBeingEdited {
|
|||
}
|
||||
|
||||
public ResourceAllocationsBeingEdited taskModifying() {
|
||||
return new ResourceAllocationsBeingEdited(task, currentAllocations,
|
||||
ResourceAllocationsBeingEdited result = new ResourceAllocationsBeingEdited(
|
||||
task, currentAllocations,
|
||||
resourceDAO, resourcesMatchingCriterions, true);
|
||||
result.formBinder = this.formBinder;
|
||||
return result;
|
||||
}
|
||||
|
||||
public FormBinder createFormBinder() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue