ItEr58S17AsignacionConsolidacion: Keeping consolidated day assignments when reassing.
This commit is contained in:
parent
c89672c6d1
commit
689181203e
8 changed files with 49 additions and 13 deletions
|
|
@ -49,6 +49,7 @@ public class GenericDayAssignment extends DayAssignment {
|
|||
for (GenericDayAssignment a : assignemnts) {
|
||||
GenericDayAssignment created = create(a.getDay(), a.getHours(), a
|
||||
.getResource());
|
||||
created.setConsolidated(a.isConsolidated());
|
||||
created.setGenericResourceAllocation(newAllocation);
|
||||
created.associateToResource();
|
||||
result.add(created);
|
||||
|
|
|
|||
|
|
@ -380,4 +380,12 @@ public class GenericResourceAllocation extends
|
|||
return result;
|
||||
}
|
||||
|
||||
public void overrideConsolidatedDayAssignments(
|
||||
GenericResourceAllocation origin) {
|
||||
if (origin != null) {
|
||||
this.genericDayAssignments = GenericDayAssignment.copy(this, origin
|
||||
.getConsolidatedAssignments());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,11 +22,13 @@ package org.navalplanner.business.planner.entities;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
|
@ -423,14 +425,14 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
@Override
|
||||
public void allocate(ResourcesPerDay resourcesPerDay) {
|
||||
Task currentTask = getTask();
|
||||
LocalDate startInclusive = new LocalDate(currentTask
|
||||
.getStartDate());
|
||||
LocalDate startInclusive = currentTask
|
||||
.getFirstDayNotConsolidated();
|
||||
List<T> assignmentsCreated = createAssignments(
|
||||
resourcesPerDay, startInclusive,
|
||||
endExclusive);
|
||||
resourcesPerDay, startInclusive, endExclusive);
|
||||
resetAssignmentsTo(assignmentsCreated);
|
||||
setResourcesPerDay(calculateResourcesPerDayFromAssignments(getAssignments()));
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -485,7 +487,7 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
}
|
||||
|
||||
private void allocate(LocalDate end, int hours) {
|
||||
LocalDate startInclusive = new LocalDate(getTask().getStartDate());
|
||||
LocalDate startInclusive = getTask().getFirstDayNotConsolidated();
|
||||
List<T> assignmentsCreated = createAssignments(startInclusive, end,
|
||||
hours);
|
||||
resetAssignmentsTo(assignmentsCreated);
|
||||
|
|
@ -494,10 +496,10 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
|
||||
private void allocate(LocalDate startInclusive, LocalDate endExclusive,
|
||||
int hours) {
|
||||
List<T> assignmentsCreated = createAssignments(startInclusive,
|
||||
endExclusive, hours);
|
||||
resetAssigmentsForInterval(startInclusive, endExclusive,
|
||||
assignmentsCreated);
|
||||
LocalDate start = Collections.max(Arrays.asList(startInclusive,
|
||||
getTask().getFirstDayNotConsolidated()));
|
||||
List<T> assignmentsCreated = createAssignments(start, endExclusive, hours);
|
||||
resetAssigmentsForInterval(start, endExclusive, assignmentsCreated);
|
||||
}
|
||||
|
||||
protected abstract AvailabilityTimeLine getResourcesAvailability();
|
||||
|
|
@ -595,19 +597,32 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
}
|
||||
|
||||
private void resetAssignmentsTo(List<T> assignments) {
|
||||
removingAssignments(getAssignments());
|
||||
removingAssignments((List<? extends DayAssignment>) removeConsolidated(getAssignments()));
|
||||
addingAssignments(assignments);
|
||||
setOriginalTotalAssigment(getAssignedHours());
|
||||
}
|
||||
|
||||
protected void resetAssigmentsForInterval(LocalDate startInclusive,
|
||||
LocalDate endExclusive, List<T> assignmentsCreated) {
|
||||
removingAssignments(getAssignments(startInclusive, endExclusive));
|
||||
removingAssignments(removeConsolidated(getAssignments(startInclusive,
|
||||
endExclusive)));
|
||||
addingAssignments(assignmentsCreated);
|
||||
setResourcesPerDay(calculateResourcesPerDayFromAssignments(getAssignments()));
|
||||
setOriginalTotalAssigment(getAssignedHours());
|
||||
}
|
||||
|
||||
private List<? extends DayAssignment> removeConsolidated(
|
||||
List<? extends DayAssignment> assignments) {
|
||||
for (Iterator<? extends DayAssignment> iterator = assignments
|
||||
.iterator(); iterator.hasNext();) {
|
||||
DayAssignment dayAssignment = (DayAssignment) iterator.next();
|
||||
if (dayAssignment.isConsolidated()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return assignments;
|
||||
}
|
||||
|
||||
public void removeLimitingDayAssignments() {
|
||||
allocateLimitingDayAssignments(Collections.<T>emptyList());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class SpecificDayAssignment extends DayAssignment {
|
|||
for (SpecificDayAssignment s : specificDaysAssignment) {
|
||||
SpecificDayAssignment created = create(s.getDay(), s.getHours(), s
|
||||
.getResource());
|
||||
created.setConsolidated(s.isConsolidated());
|
||||
created.setSpecificResourceAllocation(allocation);
|
||||
created.associateToResource();
|
||||
result.add(created);
|
||||
|
|
|
|||
|
|
@ -305,4 +305,12 @@ public class SpecificResourceAllocation extends
|
|||
return result;
|
||||
}
|
||||
|
||||
public void overrideConsolidatedDayAssignments(
|
||||
SpecificResourceAllocation origin) {
|
||||
if (origin != null) {
|
||||
this.specificDaysAssignment = SpecificDayAssignment.copy(this,
|
||||
origin.getConsolidatedAssignments());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public abstract class AllocatorForSpecifiedResourcesPerDayAndHours {
|
|||
}
|
||||
|
||||
public LocalDate untilAllocating(int hoursToAllocate) {
|
||||
LocalDate start = LocalDate.fromDateFields(task.getStartDate());
|
||||
LocalDate start = task.getFirstDayNotConsolidated();
|
||||
int i = 0;
|
||||
int maxDaysElapsed = 0;
|
||||
for (HoursPerAllocation each : hoursPerAllocation(start,
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import org.navalplanner.business.planner.entities.allocationalgorithms.Resources
|
|||
import org.navalplanner.business.resources.daos.IResourceDAO;
|
||||
import org.navalplanner.business.resources.entities.Criterion;
|
||||
import org.navalplanner.business.resources.entities.Resource;
|
||||
import org.navalplanner.web.resourceload.ResourceLoadModel;
|
||||
|
||||
/**
|
||||
* The information required for creating a {@link GenericResourceAllocation}
|
||||
|
|
@ -118,6 +117,7 @@ public class GenericAllocationRow extends AllocationRow {
|
|||
GenericResourceAllocation origin = (GenericResourceAllocation) getOrigin();
|
||||
if (origin != null) {
|
||||
result.overrideAssignedHoursForResource(origin);
|
||||
result.overrideConsolidatedDayAssignments(origin);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -136,4 +136,5 @@ public class GenericAllocationRow extends AllocationRow {
|
|||
public List<Resource> getAssociatedResources() {
|
||||
return resources;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,6 +121,8 @@ public class SpecificAllocationRow extends AllocationRow {
|
|||
SpecificResourceAllocation specific = SpecificResourceAllocation
|
||||
.create(task);
|
||||
specific.setResource(resource);
|
||||
specific
|
||||
.overrideConsolidatedDayAssignments((SpecificResourceAllocation) getOrigin());
|
||||
return specific;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue