View Javadoc

1   package org.kuali.student.r2.common.criteria.impl;
2   
3   import org.kuali.rice.core.api.criteria.GenericQueryResults;
4   import org.kuali.rice.core.api.criteria.QueryByCriteria;
5   import org.kuali.student.r2.common.criteria.CriteriaLookupService;
6   import org.kuali.student.r2.common.criteria.LookupCustomizer;
7   import org.kuali.student.r2.common.criteria.LookupCustomizer.PredicateTransform;
8   
9   import java.util.List;
10  
11  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          return additionalTransforms;
19      }
20  
21      public void setAdditionalTransforms(List<PredicateTransform> additionalTransforms) {
22          this.additionalTransforms = additionalTransforms;
23      }
24  
25      public List<PredicateTransform> getPredicateTransforms() {
26          return predicateTransforms;
27      }
28  
29      public void setPredicateTransforms(List<PredicateTransform> predicateTransforms) {
30          this.predicateTransforms = predicateTransforms;
31      }
32  
33      public void setCriteriaLookupDao(CriteriaLookupDaoJpaImpl criteriaLookupDao) {
34          this.criteriaLookupDao = criteriaLookupDao;
35      }
36      
37      @Override
38      public <T> GenericQueryResults<T> lookup(Class<T> queryClass, QueryByCriteria criteria) {
39          
40          LookupCustomizer.Builder<T> lc = LookupCustomizer.Builder.create();
41          lc.setPredicateTransforms(this.getPredicateTransforms());
42          lc.setAdditionalTransforms(this.getAdditionalTransforms());
43          
44          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          customizer.getAdditionalTransforms().addAll(this.getAdditionalTransforms());
51          customizer.getPredicateTransforms().addAll(this.getPredicateTransforms());
52          
53          return criteriaLookupDao.lookup(queryClass, criteria, customizer);
54      }
55  
56      @Override
57      public <T> GenericQueryResults<String> lookupIds(Class<T> queryClass, QueryByCriteria criteria) {
58  
59          LookupCustomizer.Builder<T> lc = LookupCustomizer.Builder.create();
60          lc.setPredicateTransforms(this.getPredicateTransforms());
61          lc.setAdditionalTransforms(this.getAdditionalTransforms());
62  
63          return criteriaLookupDao.lookupIds(queryClass, criteria, lc.build());
64      }
65  
66      @Override
67      public <T> GenericQueryResults<String> lookupIds(Class<T> queryClass, QueryByCriteria criteria, LookupCustomizer<T> customizer) {
68  
69          customizer.getAdditionalTransforms().addAll(this.getAdditionalTransforms());
70          customizer.getPredicateTransforms().addAll(this.getPredicateTransforms());
71  
72          return criteriaLookupDao.lookupIds(queryClass, criteria, customizer);
73      }
74  
75      @Override
76      public <T> GenericQueryResults<List<String>> genericLookup(final Class<T> queryClass, final QueryByCriteria criteria, List<String> fields){
77          LookupCustomizer.Builder<T> lc = LookupCustomizer.Builder.create();
78          lc.setPredicateTransforms(this.getPredicateTransforms());
79          lc.setAdditionalTransforms(this.getAdditionalTransforms());
80  
81          return criteriaLookupDao.genericLookup(queryClass, criteria, lc.build(), fields);
82      }
83  
84      @Override
85      public <T> GenericQueryResults<List<String>> genericLookup(final Class<T> queryClass, final QueryByCriteria criteria, final LookupCustomizer<T> customizer, List<String> fields){
86          customizer.getAdditionalTransforms().addAll(this.getAdditionalTransforms());
87          customizer.getPredicateTransforms().addAll(this.getPredicateTransforms());
88  
89          return criteriaLookupDao.genericLookup(queryClass, criteria, customizer, fields);
90  
91      }
92  
93  }