ItEr29S06CUAsignacionGrupoRecursosAPlanificacionItEr28S06: doAllocation returns a result grouping two result items
This commit is contained in:
parent
0ada1d347d
commit
abd2d81f02
3 changed files with 32 additions and 5 deletions
|
|
@ -162,7 +162,8 @@ class FormBinder {
|
|||
}
|
||||
|
||||
private void doApply() {
|
||||
aggregate = resourceAllocationsBeingEdited.doAllocation();
|
||||
aggregate = resourceAllocationsBeingEdited.doAllocation()
|
||||
.getAggregate();
|
||||
reloadValues();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,8 +119,8 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
private void doTheAllocation() {
|
||||
ResourceAllocationsBeingEdited allocator = resourceAllocationsBeingEdited
|
||||
.taskModifying();
|
||||
allocator.doAllocation();
|
||||
Integer newDaysDuration = allocator.getDaysDuration();
|
||||
AllocationResult allocationResult = allocator.doAllocation();
|
||||
Integer newDaysDuration = allocationResult.getDaysDuration();
|
||||
if (task.getDaysDuration() != newDaysDuration) {
|
||||
task.setDaysDuration(newDaysDuration);
|
||||
ganttTask.setEndDate(task.getEndDate());
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.joda.time.Days;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.planner.entities.AggregateOfResourceAllocations;
|
||||
|
|
@ -185,7 +186,7 @@ public class ResourceAllocationsBeingEdited {
|
|||
&& getGenericAllocation().isEmptyResourcesPerDay();
|
||||
}
|
||||
|
||||
public AggregateOfResourceAllocations doAllocation() {
|
||||
public AllocationResult doAllocation() {
|
||||
checkInvalidValues();
|
||||
List<ResourceAllocationWithDesiredResourcesPerDay> allocations = asResourceAllocations();
|
||||
switch (calculatedValue) {
|
||||
|
|
@ -203,7 +204,8 @@ public class ResourceAllocationsBeingEdited {
|
|||
default:
|
||||
throw new RuntimeException("cant handle: " + calculatedValue);
|
||||
}
|
||||
return new AggregateOfResourceAllocations(stripResourcesPerDay(allocations));
|
||||
return new AllocationResult(new AggregateOfResourceAllocations(
|
||||
stripResourcesPerDay(allocations)), daysDuration);
|
||||
}
|
||||
|
||||
private Integer from(Date startDate, LocalDate end) {
|
||||
|
|
@ -301,3 +303,27 @@ public class ResourceAllocationsBeingEdited {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class AllocationResult {
|
||||
|
||||
private final AggregateOfResourceAllocations aggregate;
|
||||
|
||||
private final Integer daysDuration;
|
||||
|
||||
AllocationResult(AggregateOfResourceAllocations aggregate,
|
||||
Integer daysDuration) {
|
||||
Validate.notNull(daysDuration);
|
||||
Validate.notNull(daysDuration);
|
||||
this.aggregate = aggregate;
|
||||
this.daysDuration = daysDuration;
|
||||
}
|
||||
|
||||
public AggregateOfResourceAllocations getAggregate() {
|
||||
return aggregate;
|
||||
}
|
||||
|
||||
public Integer getDaysDuration() {
|
||||
return daysDuration;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue