View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.rule.dao.impl;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.kew.rule.RuleDelegationBo;
20  import org.kuali.rice.kew.rule.dao.RuleDelegationDAO;
21  import org.kuali.rice.krad.data.DataObjectService;
22  import org.springframework.beans.factory.annotation.Required;
23  
24  import javax.persistence.EntityManager;
25  import java.util.Collection;
26  import java.util.List;
27  import java.util.Map;
28  
29  import static org.kuali.rice.core.api.criteria.PredicateFactory.equal;
30  
31  public class RuleDelegationDAOJpa implements RuleDelegationDAO {
32  
33  	private EntityManager entityManager;
34      private DataObjectService dataObjectService;
35  
36      public List<RuleDelegationBo> findByDelegateRuleId(String ruleId) {
37          org.kuali.rice.core.api.criteria.QueryByCriteria.Builder builder =
38                  org.kuali.rice.core.api.criteria.QueryByCriteria.Builder.create();
39          builder.setPredicates(equal("ruleDelegationId",ruleId));
40          return getDataObjectService().findMatching(RuleDelegationBo.class,builder.build()).getResults();
41      }
42  
43      public void save(RuleDelegationBo ruleDelegation) {
44      	getDataObjectService().save(ruleDelegation);
45      }
46  
47      public List<RuleDelegationBo> findAllCurrentRuleDelegations(){
48          org.kuali.rice.core.api.criteria.QueryByCriteria.Builder builder =
49                  org.kuali.rice.core.api.criteria.QueryByCriteria.Builder.create();
50          builder.setPredicates(equal("delegationRule.currentInd",true));
51          return getDataObjectService().findMatching(RuleDelegationBo.class,builder.build()).getResults();
52      }
53  
54      public RuleDelegationBo findByRuleDelegationId(String ruleDelegationId){
55          return getDataObjectService().find(RuleDelegationBo.class, ruleDelegationId);
56  
57      }
58      public void delete(String ruleDelegationId){
59          getDataObjectService().delete(findByRuleDelegationId(ruleDelegationId));
60      }
61  
62  
63      public List<RuleDelegationBo> findByResponsibilityIdWithCurrentRule(String responsibilityId) {
64          if (StringUtils.isBlank(responsibilityId)){
65              return null;
66          }
67  
68          org.kuali.rice.core.api.criteria.QueryByCriteria.Builder builder =
69                      org.kuali.rice.core.api.criteria.QueryByCriteria.Builder.create();
70          builder.setPredicates(equal("delegationRule.currentInd",true),
71                      equal("responsibilityId",responsibilityId));
72          return getDataObjectService().findMatching(RuleDelegationBo.class,builder.build()).getResults();
73      }
74  
75      /**
76       * This overridden method ...
77       *
78       * @see org.kuali.rice.kew.rule.dao.RuleDelegationDAO#search(java.lang.String, java.lang.Long, java.lang.Long, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, java.util.Map, java.lang.String)
79       */
80      public List<RuleDelegationBo> search(String parentRuleBaseVaueId, String parentResponsibilityId, String docTypeName, String ruleId,
81              String ruleTemplateId, String ruleDescription, String workgroupId,
82              String workflowId, String delegationType, Boolean activeInd,
83              Map extensionValues, String workflowIdDirective) {
84          // TODO jjhanso - THIS METHOD NEEDS JAVADOCS
85          return null;
86      }
87  
88      /**
89       * This overridden method ...
90       *
91       * @see org.kuali.rice.kew.rule.dao.RuleDelegationDAO#search(java.lang.String, java.lang.Long, java.lang.String, java.util.Collection, java.lang.String, java.lang.String, java.lang.Boolean, java.util.Map, java.util.Collection)
92       */
93      public List<RuleDelegationBo> search(String parentRuleBaseVaueId, String parentResponsibilityId, String docTypeName, String ruleTemplateId,
94              String ruleDescription, Collection<String> workgroupIds,
95              String workflowId, String delegationType, Boolean activeInd,
96              Map extensionValues, Collection actionRequestCodes) {
97          // TODO jjhanso - THIS METHOD NEEDS JAVADOCS
98          return null;
99      }
100 
101     public DataObjectService getDataObjectService() {
102         return dataObjectService;
103     }
104 
105     @Required
106     public void setDataObjectService(DataObjectService dataObjectService) {
107         this.dataObjectService = dataObjectService;
108     }
109 
110     public EntityManager getEntityManager() {
111         return this.entityManager;
112     }
113 
114     public void setEntityManager(EntityManager entityManager) {
115         this.entityManager = entityManager;
116     }
117 
118 
119 }