View Javadoc
1   /**
2    * Copyright 2005-2016 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.actionrequest.dao.impl;
17  
18  import org.kuali.rice.kew.actionrequest.ActionRequestValue;
19  import org.kuali.rice.kew.actionrequest.dao.ActionRequestDAO;
20  import org.kuali.rice.kew.api.action.ActionRequestStatus;
21  import org.kuali.rice.kew.api.action.RecipientType;
22  
23  import javax.persistence.EntityManager;
24  import javax.persistence.TypedQuery;
25  import java.util.List;
26  
27  /**
28   * This is a description of what this class does - sgibson don't forget to fill this in.
29   * 
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  public class ActionRequestDAOJpaImpl implements ActionRequestDAO {
33      
34      private EntityManager entityManager;
35  
36      /**
37  	 * @return the entityManager
38  	 */
39  	public EntityManager getEntityManager() {
40  		return this.entityManager;
41  	}
42  
43  	/**
44  	 * @param entityManager the entityManager to set
45  	 */
46  	public void setEntityManager(EntityManager entityManager) {
47  		this.entityManager = entityManager;
48  	}
49  
50      public List<ActionRequestValue> findPendingRootRequestsByDocumentType(String documentTypeId) {
51          TypedQuery<ActionRequestValue> query =
52                  entityManager.createNamedQuery("ActionRequestValue.FindPendingRootRequestsByDocumentType", ActionRequestValue.class);
53          query.setParameter("documentTypeId", documentTypeId);
54          query.setParameter("currentIndicator", Boolean.TRUE);
55          query.setParameter("actionRequestStatus1", ActionRequestStatus.INITIALIZED.getCode());
56          query.setParameter("actionRequestStatus2", ActionRequestStatus.ACTIVATED.getCode());
57          return query.getResultList();
58      }
59  
60      public List<String> getRequestGroupIds(String documentId) {
61          TypedQuery<String> query = entityManager.createNamedQuery("ActionRequestValue.GetRequestGroupIds", String.class);
62          query.setParameter("documentId", documentId);
63          query.setParameter("currentIndicator", Boolean.TRUE);
64          query.setParameter("recipientTypeCd", RecipientType.GROUP.getCode());
65          return query.getResultList();
66      }
67  
68  }