Bug #1428: Take into account the load of the other allocations when reassigning
For example when moving a task the bug #1428 could happen.
This commit is contained in:
parent
7afcef6525
commit
c52aedb4b6
1 changed files with 31 additions and 1 deletions
|
|
@ -50,6 +50,8 @@ import org.libreplan.business.orders.entities.HoursGroup;
|
|||
import org.libreplan.business.orders.entities.OrderElement;
|
||||
import org.libreplan.business.orders.entities.SumChargedEffort;
|
||||
import org.libreplan.business.orders.entities.TaskSource;
|
||||
import org.libreplan.business.planner.entities.AssignedEffortForResource.IAssignedEffortForResource;
|
||||
import org.libreplan.business.planner.entities.AssignedEffortForResource.WithTheLoadOf;
|
||||
import org.libreplan.business.planner.entities.DayAssignment.FilterType;
|
||||
import org.libreplan.business.planner.entities.Dependency.Type;
|
||||
import org.libreplan.business.planner.entities.DerivedAllocationGenerator.IWorkerFinder;
|
||||
|
|
@ -365,7 +367,7 @@ public class Task extends TaskElement implements ITaskPositionConstrained {
|
|||
}
|
||||
|
||||
public static List<ResourceAllocation<?>> modified(
|
||||
Collection<ModifiedAllocation> collection) {
|
||||
Collection<? extends ModifiedAllocation> collection) {
|
||||
List<ResourceAllocation<?>> result = new ArrayList<ResourceAllocation<?>>();
|
||||
for (ModifiedAllocation modifiedAllocation : collection) {
|
||||
result.add(modifiedAllocation.getModification());
|
||||
|
|
@ -373,6 +375,15 @@ public class Task extends TaskElement implements ITaskPositionConstrained {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static List<ResourceAllocation<?>> originals(
|
||||
Collection<? extends ModifiedAllocation> modifiedAllocations) {
|
||||
List<ResourceAllocation<?>> result = new ArrayList<ResourceAllocation<?>>();
|
||||
for (ModifiedAllocation each : modifiedAllocations) {
|
||||
result.add(each.getOriginal());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private final ResourceAllocation<?> original;
|
||||
|
||||
private final ResourceAllocation<?> modification;
|
||||
|
|
@ -741,6 +752,7 @@ public class Task extends TaskElement implements ITaskPositionConstrained {
|
|||
if (toBeModified.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
setCustomAssignedEffortForResource(copied);
|
||||
doAllocation(strategy, direction, toBeModified);
|
||||
updateDerived(copied);
|
||||
|
||||
|
|
@ -754,6 +766,24 @@ public class Task extends TaskElement implements ITaskPositionConstrained {
|
|||
}
|
||||
}
|
||||
|
||||
private void setCustomAssignedEffortForResource(
|
||||
List<ModifiedAllocation> modifiedAllocations) {
|
||||
List<ResourceAllocation<?>> originals = ModifiedAllocation
|
||||
.originals(modifiedAllocations);
|
||||
IAssignedEffortForResource discounting = AssignedEffortForResource
|
||||
.effortDiscounting(originals);
|
||||
List<ResourceAllocation<?>> beingModified = ModifiedAllocation
|
||||
.modified(modifiedAllocations);
|
||||
WithTheLoadOf allNewLoad = AssignedEffortForResource
|
||||
.withTheLoadOf(beingModified);
|
||||
List<GenericResourceAllocation> generic = ResourceAllocation.getOfType(
|
||||
GenericResourceAllocation.class, beingModified);
|
||||
for (GenericResourceAllocation each : generic) {
|
||||
each.customAssignedEffortForResource(AssignedEffortForResource.sum(
|
||||
allNewLoad.withoutConsidering(each), discounting));
|
||||
}
|
||||
}
|
||||
|
||||
private void doAllocation(WithPotentiallyNewResources strategy,
|
||||
Direction direction, List<ResourceAllocation<?>> toBeModified) {
|
||||
ModificationsResult<ResourcesPerDayModification> modificationsResult = strategy
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue