[Bug #1229] Look for new resources when moving a task
FEA: ItEr75S04BugFixing
This commit is contained in:
parent
4e9cd7cdc5
commit
af84f83c5f
3 changed files with 23 additions and 53 deletions
|
|
@ -465,56 +465,15 @@ public class Task extends TaskElement implements ITaskPositionConstrained {
|
|||
|
||||
}
|
||||
|
||||
private static abstract class AllocationModificationStrategy {
|
||||
private static class WithPotentiallyNewResources {
|
||||
|
||||
protected final IResourcesSearcher searcher;
|
||||
|
||||
public AllocationModificationStrategy(IResourcesSearcher searcher) {
|
||||
public WithPotentiallyNewResources(IResourcesSearcher searcher) {
|
||||
Validate.notNull(searcher);
|
||||
this.searcher = searcher;
|
||||
}
|
||||
|
||||
public abstract ModificationsResult<ResourcesPerDayModification> getResourcesPerDayModified(
|
||||
List<ResourceAllocation<?>> allocations);
|
||||
|
||||
public abstract ModificationsResult<EffortModification> getHoursModified(
|
||||
List<ResourceAllocation<?>> allocations);
|
||||
|
||||
}
|
||||
|
||||
private static class WithTheSameHoursAndResourcesPerDay extends
|
||||
AllocationModificationStrategy {
|
||||
|
||||
public WithTheSameHoursAndResourcesPerDay(IResourcesSearcher searcher) {
|
||||
super(searcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModificationsResult<EffortModification> getHoursModified(
|
||||
List<ResourceAllocation<?>> allocations) {
|
||||
List<EffortModification> canBeModified = EffortModification
|
||||
.fromExistent(allocations, searcher);
|
||||
return ModificationsResult.create(allocations, canBeModified);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModificationsResult<ResourcesPerDayModification> getResourcesPerDayModified(
|
||||
List<ResourceAllocation<?>> allocations) {
|
||||
List<ResourcesPerDayModification> canBeModified = ResourcesPerDayModification
|
||||
.fromExistent(allocations, searcher);
|
||||
return ModificationsResult.create(allocations, canBeModified);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class WithAnotherResources extends
|
||||
AllocationModificationStrategy {
|
||||
|
||||
public WithAnotherResources(IResourcesSearcher searcher) {
|
||||
super(searcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModificationsResult<EffortModification> getHoursModified(
|
||||
List<ResourceAllocation<?>> allocations) {
|
||||
List<EffortModification> canBeModified = EffortModification
|
||||
|
|
@ -522,13 +481,13 @@ public class Task extends TaskElement implements ITaskPositionConstrained {
|
|||
return ModificationsResult.create(allocations, canBeModified);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModificationsResult<ResourcesPerDayModification> getResourcesPerDayModified(
|
||||
List<ResourceAllocation<?>> allocations) {
|
||||
List<ResourcesPerDayModification> canBeModified = ResourcesPerDayModification
|
||||
.withNewResources(allocations, searcher);
|
||||
return ModificationsResult.create(allocations, canBeModified);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void copyAssignmentsFromOneScenarioToAnother(Scenario from, Scenario to) {
|
||||
|
|
@ -554,8 +513,8 @@ public class Task extends TaskElement implements ITaskPositionConstrained {
|
|||
}
|
||||
|
||||
private void doReassignment(Direction direction) {
|
||||
reassign(scenario, direction,
|
||||
new WithTheSameHoursAndResourcesPerDay(searcher));
|
||||
reassign(scenario, direction, new WithPotentiallyNewResources(
|
||||
searcher));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -753,12 +712,12 @@ public class Task extends TaskElement implements ITaskPositionConstrained {
|
|||
|
||||
public void reassignAllocationsWithNewResources(Scenario scenario,
|
||||
IResourcesSearcher searcher) {
|
||||
reassign(scenario, getAllocationDirection(), new WithAnotherResources(
|
||||
searcher));
|
||||
reassign(scenario, getAllocationDirection(),
|
||||
new WithPotentiallyNewResources(searcher));
|
||||
}
|
||||
|
||||
private void reassign(Scenario onScenario, Direction direction,
|
||||
AllocationModificationStrategy strategy) {
|
||||
WithPotentiallyNewResources strategy) {
|
||||
try {
|
||||
this.lastAllocationDirection = direction;
|
||||
if (isLimiting()) {
|
||||
|
|
@ -784,7 +743,7 @@ public class Task extends TaskElement implements ITaskPositionConstrained {
|
|||
}
|
||||
}
|
||||
|
||||
private void doAllocation(AllocationModificationStrategy strategy,
|
||||
private void doAllocation(WithPotentiallyNewResources strategy,
|
||||
Direction direction, List<ResourceAllocation<?>> toBeModified) {
|
||||
ModificationsResult<ResourcesPerDayModification> modificationsResult = strategy
|
||||
.getResourcesPerDayModified(toBeModified);
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ import org.libreplan.business.workingday.EffortDuration;
|
|||
import org.libreplan.business.workingday.EffortDuration.IEffortFrom;
|
||||
import org.libreplan.business.workingday.IntraDayDate;
|
||||
import org.libreplan.business.workingday.IntraDayDate.PartialDay;
|
||||
import org.libreplan.web.planner.order.PlanningStateCreator.PlanningState;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
|
@ -211,8 +212,8 @@ public class TaskElementAdapter {
|
|||
}
|
||||
|
||||
public IAdapterToTaskFundamentalProperties<TaskElement> createForOrder(
|
||||
Scenario currentScenario, Order order) {
|
||||
Adapter result = new Adapter();
|
||||
Scenario currentScenario, Order order, PlanningState planningState) {
|
||||
Adapter result = new Adapter(planningState);
|
||||
result.useScenario(currentScenario);
|
||||
result.setInitDate(asLocalDate(order.getInitDate()));
|
||||
result.setDeadline(asLocalDate(order.getDeadline()));
|
||||
|
|
@ -362,6 +363,8 @@ public class TaskElementAdapter {
|
|||
|
||||
private boolean preventCalculateResourcesText = false;
|
||||
|
||||
private final PlanningState planningState;
|
||||
|
||||
private void useScenario(Scenario scenario) {
|
||||
this.scenario = scenario;
|
||||
}
|
||||
|
|
@ -384,8 +387,12 @@ public class TaskElementAdapter {
|
|||
}
|
||||
|
||||
public Adapter() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public Adapter(PlanningState planningState) {
|
||||
this.planningState = planningState;
|
||||
}
|
||||
|
||||
private class TaskElementWrapper implements ITaskFundamentalProperties {
|
||||
|
||||
|
|
@ -493,6 +500,10 @@ public class TaskElementAdapter {
|
|||
|
||||
@Override
|
||||
public Void execute() {
|
||||
if (planningState != null) {
|
||||
planningState
|
||||
.reassociateResourcesWithSession();
|
||||
}
|
||||
modifications.doIt(position);
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -785,7 +785,7 @@ public class PlanningStateCreator {
|
|||
}
|
||||
IAdapterToTaskFundamentalProperties<TaskElement> adapter;
|
||||
adapter = taskElementAdapterCreator.createForOrder(
|
||||
getScenarioInfo().getCurrentScenario(), order);
|
||||
getScenarioInfo().getCurrentScenario(), order, this);
|
||||
|
||||
PlannerConfiguration<TaskElement> result = new PlannerConfiguration<TaskElement>(
|
||||
adapter, new TaskElementNavigator(), getInitial());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue