1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.core.statement.dao.impl; |
17 | |
|
18 | |
import java.util.List; |
19 | |
|
20 | |
import javax.persistence.EntityManager; |
21 | |
import javax.persistence.NoResultException; |
22 | |
import javax.persistence.PersistenceContext; |
23 | |
import javax.persistence.Query; |
24 | |
|
25 | |
import org.kuali.student.common.dao.impl.AbstractSearchableCrudDaoImpl; |
26 | |
import org.kuali.student.common.exceptions.DoesNotExistException; |
27 | |
import org.kuali.student.core.statement.dao.StatementDao; |
28 | |
import org.kuali.student.core.statement.entity.RefStatementRelation; |
29 | |
import org.kuali.student.core.statement.entity.ReqComponent; |
30 | |
import org.kuali.student.core.statement.entity.Statement; |
31 | |
|
32 | 14 | public class StatementDaoImpl extends AbstractSearchableCrudDaoImpl implements StatementDao { |
33 | |
|
34 | |
@PersistenceContext(unitName = "Statement") |
35 | |
@Override |
36 | |
public void setEm(EntityManager em) { |
37 | 1 | super.setEm(em); |
38 | 1 | } |
39 | |
|
40 | |
@Override |
41 | |
public List<ReqComponent> getReqComponents(List<String> reqComponentIdList) { |
42 | 0 | Query query = em.createNamedQuery("ReqComponent.getReqComponents"); |
43 | 0 | query.setParameter("reqComponentIdList", reqComponentIdList); |
44 | |
@SuppressWarnings("unchecked") |
45 | 0 | List<ReqComponent> resultList = query.getResultList(); |
46 | 0 | return resultList; |
47 | |
} |
48 | |
|
49 | |
@Override |
50 | |
public List<Statement> getStatements(List<String> statementIdList) { |
51 | 0 | Query query = em.createNamedQuery("Statement.getStatements"); |
52 | 0 | query.setParameter("statementIdList", statementIdList); |
53 | |
@SuppressWarnings("unchecked") |
54 | 0 | List<Statement> resultList = query.getResultList(); |
55 | 0 | return resultList; |
56 | |
} |
57 | |
|
58 | |
@Override |
59 | |
public List<ReqComponent> getReqComponentsByType(String reqComponentTypeKey) { |
60 | 2 | Query query = em.createNamedQuery("ReqComponent.getReqComponentsByType"); |
61 | 2 | query.setParameter("reqComponentTypeKey", reqComponentTypeKey); |
62 | |
@SuppressWarnings("unchecked") |
63 | 2 | List<ReqComponent> resultList = query.getResultList(); |
64 | 2 | return resultList; |
65 | |
} |
66 | |
|
67 | |
@Override |
68 | |
public List<Statement> getStatementsForStatementType(String statementTypeKey) { |
69 | 2 | Query query = em.createNamedQuery("Statement.getStatementsForStatementType"); |
70 | 2 | query.setParameter("statementTypeKey", statementTypeKey); |
71 | |
@SuppressWarnings("unchecked") |
72 | 2 | List<Statement> resultList = query.getResultList(); |
73 | 2 | return resultList; |
74 | |
} |
75 | |
|
76 | |
@Override |
77 | |
public List<Statement> getStatementsForReqComponent(String reqComponentId) { |
78 | 1 | Query query = em.createNamedQuery("Statement.getStatementsForReqComponent"); |
79 | 1 | query.setParameter("reqComponentId", reqComponentId); |
80 | |
@SuppressWarnings("unchecked") |
81 | 1 | List<Statement> resultList = query.getResultList(); |
82 | 1 | return resultList; |
83 | |
} |
84 | |
|
85 | |
@Override |
86 | |
public List<RefStatementRelation> getRefStatementRelations(String refObjectTypeKey, String refObjectId) { |
87 | 0 | Query query = em.createNamedQuery("RefStatementRelation.getRefStatementRelations"); |
88 | 0 | query.setParameter("refObjectTypeKey", refObjectTypeKey); |
89 | 0 | query.setParameter("refObjectId", refObjectId); |
90 | |
@SuppressWarnings("unchecked") |
91 | 0 | List<RefStatementRelation> resultList = query.getResultList(); |
92 | 0 | return resultList; |
93 | |
} |
94 | |
|
95 | |
@Override |
96 | |
public Statement getParentStatement(String childId) throws DoesNotExistException { |
97 | 2 | Query query = em.createNamedQuery("Statement.getParentStatement"); |
98 | 2 | query.setParameter("childId", childId); |
99 | |
try{ |
100 | 2 | return (Statement)query.getSingleResult(); |
101 | 1 | }catch(NoResultException e){ |
102 | 1 | throw new DoesNotExistException("No entity for key '" + childId + "' found",e); |
103 | |
} |
104 | |
} |
105 | |
|
106 | |
@Override |
107 | |
public List<Object[]> getStatementsWithDependencies( |
108 | |
List<String> cluVersionIndIds, List<String> cluSetIds) { |
109 | 0 | Query query = em.createNamedQuery("Statement.getStatementsWithDependencies"); |
110 | 0 | query.setParameter("cluVersionIndIds", cluVersionIndIds); |
111 | 0 | query.setParameter("cluSetIds", cluSetIds); |
112 | |
@SuppressWarnings("unchecked") |
113 | 0 | List<Object[]> resultList = query.getResultList(); |
114 | 0 | return resultList; |
115 | |
} |
116 | |
} |