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