ItEr36S07ValidacionEProbasFuncionaisItEr35S08: [Bug #101] Fixing bug. The problem was that the resource calendar was detached.
This commit is contained in:
parent
adc7c7fc71
commit
e551955614
5 changed files with 40 additions and 6 deletions
|
|
@ -28,6 +28,7 @@ import org.navalplanner.business.planner.entities.ResourceAllocation;
|
|||
import org.navalplanner.business.planner.entities.ResourcesPerDay;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocationBeingModified;
|
||||
import org.navalplanner.business.resources.entities.Resource;
|
||||
|
||||
/**
|
||||
* The information that must be introduced to create a
|
||||
|
|
@ -104,4 +105,6 @@ public abstract class AllocationDTO {
|
|||
return getResourcesPerDay().isZero();
|
||||
}
|
||||
|
||||
public abstract List<Resource> getAssociatedResources();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,4 +102,9 @@ public class GenericAllocationDTO extends AllocationDTO {
|
|||
public boolean hasSameCriterions(Set<Criterion> criterions) {
|
||||
return this.criterions.equals(criterions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Resource> getAssociatedResources() {
|
||||
return resources;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.calendars.daos.IBaseCalendarDAO;
|
||||
import org.navalplanner.business.orders.daos.IHoursGroupDAO;
|
||||
import org.navalplanner.business.orders.entities.AggregatedHoursGroup;
|
||||
import org.navalplanner.business.orders.entities.HoursGroup;
|
||||
|
|
@ -76,6 +76,9 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
|
||||
private org.zkoss.ganttz.data.Task ganttTask;
|
||||
|
||||
@Autowired
|
||||
private IBaseCalendarDAO calendarDAO;
|
||||
|
||||
private PlanningState planningState;
|
||||
|
||||
private ResourceAllocationsBeingEdited resourceAllocationsBeingEdited;
|
||||
|
|
@ -146,12 +149,23 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
@Transactional(readOnly = true)
|
||||
public <T> T onAllocationContext(
|
||||
IResourceAllocationContext<T> resourceAllocationContext) {
|
||||
reassociateResourcesWithSession();
|
||||
ensureResourcesAreReadyForDoingAllocation();
|
||||
return resourceAllocationContext.doInsideTransaction();
|
||||
}
|
||||
|
||||
private void ensureResourcesAreReadyForDoingAllocation() {
|
||||
Set<Resource> resources = resourceAllocationsBeingEdited
|
||||
.getAllocationResources();
|
||||
for (Resource each : resources) {
|
||||
reattachResource(each);
|
||||
}
|
||||
}
|
||||
|
||||
private void stepsBeforeDoingAllocation() {
|
||||
reassociateResourcesWithSession();
|
||||
ensureResourcesAreReadyForDoingAllocation();
|
||||
if (task.getCalendar() != null) {
|
||||
calendarDAO.reattachUnmodifiedEntity(task.getCalendar());
|
||||
}
|
||||
removeDeletedAllocations();
|
||||
}
|
||||
|
||||
|
|
@ -249,9 +263,7 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
private void reattachResource(Resource resource) {
|
||||
resourceDAO.reattach(resource);
|
||||
reattachCriterionSatisfactions(resource.getCriterionSatisfactions());
|
||||
if (resource.getCalendar() != null) {
|
||||
resource.getCalendar().getWorkableHours(new LocalDate());
|
||||
}
|
||||
calendarDAO.reattachUnmodifiedEntity(resource.getCalendar());
|
||||
for (DayAssignment dayAssignment : resource.getAssignments()) {
|
||||
Hibernate.initialize(dayAssignment);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -276,4 +276,12 @@ public class ResourceAllocationsBeingEdited {
|
|||
return daysDuration;
|
||||
}
|
||||
|
||||
public Set<Resource> getAllocationResources() {
|
||||
Set<Resource> result = new HashSet<Resource>();
|
||||
for (AllocationDTO each : currentAllocations) {
|
||||
result.addAll(each.getAssociatedResources());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -22,6 +22,7 @@ package org.navalplanner.web.planner.allocation;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.planner.entities.ResourceAllocation;
|
||||
|
|
@ -119,4 +120,9 @@ public class SpecificAllocationDTO extends AllocationDTO {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Resource> getAssociatedResources() {
|
||||
return Collections.singletonList(resource);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue