ItEr57S04ValidacionEProbasFuncionaisItEr56S04: [Bug #489] Fix bug.
ReturningNewAssignments was always adding the initial new assignments (assignments for the current order and scenario that are still not saved). But removals and addings can happen on these new assignments but ReturningNewAssignments kept using the initial new assignments. Instead of passing the initial new assignmetns to ReturningNewAssignments, they are added to resource using @AfterCopy mechanism.
This commit is contained in:
parent
b263ea5baf
commit
ede7870ae7
2 changed files with 4 additions and 24 deletions
|
|
@ -40,6 +40,7 @@ import org.joda.time.LocalDate;
|
|||
import org.navalplanner.business.common.BaseEntity;
|
||||
import org.navalplanner.business.resources.entities.Resource;
|
||||
import org.navalplanner.business.scenarios.entities.Scenario;
|
||||
import org.navalplanner.business.util.deepcopy.AfterCopy;
|
||||
import org.navalplanner.business.util.deepcopy.OnCopy;
|
||||
import org.navalplanner.business.util.deepcopy.Strategy;
|
||||
|
||||
|
|
@ -229,6 +230,7 @@ public abstract class DayAssignment extends BaseEntity {
|
|||
&& day.compareTo(endExclusive) < 0;
|
||||
}
|
||||
|
||||
@AfterCopy
|
||||
protected void associateToResource() {
|
||||
getResource().addNewAssignments(Arrays.asList(this));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,26 +270,10 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
IAssignmentsOnResourceCalculator {
|
||||
|
||||
private Set<DayAssignment> previousAssignmentsSet;
|
||||
private Map<Resource, List<DayAssignment>> newAssignments;
|
||||
|
||||
public ReturningNewAssignments(List<DayAssignment> previousAssignments,
|
||||
List<DayAssignment> newAssignments) {
|
||||
public ReturningNewAssignments(List<DayAssignment> previousAssignments) {
|
||||
this.previousAssignmentsSet = new HashSet<DayAssignment>(
|
||||
previousAssignments);
|
||||
this.newAssignments = byResource(newAssignments);
|
||||
}
|
||||
|
||||
private Map<Resource, List<DayAssignment>> byResource(List<DayAssignment> newAssignments) {
|
||||
Map<Resource, List<DayAssignment>> result = new HashMap<Resource, List<DayAssignment>>();
|
||||
for (DayAssignment each : newAssignments) {
|
||||
Resource resource = each.getResource();
|
||||
List<DayAssignment> list = result.get(resource);
|
||||
if (list == null) {
|
||||
result.put(resource, new ArrayList<DayAssignment>());
|
||||
}
|
||||
result.get(resource).add(each);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -300,15 +284,9 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
result.add(each);
|
||||
}
|
||||
}
|
||||
result.addAll(newAssignmentsFor(resource));
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<DayAssignment> newAssignmentsFor(Resource resource) {
|
||||
List<DayAssignment> result = newAssignments.get(resource);
|
||||
return result == null ? Collections.<DayAssignment> emptyList()
|
||||
: result;
|
||||
}
|
||||
}
|
||||
|
||||
private final class TaskElementNavigator implements
|
||||
|
|
@ -1001,7 +979,7 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
.createInitialVersion(currentScenario);
|
||||
orderReloaded.writeSchedulingDataChangesTo(currentScenario, newVersion);
|
||||
assigmentsOnResourceCalculator = new ReturningNewAssignments(
|
||||
previousAssignments, orderReloaded.getDayAssignments());
|
||||
previousAssignments);
|
||||
return createScenarioInfoForNotOwnerScenario(orderReloaded, previousVersion,
|
||||
newVersion);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue