1 | |
package org.kuali.student.r2.common.criteria.impl; |
2 | |
|
3 | |
import java.util.List; |
4 | |
|
5 | |
import org.kuali.rice.core.api.criteria.GenericQueryResults; |
6 | |
import org.kuali.rice.core.api.criteria.QueryByCriteria; |
7 | |
import org.kuali.student.r2.common.criteria.CriteriaLookupService; |
8 | |
import org.kuali.student.r2.common.criteria.LookupCustomizer; |
9 | |
import org.kuali.student.r2.common.criteria.LookupCustomizer.PredicateTransform; |
10 | |
|
11 | 0 | public class CriteriaLookupServiceImpl implements CriteriaLookupService { |
12 | |
|
13 | |
private CriteriaLookupDaoJpaImpl criteriaLookupDao; |
14 | |
private List<PredicateTransform> additionalTransforms; |
15 | |
private List<PredicateTransform> predicateTransforms; |
16 | |
|
17 | |
public List<PredicateTransform> getAdditionalTransforms() { |
18 | 0 | return additionalTransforms; |
19 | |
} |
20 | |
|
21 | |
public void setAdditionalTransforms(List<PredicateTransform> additionalTransforms) { |
22 | 0 | this.additionalTransforms = additionalTransforms; |
23 | 0 | } |
24 | |
|
25 | |
public List<PredicateTransform> getPredicateTransforms() { |
26 | 0 | return predicateTransforms; |
27 | |
} |
28 | |
|
29 | |
public void setPredicateTransforms(List<PredicateTransform> predicateTransforms) { |
30 | 0 | this.predicateTransforms = predicateTransforms; |
31 | 0 | } |
32 | |
|
33 | |
public void setCriteriaLookupDao(CriteriaLookupDaoJpaImpl criteriaLookupDao) { |
34 | 0 | this.criteriaLookupDao = criteriaLookupDao; |
35 | 0 | } |
36 | |
|
37 | |
@Override |
38 | |
public <T> GenericQueryResults<T> lookup(Class<T> queryClass, QueryByCriteria criteria) { |
39 | |
|
40 | 0 | LookupCustomizer.Builder<T> lc = LookupCustomizer.Builder.create(); |
41 | 0 | lc.setPredicateTransforms(this.getPredicateTransforms()); |
42 | 0 | lc.setAdditionalTransforms(this.getAdditionalTransforms()); |
43 | |
|
44 | 0 | return criteriaLookupDao.lookup(queryClass, criteria, lc.build()); |
45 | |
} |
46 | |
|
47 | |
@Override |
48 | |
public <T> GenericQueryResults<T> lookup(Class<T> queryClass, QueryByCriteria criteria, LookupCustomizer<T> customizer) { |
49 | |
|
50 | 0 | customizer.getAdditionalTransforms().addAll(this.getAdditionalTransforms()); |
51 | 0 | customizer.getPredicateTransforms().addAll(this.getPredicateTransforms()); |
52 | |
|
53 | 0 | return criteriaLookupDao.lookup(queryClass, criteria, customizer); |
54 | |
} |
55 | |
|
56 | |
} |