ItEr49S04ValidacionEProbasFuncionaisItEr48S04: [Bug #366] Fixing bug.

Not reattaching calendars since they are already loaded.
This commit is contained in:
Óscar González Fernández 2010-03-03 18:48:38 +01:00
parent 2a46cbddfd
commit 5382d6f109

View file

@ -28,8 +28,6 @@ import java.util.Set;
import org.hibernate.Hibernate;
import org.navalplanner.business.calendars.daos.IBaseCalendarDAO;
import org.navalplanner.business.calendars.entities.BaseCalendar;
import org.navalplanner.business.calendars.entities.CalendarData;
import org.navalplanner.business.common.IAdHocTransactionService;
import org.navalplanner.business.common.IOnTransaction;
import org.navalplanner.business.common.ProportionalDistributor;
@ -191,7 +189,7 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
}
private void stepsBeforeDoingAllocation() {
reattachmentsBeforeDoingAllocation();
ensureResourcesAreReadyForDoingAllocation();
removeDeletedAllocations();
}
@ -199,7 +197,7 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
@Transactional(readOnly = true)
public <T> T onAllocationContext(
IResourceAllocationContext<T> resourceAllocationContext) {
reattachmentsBeforeDoingAllocation();
ensureResourcesAreReadyForDoingAllocation();
return resourceAllocationContext.doInsideTransaction();
}
@ -211,13 +209,6 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
}
}
private void reattachmentsBeforeDoingAllocation() {
ensureResourcesAreReadyForDoingAllocation();
if (task.getCalendar() != null) {
calendarDAO.reattachUnmodifiedEntity(task.getCalendar());
}
}
private void reassociateResourcesWithSession() {
planningState.reassociateResourcesWithSession();
}
@ -344,9 +335,6 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
private void reattachResource(Resource resource) {
resourceDAO.reattach(resource);
reattachCriterionSatisfactions(resource.getCriterionSatisfactions());
if (resource.getCalendar() != null) {
loadCalendar(resource.getCalendar());
}
for (DayAssignment dayAssignment : resource.getAssignments()) {
Hibernate.initialize(dayAssignment);
}
@ -355,18 +343,6 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
}
}
private void loadCalendar(BaseCalendar baseCalendar) {
calendarDAO.reattachUnmodifiedEntity(baseCalendar);
for (CalendarData calendarData : baseCalendar.getCalendarDataVersions()) {
calendarData.getHoursPerDay().size();
if (calendarData.getParent() != null) {
loadCalendar(calendarData.getParent());
}
}
baseCalendar.getExceptions().size();
baseCalendar.getCalendarAvailabilities().size();
}
private void reattachCriterionSatisfactions(
Set<CriterionSatisfaction> criterionSatisfactions) {
for (CriterionSatisfaction criterionSatisfaction : criterionSatisfactions) {