Calls to reassign wipe out the previous not consolidated assignments
This allows to delete the calls to reassign with zero effort. FEA: ItEr74S04BugFixing
This commit is contained in:
parent
ff54310d36
commit
0b97acc372
5 changed files with 55 additions and 55 deletions
|
|
@ -78,8 +78,25 @@ public interface IAllocatable extends IAllocateResourcesPerDay {
|
|||
public IAllocateEffortOnInterval onInterval(IntraDayDate start,
|
||||
IntraDayDate end);
|
||||
|
||||
/**
|
||||
* 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 endExclusive
|
||||
* @return
|
||||
*/
|
||||
public IAllocateEffortOnInterval fromStartUntil(LocalDate endExclusive);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* not consolidated day. All previous assignments are removed, but the
|
||||
* consolidated ones.
|
||||
*
|
||||
* @param endExclusive
|
||||
* @return
|
||||
*/
|
||||
public IAllocateEffortOnInterval fromEndUntil(LocalDate start);
|
||||
|
||||
}
|
||||
|
|
@ -920,14 +920,8 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
EffortDuration durationToAssign) {
|
||||
List<T> assignmentsCreated = createAssignments(interval,
|
||||
durationToAssign);
|
||||
allocateTheWholeAllocation(interval, assignmentsCreated);
|
||||
}
|
||||
|
||||
private void allocateTheWholeAllocation(AllocationInterval interval,
|
||||
List<T> assignments) {
|
||||
resetAllAllocationAssignmentsTo(assignments,
|
||||
interval.getStartInclusive(), interval.getEndExclusive());
|
||||
updateResourcesPerDay();
|
||||
ResourceAllocation.this.allocateTheWholeAllocation(interval,
|
||||
assignmentsCreated);
|
||||
}
|
||||
|
||||
protected abstract AvailabilityTimeLine getResourcesAvailability();
|
||||
|
|
@ -1059,6 +1053,13 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
task.getIntraDayEndDate());
|
||||
}
|
||||
|
||||
protected void allocateTheWholeAllocation(AllocationInterval interval,
|
||||
List<T> assignments) {
|
||||
resetAllAllocationAssignmentsTo(assignments,
|
||||
interval.getStartInclusive(), interval.getEndExclusive());
|
||||
updateResourcesPerDay();
|
||||
}
|
||||
|
||||
protected void resetAllAllocationAssignmentsTo(List<T> assignments,
|
||||
IntraDayDate intraDayStart,
|
||||
IntraDayDate intraDayEnd) {
|
||||
|
|
|
|||
|
|
@ -309,21 +309,18 @@ public class SpecificResourceAllocation extends
|
|||
}
|
||||
}
|
||||
|
||||
public void allocateKeepingProportions(LocalDate start,
|
||||
LocalDate endExclusive, EffortDuration effortForInterval) {
|
||||
AllocationIntervalInsideTask interval = new AllocationIntervalInsideTask(
|
||||
start, endExclusive);
|
||||
|
||||
EffortDuration sumConsolidated = DayAssignment
|
||||
.sum(interval
|
||||
.getConsolidatedAssignmentsOnInterval());
|
||||
|
||||
if (sumConsolidated.compareTo(effortForInterval) >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
EffortDuration pendingToReassign = effortForInterval
|
||||
.minus(sumConsolidated);
|
||||
/**
|
||||
* It does an allocation using the provided {@link EffortDuration} in the
|
||||
* not consolidated part in interval from the first day not consolidated to
|
||||
* the end provided. All previous not consolidated assignments are removed.
|
||||
*
|
||||
* @param effortForNotConsolidatedPart
|
||||
* @param endExclusive
|
||||
*/
|
||||
public void allocateWholeAllocationKeepingProportions(
|
||||
EffortDuration effortForNotConsolidatedPart, IntraDayDate end) {
|
||||
AllocationInterval interval = new AllocationInterval(
|
||||
getIntraDayStartDate(), end);
|
||||
|
||||
List<DayAssignment> nonConsolidatedAssignments = interval
|
||||
.getNoConsolidatedAssignmentsOnInterval();
|
||||
|
|
@ -331,9 +328,9 @@ public class SpecificResourceAllocation extends
|
|||
.create(asSeconds(nonConsolidatedAssignments));
|
||||
|
||||
EffortDuration[] effortsPerDay = asEfforts(distributor
|
||||
.distribute(pendingToReassign.getSeconds()));
|
||||
|
||||
resetAssigmentsForInterval(interval,
|
||||
.distribute(effortForNotConsolidatedPart.getSeconds()));
|
||||
allocateTheWholeAllocation(
|
||||
interval,
|
||||
assignmentsForEfforts(nonConsolidatedAssignments, effortsPerDay));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -782,11 +782,12 @@ public class SpecificResourceAllocationTest {
|
|||
assertThat(specificResourceAllocation.getAssignments(), haveHours(2, 4,
|
||||
8, 6));
|
||||
|
||||
specificResourceAllocation.allocateKeepingProportions(start,
|
||||
start.plusDays(2), EffortDuration.hours(9));
|
||||
specificResourceAllocation.allocateWholeAllocationKeepingProportions(
|
||||
EffortDuration.hours(18),
|
||||
IntraDayDate.startOfDay(start.plusDays(2)));
|
||||
|
||||
assertThat(specificResourceAllocation.getAssignments(), haveHours(3, 6,
|
||||
8, 6));
|
||||
assertThat(specificResourceAllocation.getAssignments(),
|
||||
haveHours(6, 12));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -232,22 +232,20 @@ public class AdvanceConsolidationModel implements IAdvanceConsolidationModel {
|
|||
task.setIntraDayEndDate(date.nextDayAtStart());
|
||||
}
|
||||
} else {
|
||||
reassign(resourceAllocation, task.getFirstDayNotConsolidated()
|
||||
.getDate(), endExclusive, pendingEffort);
|
||||
reassign(resourceAllocation, endExclusive, pendingEffort);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void reassign(ResourceAllocation<?> resourceAllocation,
|
||||
LocalDate startInclusive, LocalDate endExclusive,
|
||||
EffortDuration pendingEffort) {
|
||||
LocalDate endExclusive, EffortDuration pendingEffort) {
|
||||
if (resourceAllocation instanceof SpecificResourceAllocation) {
|
||||
((SpecificResourceAllocation) resourceAllocation)
|
||||
.allocateKeepingProportions(startInclusive, endExclusive,
|
||||
pendingEffort);
|
||||
.allocateWholeAllocationKeepingProportions(pendingEffort,
|
||||
IntraDayDate.startOfDay(endExclusive));
|
||||
} else {
|
||||
resourceAllocation.withPreviousAssociatedResources()
|
||||
.onIntervalWithinTask(startInclusive, endExclusive)
|
||||
.fromStartUntil(endExclusive)
|
||||
.allocate(pendingEffort);
|
||||
}
|
||||
}
|
||||
|
|
@ -281,11 +279,11 @@ public class AdvanceConsolidationModel implements IAdvanceConsolidationModel {
|
|||
return;
|
||||
}
|
||||
|
||||
LocalDate taskEndDate = LocalDate.fromDateFields(task.getEndDate());
|
||||
LocalDate endExclusive = taskEndDate;
|
||||
if (!consolidation.getConsolidatedValues().isEmpty()) {
|
||||
endExclusive = consolidation.getConsolidatedValues().last()
|
||||
LocalDate endExclusive = consolidation.getConsolidatedValues()
|
||||
.last()
|
||||
.getTaskEndDate();
|
||||
task.setEndDate(endExclusive.toDateTimeAtStartOfDay().toDate());
|
||||
}
|
||||
if (!consolidation.isCalculated()) {
|
||||
((NonCalculatedConsolidation) consolidation)
|
||||
|
|
@ -301,9 +299,6 @@ public class AdvanceConsolidationModel implements IAdvanceConsolidationModel {
|
|||
|
||||
task.updateAssignmentsConsolidatedValues();
|
||||
|
||||
LocalDate firstDayNotConsolidated = task.getFirstDayNotConsolidated()
|
||||
.getDate();
|
||||
|
||||
Set<ResourceAllocation<?>> allResourceAllocations = task
|
||||
.getAllResourceAllocations();
|
||||
for (ResourceAllocation<?> resourceAllocation : allResourceAllocations) {
|
||||
|
|
@ -312,18 +307,7 @@ public class AdvanceConsolidationModel implements IAdvanceConsolidationModel {
|
|||
EffortDuration pendingEffort = task.getConsolidation()
|
||||
.getNotConsolidated(
|
||||
resourceAllocation.getIntendedTotalAssigment());
|
||||
if (!taskEndDate.equals(endExclusive)) {
|
||||
if ((taskEndDate != null) && (endExclusive != null)
|
||||
&& (taskEndDate.compareTo(endExclusive) <= 0)) {
|
||||
reassign(resourceAllocation, taskEndDate, endExclusive,
|
||||
EffortDuration.zero());
|
||||
} else {
|
||||
reassign(resourceAllocation, endExclusive, taskEndDate,
|
||||
EffortDuration.zero());
|
||||
}
|
||||
task.setEndDate(endExclusive.toDateTimeAtStartOfDay().toDate());
|
||||
}
|
||||
reassign(resourceAllocation, firstDayNotConsolidated, endExclusive,
|
||||
reassign(resourceAllocation, task.getEndAsLocalDate(),
|
||||
pendingEffort);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue