Extract common functionality into methods
FEA: ItEr74S04BugFixing
This commit is contained in:
parent
0b97acc372
commit
71235e2c8e
1 changed files with 48 additions and 30 deletions
|
|
@ -25,6 +25,8 @@ import static org.navalplanner.web.I18nHelper._;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -211,29 +213,29 @@ public class AdvanceConsolidationModel implements IAdvanceConsolidationModel {
|
||||||
|
|
||||||
Set<ResourceAllocation<?>> allResourceAllocations = task
|
Set<ResourceAllocation<?>> allResourceAllocations = task
|
||||||
.getAllResourceAllocations();
|
.getAllResourceAllocations();
|
||||||
for (ResourceAllocation<?> resourceAllocation : allResourceAllocations) {
|
withDetachOnDayAssignmentRemoval(allResourceAllocations);
|
||||||
LocalDate endExclusive = LocalDate
|
|
||||||
.fromDateFields(task.getEndDate());
|
|
||||||
|
|
||||||
|
LocalDate endExclusive = LocalDate.fromDateFields(task.getEndDate());
|
||||||
|
if (value.getDate().compareTo(endExclusive.minusDays(1)) >= 0) {
|
||||||
|
reassignExpandingTask(allResourceAllocations);
|
||||||
|
} else {
|
||||||
|
reassignAll(endExclusive, allResourceAllocations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void withDetachOnDayAssignmentRemoval(
|
||||||
|
Collection<? extends ResourceAllocation<?>> allocations) {
|
||||||
|
for (ResourceAllocation<?> each : allocations) {
|
||||||
|
each.setOnDayAssignmentRemoval(new DetachDayAssignmentOnRemoval());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reassignAll(LocalDate endExclusive,
|
||||||
|
Collection<? extends ResourceAllocation<?>> allocations) {
|
||||||
|
for (ResourceAllocation<?> each : allocations) {
|
||||||
EffortDuration pendingEffort = consolidation
|
EffortDuration pendingEffort = consolidation
|
||||||
.getNotConsolidated(resourceAllocation
|
.getNotConsolidated(each.getIntendedTotalAssigment());
|
||||||
.getIntendedTotalAssigment());
|
reassign(each, endExclusive, pendingEffort);
|
||||||
|
|
||||||
resourceAllocation
|
|
||||||
.setOnDayAssignmentRemoval(new DetachDayAssignmentOnRemoval());
|
|
||||||
|
|
||||||
if (value.getDate().compareTo(endExclusive.minusDays(1)) >= 0) {
|
|
||||||
if (!AllocationsSpecified.isZero(resourceAllocation
|
|
||||||
.asResourcesPerDayModification().getGoal().getAmount())) {
|
|
||||||
IntraDayDate date = ResourceAllocation.allocating(
|
|
||||||
Arrays.asList(resourceAllocation
|
|
||||||
.asResourcesPerDayModification()))
|
|
||||||
.untilAllocating(pendingEffort);
|
|
||||||
task.setIntraDayEndDate(date.nextDayAtStart());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
reassign(resourceAllocation, endExclusive, pendingEffort);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,6 +252,28 @@ public class AdvanceConsolidationModel implements IAdvanceConsolidationModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reassignExpandingTask(
|
||||||
|
Collection<? extends ResourceAllocation<?>> allResourceAllocations) {
|
||||||
|
|
||||||
|
List<IntraDayDate> ends = new ArrayList<IntraDayDate>();
|
||||||
|
for (ResourceAllocation<?> resourceAllocation : allResourceAllocations) {
|
||||||
|
if (!AllocationsSpecified.isZero(resourceAllocation
|
||||||
|
.asResourcesPerDayModification().getGoal().getAmount())) {
|
||||||
|
EffortDuration pendingEffort = consolidation
|
||||||
|
.getNotConsolidated(resourceAllocation
|
||||||
|
.getIntendedTotalAssigment());
|
||||||
|
IntraDayDate date = ResourceAllocation.allocating(
|
||||||
|
Arrays.asList(resourceAllocation
|
||||||
|
.asResourcesPerDayModification()))
|
||||||
|
.untilAllocating(pendingEffort);
|
||||||
|
ends.add(date);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ends.isEmpty()) {
|
||||||
|
task.setIntraDayEndDate(Collections.max(ends));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private ConsolidatedValue createNewConsolidatedValue(
|
private ConsolidatedValue createNewConsolidatedValue(
|
||||||
AdvanceConsolidationDTO dto) {
|
AdvanceConsolidationDTO dto) {
|
||||||
if (consolidation != null && task != null) {
|
if (consolidation != null && task != null) {
|
||||||
|
|
@ -301,15 +325,9 @@ public class AdvanceConsolidationModel implements IAdvanceConsolidationModel {
|
||||||
|
|
||||||
Set<ResourceAllocation<?>> allResourceAllocations = task
|
Set<ResourceAllocation<?>> allResourceAllocations = task
|
||||||
.getAllResourceAllocations();
|
.getAllResourceAllocations();
|
||||||
for (ResourceAllocation<?> resourceAllocation : allResourceAllocations) {
|
withDetachOnDayAssignmentRemoval(allResourceAllocations);
|
||||||
resourceAllocation
|
|
||||||
.setOnDayAssignmentRemoval(new DetachDayAssignmentOnRemoval());
|
reassignAll(task.getEndAsLocalDate(), allResourceAllocations);
|
||||||
EffortDuration pendingEffort = task.getConsolidation()
|
|
||||||
.getNotConsolidated(
|
|
||||||
resourceAllocation.getIntendedTotalAssigment());
|
|
||||||
reassign(resourceAllocation, task.getEndAsLocalDate(),
|
|
||||||
pendingEffort);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateConsolidationInAdvanceIfIsNeeded() {
|
private void updateConsolidationInAdvanceIfIsNeeded() {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue