View Javadoc

1   package org.kuali.student.enrollment.class1.lpr.dao;
2   
3   
4   import java.util.HashSet;
5   import java.util.List;
6   import java.util.Set;
7   
8   import org.kuali.student.enrollment.class1.lpr.model.LprEntity;
9   import org.kuali.student.r2.common.dao.GenericEntityDao;
10  import org.kuali.student.enrollment.lpr.dto.LprInfo;
11  import org.kuali.student.r2.common.exceptions.DoesNotExistException;
12  
13  
14  public class LprDao extends GenericEntityDao<LprEntity> {
15  
16      @SuppressWarnings({"unchecked"})
17      public List<LprEntity> getByLuiId(String luiId) {
18          return em.createQuery("from LprEntity lpr where lpr.luiId=:luiId").setParameter("luiId", luiId).getResultList();
19      }
20  
21      @SuppressWarnings("unchecked")
22      public List<String> getLprIdsByLuiAndPerson(String personId, String luiId) {
23          return em.createQuery("select lpr.id from LprEntity lpr where lpr.personId=:personId and lpr.luiId=:luiId").setParameter("personId", personId).setParameter("luiId", luiId).getResultList();
24      }
25  
26      @SuppressWarnings("unchecked")
27      public List<LprEntity> getLprsByPersonAndType(String personId,String typeKey){
28          return em.createQuery("from LprEntity lpr where lpr.personId=:personId and lpr.personRelationTypeId=:typeKey").setParameter("personId", personId).setParameter("typeKey", typeKey).getResultList();
29      }
30  
31  
32      @SuppressWarnings("unchecked")
33      public List<LprEntity> getLprsByPerson(String personId){
34          return em.createQuery("from LprEntity lpr where lpr.personId=:personId").setParameter("personId", personId).getResultList();
35      }
36  
37      @SuppressWarnings("unchecked")
38      public List<String> getPersonIdsByLui(String luiId, String typeKey, String stateKey){
39          return em.createQuery("select lpr.personId from LprEntity lpr where lpr.luiId=:luiId and lpr.personRelationTypeId=:typeKey and lpr.personRelationStateId=:stateKey")
40                  .setParameter("luiId", luiId)
41                  .setParameter("typeKey", typeKey)
42                  .setParameter("stateKey", stateKey)
43                  .getResultList();
44      }
45  
46      @SuppressWarnings("unchecked")
47      public List<LprEntity> getLprByLuiAndPerson(String personId, String luiId) {
48          return em.createQuery("from LprEntity lpr where lpr.personId=:personId and lpr.luiId=:luiId")
49                  .setParameter("personId", personId)
50                  .setParameter("luiId", luiId)
51                  .getResultList();
52      }
53  
54      @SuppressWarnings("unchecked")
55      public List<LprEntity> getLprsByLuiPersonAndState(String personId, String luiId, String stateKey) {
56          return em.createQuery("from LprEntity lpr where lpr.personId=:personId and lpr.luiId=:luiId and lpr.personRelationStateId=:stateKey")
57                  .setParameter("personId", personId)
58                  .setParameter("luiId", luiId)
59                  .setParameter("stateKey", stateKey)
60                  .getResultList();
61      }
62  
63      @SuppressWarnings("unchecked")
64      public List<LprEntity> getLprsByLuiAndType(String luiId, String lprTypeKey) {
65          return em.createQuery("from LprEntity lpr where lpr.luiId=:luiId and lpr.personRelationTypeId=:lprTypeKey").setParameter("luiId", luiId).setParameter("lprTypeKey", lprTypeKey).getResultList();
66      }
67  
68      public List<String> getLuiIdsByPersonAndTypeAndState(String personId, String luiPersonRelationType, String relationState) {
69          return em.createQuery("SELECT lpr.luiId FROM LprEntity lpr WHERE lpr.personId = :personId AND lpr.personRelationTypeId = :luiPersonRelationType AND lpr.personRelationStateId = :relationState")
70                  .setParameter("personId", personId)
71                  .setParameter("luiPersonRelationType", luiPersonRelationType)
72                  .setParameter("relationState", relationState)
73                  .getResultList();
74      }
75  
76      @SuppressWarnings("unchecked")
77      public List<LprEntity> getLprsByLuis(List<String> luiIds) {
78          Set<String> luiIdSet = new HashSet<String>(luiIds.size());
79          // remove duplicates from the key list
80          luiIdSet.addAll(luiIds);
81          return (List<LprEntity>) em.createNamedQuery("Lpr.getLprsByLuis").setParameter("luiIds", luiIdSet).getResultList();
82      }
83  }