From 88bbc256e257ba08768b180175a7b38d9ff7ace9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Wed, 5 Oct 2011 13:37:58 +0200 Subject: [PATCH] Look for new resources when moving a task FEA: ItEr75S04BugFixing --- .../business/planner/entities/Task.java | 59 +++---------------- 1 file changed, 9 insertions(+), 50 deletions(-) diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/Task.java b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/Task.java index 950b966fc..71bc91f4c 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/Task.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/Task.java @@ -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 getResourcesPerDayModified( - List> allocations); - - public abstract ModificationsResult getHoursModified( - List> allocations); - - } - - private static class WithTheSameHoursAndResourcesPerDay extends - AllocationModificationStrategy { - - public WithTheSameHoursAndResourcesPerDay(IResourcesSearcher searcher) { - super(searcher); - } - - @Override - public ModificationsResult getHoursModified( - List> allocations) { - List canBeModified = EffortModification - .fromExistent(allocations, searcher); - return ModificationsResult.create(allocations, canBeModified); - } - - @Override - public ModificationsResult getResourcesPerDayModified( - List> allocations) { - List 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 getHoursModified( List> allocations) { List canBeModified = EffortModification @@ -522,13 +481,13 @@ public class Task extends TaskElement implements ITaskPositionConstrained { return ModificationsResult.create(allocations, canBeModified); } - @Override public ModificationsResult getResourcesPerDayModified( List> allocations) { List 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> toBeModified) { ModificationsResult modificationsResult = strategy .getResourcesPerDayModified(toBeModified);