[Bug #1015] Fix bug at hours worked by resource report

Include in the query descendant criteria.

FEA: ItEr74S04BugFixing
This commit is contained in:
Óscar González Fernández 2011-04-25 19:22:53 +02:00
parent 9bc2b40cfd
commit c3208fa78c
3 changed files with 13 additions and 13 deletions

View file

@ -231,7 +231,8 @@ public class ResourceDAO extends IntegrationEntityDAO<Resource> implements
query.setParameterList("labels", labels);
}
if (criterions != null && !criterions.isEmpty()) {
query.setParameterList("criterions", criterions);
query.setParameterList("criterions",
Criterion.withAllDescendants(criterions));
}
// Get result

View file

@ -29,7 +29,6 @@ import static org.hibernate.criterion.Restrictions.or;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
@ -144,17 +143,7 @@ public class ResourcesSearcher implements IResourcesSearcher {
return;
}
criteria.createCriteria("criterionSatisfactions").add(
in("criterion", withAllDescendants(this.criteria)));
}
private Set<Criterion> withAllDescendants(
Collection<? extends Criterion> originalCriteria) {
Set<Criterion> result = new HashSet<Criterion>();
for (Criterion each : originalCriteria) {
result.add(each);
result.addAll(withAllDescendants(each.getChildren()));
}
return result;
in("criterion", Criterion.withAllDescendants(this.criteria)));
}
private boolean criteriaSpecified() {

View file

@ -70,6 +70,16 @@ public class Criterion extends IntegrationEntity implements ICriterion {
}
public static Set<Criterion> withAllDescendants(
Collection<? extends Criterion> originalCriteria) {
Set<Criterion> result = new HashSet<Criterion>();
for (Criterion each : originalCriteria) {
result.add(each);
result.addAll(withAllDescendants(each.getChildren()));
}
return result;
}
public static final Comparator<Criterion> byName = new Comparator<Criterion>() {
@Override