diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/ResourceAllocation.java b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/ResourceAllocation.java index 87a7ddc91..7236e4f4f 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/ResourceAllocation.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/ResourceAllocation.java @@ -326,10 +326,12 @@ public abstract class ResourceAllocation extends ResourcesPerDay resourcesPerDay, List dayAssignments) { Task task = AllocationsSpecified.this.task; if (isForwardScheduling()) { - allocation.resetAssignmentsTo(dayAssignments, + allocation.resetAllAllocationAssignmentsTo( + dayAssignments, task.getIntraDayStartDate(), resultDate); } else { - allocation.resetAssignmentsTo(dayAssignments, + allocation.resetAllAllocationAssignmentsTo( + dayAssignments, resultDate, task.getIntraDayEndDate()); } allocation.updateResourcesPerDay(); @@ -668,7 +670,8 @@ public abstract class ResourceAllocation extends public void allocate(ResourcesPerDay resourcesPerDay) { List assignmentsCreated = createAssignments(resourcesPerDay, startInclusive, endExclusive); - resetAssignmentsTo(assignmentsCreated, startInclusive, + resetAllAllocationAssignmentsTo(assignmentsCreated, + startInclusive, endExclusive); updateResourcesPerDay(); } @@ -688,7 +691,7 @@ public abstract class ResourceAllocation extends } public void allocateHours(int hours) { - allocate(start, end, hours(hours)); + allocateSubintervalWithinTaskBounds(start, end, hours(hours)); } } @@ -704,7 +707,7 @@ public abstract class ResourceAllocation extends @Override public void allocateHours(int hours) { - allocate(getStartSpecifiedByTask(), + allocateTheWholeAllocation(getStartSpecifiedByTask(), IntraDayDate.startOfDay(end), hours(hours)); } }; @@ -716,23 +719,25 @@ public abstract class ResourceAllocation extends @Override public void allocateHours(int hours) { - allocate(IntraDayDate.startOfDay(start), + allocateTheWholeAllocation(IntraDayDate.startOfDay(start), task.getIntraDayEndDate(), hours(hours)); } }; } - private void allocate(IntraDayDate startInclusive, + private void allocateTheWholeAllocation(IntraDayDate startInclusive, IntraDayDate endExclusive, EffortDuration durationToAssign) { IntraDayDate afterConsolidated = getStartSpecifiedByTask(); List assignmentsCreated = createAssignments( IntraDayDate.max(afterConsolidated, startInclusive), endExclusive, durationToAssign); - resetAssignmentsTo(assignmentsCreated, startInclusive, endExclusive); + resetAllAllocationAssignmentsTo(assignmentsCreated, startInclusive, + endExclusive); updateResourcesPerDay(); } - private void allocate(LocalDate startInclusive, LocalDate endExclusive, + private void allocateSubintervalWithinTaskBounds( + LocalDate startInclusive, LocalDate endExclusive, EffortDuration durationToAssign) { IntervalInsideTask interval = new IntervalInsideTask( startInclusive, endExclusive); @@ -852,11 +857,12 @@ public abstract class ResourceAllocation extends protected abstract void copyAssignments(Scenario from, Scenario to); protected void resetAssignmentsTo(List assignments) { - resetAssignmentsTo(assignments, task.getIntraDayStartDate(), + resetAllAllocationAssignmentsTo(assignments, + task.getIntraDayStartDate(), task.getIntraDayEndDate()); } - protected void resetAssignmentsTo(List assignments, + protected void resetAllAllocationAssignmentsTo(List assignments, IntraDayDate intraDayStart, IntraDayDate intraDayEnd) { removingAssignments(withoutConsolidated(getAssignments()));