diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/IAllocatable.java b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/IAllocatable.java index 1c871c0b7..abf0edef1 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/IAllocatable.java +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/IAllocatable.java @@ -34,6 +34,10 @@ public interface IAllocatable extends IAllocateResourcesPerDay { public IAllocateResourcesPerDay resourcesPerDayFromEndUntil(LocalDate start); + public IAllocateResourcesPerDay resourcesPerDayUntil(IntraDayDate endExclusive); + + public IAllocateResourcesPerDay resourcesPerDayFromEndUntil(IntraDayDate start); + /** * @see IAllocatable#onIntervalWithinTask(IntraDayDate, IntraDayDate) */ diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/ResourceAllocation.java b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/ResourceAllocation.java index 1eb1c6f6d..59c139dea 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/ResourceAllocation.java +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/ResourceAllocation.java @@ -436,13 +436,13 @@ public abstract class ResourceAllocation extends allocator.allocateOnTaskLength(); } - public void allocateUntil(LocalDate endExclusive) { + public void allocateUntil(IntraDayDate endExclusive) { AllocatorForTaskDurationAndSpecifiedResourcesPerDay allocator = new AllocatorForTaskDurationAndSpecifiedResourcesPerDay( allocations); allocator.allocateUntil(endExclusive); } - public void allocateFromEndUntil(LocalDate start) { + public void allocateFromEndUntil(IntraDayDate start) { AllocatorForTaskDurationAndSpecifiedResourcesPerDay allocator = new AllocatorForTaskDurationAndSpecifiedResourcesPerDay( allocations); allocator.allocateFromEndUntil(start); @@ -775,16 +775,26 @@ public abstract class ResourceAllocation extends @Override public IAllocateResourcesPerDay resourcesPerDayUntil(final LocalDate endExclusive) { + return resourcesPerDayUntil(IntraDayDate.startOfDay(endExclusive)); + } + + @Override + public IAllocateResourcesPerDay resourcesPerDayUntil(IntraDayDate end) { IntraDayDate startInclusive = getStartSpecifiedByTask(); - IntraDayDate end = IntraDayDate.startOfDay(endExclusive); return new AllocateResourcesPerDayOnInterval(startInclusive, end); } @Override public IAllocateResourcesPerDay resourcesPerDayFromEndUntil( LocalDate start) { - IntraDayDate startInclusive = IntraDayDate.max( - IntraDayDate.startOfDay(start), getStartSpecifiedByTask()); + return resourcesPerDayFromEndUntil(IntraDayDate.startOfDay(start)); + } + + @Override + public IAllocateResourcesPerDay resourcesPerDayFromEndUntil( + IntraDayDate start) { + IntraDayDate startInclusive = IntraDayDate.max(start, + getStartSpecifiedByTask()); IntraDayDate endDate = task.getIntraDayEndDate(); return new AllocateResourcesPerDayOnInterval(startInclusive, endDate); diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/SpecificResourceAllocation.java b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/SpecificResourceAllocation.java index 3df3ed45f..0dd7bb2be 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/SpecificResourceAllocation.java +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/SpecificResourceAllocation.java @@ -176,6 +176,20 @@ public class SpecificResourceAllocation extends return allocator.resourcesPerDayFromEndUntil(start); } + @Override + public IAllocateResourcesPerDay resourcesPerDayUntil( + IntraDayDate endExclusive) { + return new SpecificAssignmentsAllocator() + .resourcesPerDayUntil(endExclusive); + } + + @Override + public IAllocateResourcesPerDay resourcesPerDayFromEndUntil( + IntraDayDate start) { + SpecificAssignmentsAllocator allocator = new SpecificAssignmentsAllocator(); + return allocator.resourcesPerDayFromEndUntil(start); + } + @Override public IAllocateEffortOnInterval fromStartUntil(LocalDate endExclusive) { return new SpecificAssignmentsAllocator().fromStartUntil(endExclusive); diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/allocationalgorithms/AllocatorForTaskDurationAndSpecifiedResourcesPerDay.java b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/allocationalgorithms/AllocatorForTaskDurationAndSpecifiedResourcesPerDay.java index a3a6f66ac..ef91685b0 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/allocationalgorithms/AllocatorForTaskDurationAndSpecifiedResourcesPerDay.java +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/allocationalgorithms/AllocatorForTaskDurationAndSpecifiedResourcesPerDay.java @@ -23,7 +23,7 @@ package org.libreplan.business.planner.entities.allocationalgorithms; import java.util.List; -import org.joda.time.LocalDate; +import org.libreplan.business.workingday.IntraDayDate; public class AllocatorForTaskDurationAndSpecifiedResourcesPerDay { @@ -40,13 +40,13 @@ public class AllocatorForTaskDurationAndSpecifiedResourcesPerDay { } } - public void allocateUntil(LocalDate endExclusive) { + public void allocateUntil(IntraDayDate endExclusive) { for (ResourcesPerDayModification allocation : allocations) { allocation.applyAllocationUntil(endExclusive); } } - public void allocateFromEndUntil(LocalDate start) { + public void allocateFromEndUntil(IntraDayDate start) { for (ResourcesPerDayModification allocation : allocations) { allocation.applyAllocationFromEndUntil(start); } diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/allocationalgorithms/ResourcesPerDayModification.java b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/allocationalgorithms/ResourcesPerDayModification.java index eb6e77eda..9ed8ab21e 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/allocationalgorithms/ResourcesPerDayModification.java +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/allocationalgorithms/ResourcesPerDayModification.java @@ -72,13 +72,13 @@ public abstract class ResourcesPerDayModification extends } @Override - public void applyAllocationUntil(LocalDate endExclusive) { + public void applyAllocationUntil(IntraDayDate endExclusive) { genericAllocation.forResources(getResources()) .resourcesPerDayUntil(endExclusive).allocate(getGoal()); } @Override - public void applyAllocationFromEndUntil(LocalDate start) { + public void applyAllocationFromEndUntil(IntraDayDate start) { genericAllocation.forResources(getResources()) .resourcesPerDayFromEndUntil(start).allocate(getGoal()); } @@ -153,13 +153,13 @@ public abstract class ResourcesPerDayModification extends } @Override - public void applyAllocationUntil(LocalDate endExclusive) { + public void applyAllocationUntil(IntraDayDate endExclusive) { resourceAllocation.resourcesPerDayUntil(endExclusive).allocate( getGoal()); } @Override - public void applyAllocationFromEndUntil(LocalDate start) { + public void applyAllocationFromEndUntil(IntraDayDate start) { resourceAllocation.resourcesPerDayFromEndUntil(start).allocate( getGoal()); } @@ -272,9 +272,9 @@ public abstract class ResourcesPerDayModification extends public abstract void applyAllocationOnAllTaskLength(); - public abstract void applyAllocationUntil(LocalDate endExclusive); + public abstract void applyAllocationUntil(IntraDayDate endExclusive); - public abstract void applyAllocationFromEndUntil(LocalDate start); + public abstract void applyAllocationFromEndUntil(IntraDayDate start); public IAssignmentsCreator createAssignmentsCreator() { diff --git a/libreplan-business/src/test/java/org/libreplan/business/test/planner/entities/GenericResourceAllocationTest.java b/libreplan-business/src/test/java/org/libreplan/business/test/planner/entities/GenericResourceAllocationTest.java index 780243ad1..fbf11042f 100644 --- a/libreplan-business/src/test/java/org/libreplan/business/test/planner/entities/GenericResourceAllocationTest.java +++ b/libreplan-business/src/test/java/org/libreplan/business/test/planner/entities/GenericResourceAllocationTest.java @@ -480,7 +480,8 @@ public class GenericResourceAllocationTest { ResourcesPerDay resourcesPerDay = ResourcesPerDay.amount(1); genericResourceAllocation.forResources(Arrays.asList(worker1)) - .resourcesPerDayUntil(null).allocate(resourcesPerDay); + .resourcesPerDayUntil((IntraDayDate) null) + .allocate(resourcesPerDay); } @Test diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AllocationRowsHandler.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AllocationRowsHandler.java index 5c67b320d..ed534013a 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AllocationRowsHandler.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AllocationRowsHandler.java @@ -298,10 +298,10 @@ public class AllocationRowsHandler { .createAndAssociate(task, currentRows, requestedToRemove); if (isForwardsAllocation()) { ResourceAllocation.allocating(allocations).allocateUntil( - formBinder.getAllocationEnd().asExclusiveEnd()); + formBinder.getAllocationEnd()); } else { ResourceAllocation.allocating(allocations).allocateFromEndUntil( - formBinder.getAllocationStart().getDate()); + formBinder.getAllocationStart()); } return allocations; }