ItEr39S05ValidacionEProbasFuncionaisItEr38S05: [Bug #186] Fixing bug. Detaching task sources associated to the order element to be removed and its descendants
This commit is contained in:
parent
9842d1b82c
commit
0a5e22bbaf
3 changed files with 27 additions and 1 deletions
|
|
@ -30,6 +30,8 @@ import org.hibernate.criterion.Restrictions;
|
|||
import org.navalplanner.business.common.daos.GenericDAOHibernate;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
import org.navalplanner.business.orders.entities.TaskSource;
|
||||
import org.navalplanner.business.planner.daos.ITaskSourceDAO;
|
||||
import org.navalplanner.business.workreports.daos.IWorkReportLineDAO;
|
||||
import org.navalplanner.business.workreports.entities.WorkReportLine;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -53,6 +55,9 @@ public class OrderElementDAO extends GenericDAOHibernate<OrderElement, Long>
|
|||
@Autowired
|
||||
private IWorkReportLineDAO workReportLineDAO;
|
||||
|
||||
@Autowired
|
||||
private ITaskSourceDAO taskSourceDAO;
|
||||
|
||||
@Override
|
||||
public List<OrderElement> findWithoutParent() {
|
||||
Criteria c = getSession().createCriteria(OrderElement.class);
|
||||
|
|
@ -164,4 +169,14 @@ public class OrderElementDAO extends GenericDAOHibernate<OrderElement, Long>
|
|||
return assignedHours.divide(estimatedHours, RoundingMode.DOWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Long id) throws InstanceNotFoundException {
|
||||
OrderElement orderElement = find(id);
|
||||
for (TaskSource each : orderElement.getTaskSourcesFromBottomToTop()) {
|
||||
each.detachAssociatedTaskFromParent();
|
||||
taskSourceDAO.remove(each.getId());
|
||||
}
|
||||
super.remove(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -314,4 +314,8 @@ public class TaskSource extends BaseEntity {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void detachAssociatedTaskFromParent() {
|
||||
task.detach();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -255,8 +255,15 @@ public class OrderModel implements IOrderModel {
|
|||
reattachCriterions();
|
||||
reattachTasksForTasksSources();
|
||||
this.orderDAO.save(order);
|
||||
synchronizeWithSchedule(order);
|
||||
reattachCurrentTaskSources();
|
||||
deleteOrderElementWithoutParent();
|
||||
synchronizeWithSchedule(order);
|
||||
}
|
||||
|
||||
private void reattachCurrentTaskSources() {
|
||||
for (TaskSource each : order.getTaskSourcesFromBottomToTop()) {
|
||||
taskSourceDAO.reattach(each);
|
||||
}
|
||||
}
|
||||
|
||||
private void reattachTasksForTasksSources() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue