1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.r2.core.class1.enumerationmanagement.dao; |
17 | |
|
18 | |
import java.util.Date; |
19 | |
import java.util.List; |
20 | |
|
21 | |
import org.kuali.student.enrollment.dao.GenericEntityDao; |
22 | |
import org.kuali.student.r2.core.class1.enumerationmanagement.model.EnumeratedValueEntity; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | 0 | public class EnumeratedValueDao extends GenericEntityDao<EnumeratedValueEntity> { |
30 | |
|
31 | |
@SuppressWarnings("unchecked") |
32 | |
public List<EnumeratedValueEntity> getByDate(String enumerationKey, Date contextDate) { |
33 | 0 | return em.createQuery("from EnumeratedValueEntity e where e.effectiveDate <= :contextDate and " + |
34 | |
"(e.expirationDate is null or e.expirationDate >= :contextDate) and e.enumeration.id = :enumerationKey ") |
35 | |
.setParameter("enumerationKey", enumerationKey).setParameter("contextDate", contextDate).getResultList(); |
36 | |
} |
37 | |
|
38 | |
@SuppressWarnings("unchecked") |
39 | |
public List<EnumeratedValueEntity> getByContextAndDate(String enumerationKey, String contextKey, String contextValue, Date contextDate) { |
40 | 0 | return em.createQuery("select e from EnumeratedValueEntity e , IN(e.contextValueEntities) c " + |
41 | |
"where e.effectiveDate <= :contextDate and (e.expirationDate is null or e.expirationDate >= :contextDate) and " + |
42 | |
"c.contextValue = :contextValue and c.contextKey = :enumContextKey and e.enumeration.id = :enumKey ") |
43 | |
.setParameter("contextDate", contextDate).setParameter("contextValue", contextValue).setParameter("enumContextKey", contextKey) |
44 | |
.setParameter("enumKey", enumerationKey).getResultList(); |
45 | |
} |
46 | |
|
47 | |
@SuppressWarnings("unchecked") |
48 | |
public List<EnumeratedValueEntity> getByContextTypeAndValue(String enumerationKey, String contextTypeKey, String contextValue) { |
49 | 0 | return em.createQuery("select e from EnumeratedValueEntity e JOIN e.contextValueEntities c " + |
50 | |
"where c.contextValue = :contextValue and c.contextKey = :enumContextKey and " + |
51 | |
"e.enumeration.id = :enumerationKey ").setParameter("enumerationKey", enumerationKey) |
52 | |
.setParameter("enumContextKey", contextTypeKey).setParameter("contextValue", contextValue).getResultList(); |
53 | |
} |
54 | |
|
55 | |
@SuppressWarnings("unchecked") |
56 | |
public List<EnumeratedValueEntity> getByEnumerationKey(String enumerationKey) { |
57 | 0 | return em.createQuery("from EnumeratedValueEntity e where e.enumeration.id = :enumerationKey ") |
58 | |
.setParameter("enumerationKey", enumerationKey).getResultList(); |
59 | |
} |
60 | |
|
61 | |
public EnumeratedValueEntity getByEnumerationKeyAndCode(String enumerationKey, String code) { |
62 | 0 | return (EnumeratedValueEntity) (em.createQuery("select e from EnumeratedValueEntity e where e.enumeration.id = :enumerationKey and e.code = :code") |
63 | |
.setParameter("enumerationKey", enumerationKey).setParameter("code", code).getSingleResult()); |
64 | |
|
65 | |
} |
66 | |
} |