View Javadoc

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  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  }