[Bug #1303] Fix issue adding consolidation using IntraDayDate for task end

FEA: ItEr75S04BugFixing
This commit is contained in:
Manuel Rego Casasnovas 2011-12-19 12:28:41 +01:00
parent e5173d6e49
commit bdcd45abaa
4 changed files with 37 additions and 10 deletions

View file

@ -88,6 +88,16 @@ public interface IAllocatable extends IAllocateResourcesPerDay {
*/
public IAllocateEffortOnInterval fromStartUntil(LocalDate endExclusive);
/**
* It allocates the effort specified on the interval from the start, i.e.
* first day not consolidated to the specified end. All previous assignments
* are removed, but the consolidated ones.
*
* @param end
* @return
*/
public IAllocateEffortOnInterval fromStartUntil(IntraDayDate end);
/**
* It allocates the effort specified on the interval from the end until the
* start. Being the start the maximum of the provided start and the first
@ -99,4 +109,4 @@ public interface IAllocatable extends IAllocateResourcesPerDay {
*/
public IAllocateEffortOnInterval fromEndUntil(LocalDate start);
}
}

View file

@ -862,6 +862,18 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
public IAllocateEffortOnInterval fromStartUntil(final LocalDate end) {
final AllocationInterval interval = new AllocationInterval(
getStartSpecifiedByTask(), IntraDayDate.startOfDay(end));
return getIAllocateEffortOnInterval(interval);
}
@Override
public IAllocateEffortOnInterval fromStartUntil(final IntraDayDate end) {
final AllocationInterval interval = new AllocationInterval(
getStartSpecifiedByTask(), end);
return getIAllocateEffortOnInterval(interval);
}
private IAllocateEffortOnInterval getIAllocateEffortOnInterval(
final AllocationInterval interval) {
return new IAllocateEffortOnInterval() {
@Override

View file

@ -181,6 +181,11 @@ public class SpecificResourceAllocation extends
return new SpecificAssignmentsAllocator().fromStartUntil(endExclusive);
}
@Override
public IAllocateEffortOnInterval fromStartUntil(IntraDayDate end) {
return new SpecificAssignmentsAllocator().fromStartUntil(end);
}
@Override
public IAllocateEffortOnInterval fromEndUntil(LocalDate start) {
return new SpecificAssignmentsAllocator().fromEndUntil(start);

View file

@ -215,11 +215,11 @@ public class AdvanceConsolidationModel implements IAdvanceConsolidationModel {
.getAllResourceAllocations();
withDetachOnDayAssignmentRemoval(allResourceAllocations);
LocalDate endExclusive = LocalDate.fromDateFields(task.getEndDate());
if (value.getDate().compareTo(endExclusive.minusDays(1)) >= 0) {
IntraDayDate end = task.getIntraDayEndDate();
if (value.getDate().compareTo(end.getDate().minusDays(1)) >= 0) {
reassignExpandingTask(allResourceAllocations);
} else {
reassignAll(endExclusive, allResourceAllocations);
reassignAll(end, allResourceAllocations);
}
}
@ -230,24 +230,24 @@ public class AdvanceConsolidationModel implements IAdvanceConsolidationModel {
}
}
private void reassignAll(LocalDate endExclusive,
private void reassignAll(IntraDayDate end,
Collection<? extends ResourceAllocation<?>> allocations) {
for (ResourceAllocation<?> each : allocations) {
EffortDuration pendingEffort = consolidation
.getNotConsolidated(each.getIntendedTotalAssigment());
reassign(each, endExclusive, pendingEffort);
reassign(each, end, pendingEffort);
}
}
private void reassign(ResourceAllocation<?> resourceAllocation,
LocalDate endExclusive, EffortDuration pendingEffort) {
IntraDayDate end, EffortDuration pendingEffort) {
if (resourceAllocation instanceof SpecificResourceAllocation) {
((SpecificResourceAllocation) resourceAllocation)
.allocateWholeAllocationKeepingProportions(pendingEffort,
IntraDayDate.startOfDay(endExclusive));
end);
} else {
resourceAllocation.withPreviousAssociatedResources()
.fromStartUntil(endExclusive)
.fromStartUntil(end)
.allocate(pendingEffort);
}
}
@ -327,7 +327,7 @@ public class AdvanceConsolidationModel implements IAdvanceConsolidationModel {
.getAllResourceAllocations();
withDetachOnDayAssignmentRemoval(allResourceAllocations);
reassignAll(task.getEndAsLocalDate(), allResourceAllocations);
reassignAll(task.getIntraDayEndDate(), allResourceAllocations);
}
private void updateConsolidationInAdvanceIfIsNeeded() {