Include unscheduled projects in orders query
When you import a project from the web service, the task elements are not created yet, so we need to return these projects in the query otherwise they will be not visible at all for the users. FEA: ItEr77S15FilteringEnhancements
This commit is contained in:
parent
f02d6f8a8d
commit
58b963f30f
1 changed files with 54 additions and 5 deletions
|
|
@ -43,6 +43,7 @@ import org.libreplan.business.labels.entities.Label;
|
||||||
import org.libreplan.business.orders.entities.Order;
|
import org.libreplan.business.orders.entities.Order;
|
||||||
import org.libreplan.business.orders.entities.OrderElement;
|
import org.libreplan.business.orders.entities.OrderElement;
|
||||||
import org.libreplan.business.orders.entities.OrderStatusEnum;
|
import org.libreplan.business.orders.entities.OrderStatusEnum;
|
||||||
|
import org.libreplan.business.orders.entities.SchedulingState;
|
||||||
import org.libreplan.business.planner.daos.ITaskSourceDAO;
|
import org.libreplan.business.planner.daos.ITaskSourceDAO;
|
||||||
import org.libreplan.business.planner.entities.Task;
|
import org.libreplan.business.planner.entities.Task;
|
||||||
import org.libreplan.business.reports.dtos.CostExpenseSheetDTO;
|
import org.libreplan.business.reports.dtos.CostExpenseSheetDTO;
|
||||||
|
|
@ -231,12 +232,25 @@ public class OrderDAO extends IntegrationEntityDAO<Order> implements
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Long> ordersIdsUnscheduled = getOrdersIdsUnscheduled(startDate,
|
||||||
|
endDate);
|
||||||
|
|
||||||
Criteria c = getSession().createCriteria(Order.class);
|
Criteria c = getSession().createCriteria(Order.class);
|
||||||
if (ordersIdsFiltered != null) {
|
if (ordersIdsFiltered != null && ordersIdsByDates != null) {
|
||||||
c.add(Restrictions.in("id", ordersIdsFiltered));
|
org.hibernate.criterion.Criterion and = Restrictions.and(
|
||||||
}
|
Restrictions.in("id", ordersIdsFiltered),
|
||||||
if (ordersIdsByDates != null) {
|
Restrictions.in("id", ordersIdsByDates));
|
||||||
c.add(Restrictions.in("id", ordersIdsByDates));
|
c.add(Restrictions.or(and,
|
||||||
|
Restrictions.in("id", ordersIdsUnscheduled)));
|
||||||
|
} else {
|
||||||
|
if (ordersIdsFiltered != null) {
|
||||||
|
c.add(Restrictions.or(Restrictions.in("id", ordersIdsFiltered),
|
||||||
|
Restrictions.in("id", ordersIdsUnscheduled)));
|
||||||
|
}
|
||||||
|
if (ordersIdsByDates != null) {
|
||||||
|
c.add(Restrictions.or(Restrictions.in("id", ordersIdsByDates),
|
||||||
|
Restrictions.in("id", ordersIdsUnscheduled)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.addOrder(org.hibernate.criterion.Order.desc("initDate"));
|
c.addOrder(org.hibernate.criterion.Order.desc("initDate"));
|
||||||
|
|
@ -244,6 +258,41 @@ public class OrderDAO extends IntegrationEntityDAO<Order> implements
|
||||||
return c.list();
|
return c.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Long> getOrdersIdsUnscheduled(Date startDate, Date endDate) {
|
||||||
|
String strQuery = "SELECT s.orderElement.id "
|
||||||
|
+ "FROM SchedulingDataForVersion s "
|
||||||
|
+ "WHERE s.schedulingStateType = :type";
|
||||||
|
Query query = getSession().createQuery(strQuery);
|
||||||
|
query.setParameter("type", SchedulingState.Type.NO_SCHEDULED);
|
||||||
|
|
||||||
|
List<Long> ordersIdsUnscheduled = query.list();
|
||||||
|
if (ordersIdsUnscheduled.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
String strQueryDates = "SELECT o.id "
|
||||||
|
+ "FROM Order o "
|
||||||
|
+ "WHERE o.id IN (:ids) ";
|
||||||
|
|
||||||
|
if (startDate != null) {
|
||||||
|
strQueryDates += "AND o.initDate >= :startDate ";
|
||||||
|
}
|
||||||
|
if (endDate != null) {
|
||||||
|
strQueryDates += "AND o.initDate <= :endDate ";
|
||||||
|
}
|
||||||
|
|
||||||
|
Query queryDates = getSession().createQuery(strQueryDates);
|
||||||
|
if (startDate != null) {
|
||||||
|
queryDates.setParameter("startDate", startDate);
|
||||||
|
}
|
||||||
|
if (endDate != null) {
|
||||||
|
queryDates.setParameter("endDate", endDate);
|
||||||
|
}
|
||||||
|
queryDates.setParameterList("ids", ordersIdsUnscheduled);
|
||||||
|
|
||||||
|
return queryDates.list();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If both params are <code>null</code> it returns <code>null</code>.
|
* If both params are <code>null</code> it returns <code>null</code>.
|
||||||
* Otherwise it filters the list of tasks to return the ones wihtout parent
|
* Otherwise it filters the list of tasks to return the ones wihtout parent
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue