ItEr57S10CUEscaladoPantallaCargaRecursosEmpresaItEr56S11: Added a new DAO operation to filter allocations by time when selecting a criterion from the bandbox.
It would also work inside an order, but the time filter isn't active in that case.
This commit is contained in:
parent
5f9c28803f
commit
e095f784be
3 changed files with 38 additions and 2 deletions
|
|
@ -68,4 +68,8 @@ public interface IResourceAllocationDAO extends
|
|||
Map<Criterion, List<GenericResourceAllocation>> findGenericAllocationsBySomeCriterion(
|
||||
List<Criterion> criterions);
|
||||
|
||||
Map<Criterion, List<GenericResourceAllocation>> findGenericAllocationsBySomeCriterion(
|
||||
List<Criterion> criterions, Date intervalFilterStartDate,
|
||||
Date intervalFilterEndDate);
|
||||
|
||||
}
|
||||
|
|
@ -232,6 +232,38 @@ public class ResourceAllocationDAO extends
|
|||
return stripAllocationsWithoutAssignations(byCriterion(list));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<Criterion, List<GenericResourceAllocation>> findGenericAllocationsBySomeCriterion(
|
||||
List<Criterion> criterions, Date intervalFilterStartDate, Date intervalFilterEndDate) {
|
||||
if (criterions.isEmpty()) {
|
||||
return new HashMap<Criterion, List<GenericResourceAllocation>>();
|
||||
}
|
||||
String query = "select generic, criterion "
|
||||
+ "from GenericResourceAllocation as generic "
|
||||
+ "join generic.criterions as criterion ";
|
||||
if(intervalFilterStartDate != null || intervalFilterEndDate != null) {
|
||||
query += "inner join generic.task as task ";
|
||||
}
|
||||
query += "where criterion in(:criterions) ";
|
||||
if(intervalFilterEndDate != null) {
|
||||
query += "and task.startDate <= :intervalFilterEndDate ";
|
||||
}
|
||||
if(intervalFilterStartDate != null) {
|
||||
query += "and task.endDate >= :intervalFilterStartDate ";
|
||||
}
|
||||
|
||||
Query q = getSession().createQuery(query);
|
||||
q.setParameterList("criterions", criterions);
|
||||
if(intervalFilterStartDate != null) {
|
||||
q.setParameter("intervalFilterStartDate", intervalFilterStartDate);
|
||||
}
|
||||
if(intervalFilterEndDate != null) {
|
||||
q.setParameter("intervalFilterEndDate", intervalFilterEndDate);
|
||||
}
|
||||
return stripAllocationsWithoutAssignations(byCriterion(q.list()));
|
||||
}
|
||||
|
||||
private Map<Criterion, List<GenericResourceAllocation>> byCriterion(
|
||||
List<Object> results) {
|
||||
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ public class ResourceLoadModel implements IResourceLoadModel {
|
|||
private Map<Criterion, List<GenericResourceAllocation>> genericAllocationsByCriterion() {
|
||||
if(!criteriaToShowList.isEmpty()) {
|
||||
return resourceAllocationDAO
|
||||
.findGenericAllocationsBySomeCriterion(criteriaToShowList);
|
||||
.findGenericAllocationsBySomeCriterion(criteriaToShowList, initDateFilter, endDateFilter);
|
||||
}
|
||||
if (filter()) {
|
||||
List<Criterion> criterions = new ArrayList<Criterion>();
|
||||
|
|
@ -202,7 +202,7 @@ public class ResourceLoadModel implements IResourceLoadModel {
|
|||
}
|
||||
}
|
||||
return resourceAllocationDAO
|
||||
.findGenericAllocationsBySomeCriterion(criterions);
|
||||
.findGenericAllocationsBySomeCriterion(criterions, initDateFilter, endDateFilter);
|
||||
} else {
|
||||
return resourceAllocationDAO.findGenericAllocationsByCriterion(initDateFilter, endDateFilter);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue