ItEr53S11RFInfraestucturaEscenariosItEr52S11: Delete associated WorkReports when erasing an order element.
It was causing intermittent test failures at OrderModelTest.
This commit is contained in:
parent
20daf4ca24
commit
c0da04ff89
1 changed files with 18 additions and 0 deletions
|
|
@ -22,8 +22,10 @@ package org.navalplanner.business.orders.daos;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.hibernate.Criteria;
|
||||
|
|
@ -38,6 +40,7 @@ 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.templates.entities.OrderElementTemplate;
|
||||
import org.navalplanner.business.workreports.daos.IWorkReportDAO;
|
||||
import org.navalplanner.business.workreports.daos.IWorkReportLineDAO;
|
||||
import org.navalplanner.business.workreports.entities.WorkReport;
|
||||
import org.navalplanner.business.workreports.entities.WorkReportLine;
|
||||
|
|
@ -63,6 +66,9 @@ public class OrderElementDAO extends IntegrationEntityDAO<OrderElement>
|
|||
@Autowired
|
||||
private IWorkReportLineDAO workReportLineDAO;
|
||||
|
||||
@Autowired
|
||||
private IWorkReportDAO workReportDAO;
|
||||
|
||||
@Autowired
|
||||
private ITaskSourceDAO taskSourceDAO;
|
||||
|
||||
|
|
@ -188,9 +194,21 @@ public class OrderElementDAO extends IntegrationEntityDAO<OrderElement>
|
|||
each.detachAssociatedTaskFromParent();
|
||||
taskSourceDAO.remove(each.getId());
|
||||
}
|
||||
for (WorkReport each : getWorkReportsPointingTo(orderElement)) {
|
||||
workReportDAO.remove(each.getId());
|
||||
}
|
||||
super.remove(id);
|
||||
}
|
||||
|
||||
private Set<WorkReport> getWorkReportsPointingTo(OrderElement orderElement) {
|
||||
Set<WorkReport> result = new HashSet<WorkReport>();
|
||||
for (WorkReportLine each : workReportLineDAO
|
||||
.findByOrderElementAndChildren(orderElement)) {
|
||||
result.add(each.getWorkReport());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderElement> findAll() {
|
||||
return getSession().createCriteria(getEntityClass()).addOrder(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue