1 | |
package org.kuali.student.enrollment.class1.lpr.dao; |
2 | |
|
3 | |
|
4 | |
import java.util.List; |
5 | |
|
6 | |
import org.kuali.student.enrollment.class1.lpr.model.LprEntity; |
7 | |
import org.kuali.student.enrollment.dao.GenericEntityDao; |
8 | |
import org.kuali.student.enrollment.lpr.dto.LprInfo; |
9 | |
import org.kuali.student.r2.common.exceptions.DoesNotExistException; |
10 | |
|
11 | |
|
12 | 0 | public class LprDao extends GenericEntityDao<LprEntity> { |
13 | |
|
14 | |
@SuppressWarnings({"unchecked"}) |
15 | |
public List<LprEntity> getByLuiId(String luiId) { |
16 | 0 | return em.createQuery("from LuiPersonRelationEntity lpr where lpr.luiId=:luiId").setParameter("luiId", luiId).getResultList(); |
17 | |
} |
18 | |
|
19 | |
public List<String> getLprIdsByLuiAndPerson(String personId, String luiId) { |
20 | 0 | return em.createQuery("select lpr.id from LuiPersonRelationEntity lpr where lpr.personId=:personId and lpr.luiId=:luiId").setParameter("personId", personId).setParameter("luiId", luiId).getResultList(); |
21 | |
} |
22 | |
|
23 | |
public List<LprEntity> getLprsByPersonAndType(String personId,String typeKey){ |
24 | 0 | return em.createQuery("from LuiPersonRelationEntity lpr where lpr.personId=:personId and lpr.personRelationTypeId=:typeKey").setParameter("personId", personId).setParameter("typeKey", typeKey).getResultList(); |
25 | |
} |
26 | |
|
27 | |
|
28 | |
public List<LprEntity> getLprsByPerson(String personId){ |
29 | 0 | return em.createQuery("from LuiPersonRelationEntity lpr where lpr.personId=:personId").setParameter("personId", personId).getResultList(); |
30 | |
} |
31 | |
|
32 | |
@SuppressWarnings("unchecked") |
33 | |
public List<String> getPersonIdsByLui(String luiId, String typeKey, String stateKey){ |
34 | 0 | return em.createQuery("select lpr.personId from LuiPersonRelationEntity lpr where lpr.luiId=:luiId and lpr.personRelationTypeId=:typeKey and lpr.personRelationStateId=:stateKey") |
35 | |
.setParameter("luiId", luiId) |
36 | |
.setParameter("typeKey", typeKey) |
37 | |
.setParameter("stateKey", stateKey) |
38 | |
.getResultList(); |
39 | |
} |
40 | |
|
41 | |
public List<LprEntity> getLprByLuiAndPerson(String personId, String luiId) { |
42 | 0 | return em.createQuery("from LuiPersonRelationEntity lpr where lpr.personId=:personId and lpr.luiId=:luiId") |
43 | |
.setParameter("personId", personId) |
44 | |
.setParameter("luiId", luiId) |
45 | |
.getResultList(); |
46 | |
} |
47 | |
|
48 | |
public List<LprEntity> getLprsByLuiPersonAndState(String personId, String luiId, String stateKey) { |
49 | 0 | return em.createQuery("from LuiPersonRelationEntity lpr where lpr.personId=:personId and lpr.luiId=:luiId and lpr.personRelationStateId=:stateKey") |
50 | |
.setParameter("personId", personId) |
51 | |
.setParameter("luiId", luiId) |
52 | |
.setParameter("stateKey", stateKey) |
53 | |
.getResultList(); |
54 | |
} |
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
public void mergeFromDto(LprEntity entity, LprInfo info) throws DoesNotExistException { |
65 | |
|
66 | 0 | List<Object> orphanedData = entity.fromDto(info); |
67 | |
|
68 | 0 | for (Object orphan : orphanedData) { |
69 | |
|
70 | 0 | em.remove(orphan); |
71 | |
} |
72 | |
|
73 | 0 | } |
74 | |
} |