1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.r1.lum.lrc.dao.impl;
17
18 import java.util.List;
19
20 import javax.persistence.EntityManager;
21 import javax.persistence.EntityNotFoundException;
22 import javax.persistence.NoResultException;
23 import javax.persistence.PersistenceContext;
24 import javax.persistence.Query;
25
26 import org.kuali.student.r1.common.dao.impl.AbstractSearchableCrudDaoImpl;
27 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
28 import org.kuali.student.r1.lum.lrc.dao.LrcDao;
29 import org.kuali.student.r1.lum.lrc.entity.ResultComponentType;
30
31 public class LrcDaoImpl extends AbstractSearchableCrudDaoImpl implements LrcDao {
32 @PersistenceContext(unitName = "Lrc")
33 @Override
34 public void setEm(EntityManager em) {
35 super.setEm(em);
36 }
37
38 @Override
39 public List<String> getResultComponentIdsByResult(String resultValueId) {
40 Query query = em.createNamedQuery("ResultComponent.getResultComponentIdsByResult");
41 query.setParameter("resultValueId", resultValueId);
42 @SuppressWarnings("unchecked")
43 List<String> resultList = query.getResultList();
44 return resultList;
45 }
46
47 @Override
48 public List<String> getResultComponentIdsByResultComponentType(String resultComponentTypeKey) {
49 Query query = em.createNamedQuery("ResultComponent.getResultComponentIdsByResultComponentType");
50 query.setParameter("resultComponentTypeKey", resultComponentTypeKey);
51 @SuppressWarnings("unchecked")
52 List<String> resultList = query.getResultList();
53 return resultList;
54 }
55
56 @Override
57 public ResultComponentType getResultComponentType(String resultComponentTypeKey) throws DoesNotExistException {
58 Query query = em.createNamedQuery("ResultComponent.getResultComponentType");
59 query.setParameter("resultComponentTypeKey", resultComponentTypeKey);
60 try {
61 return (ResultComponentType)query.getSingleResult();
62 } catch (NoResultException e) {
63 throw new DoesNotExistException();
64 } catch (EntityNotFoundException e){
65 throw new DoesNotExistException();
66 }
67 }
68 }