1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.core.proposal.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.proposal.dao.ProposalDao; |
28 | |
import org.kuali.student.core.proposal.entity.Proposal; |
29 | |
import org.kuali.student.core.proposal.entity.ProposalOrg; |
30 | |
import org.kuali.student.core.proposal.entity.ProposalPerson; |
31 | |
import org.kuali.student.core.proposal.entity.ProposalReference; |
32 | |
import org.kuali.student.core.proposal.entity.ProposalType; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | 1 | public class ProposalDaoImpl extends AbstractSearchableCrudDaoImpl implements ProposalDao { |
41 | |
@PersistenceContext(unitName = "Proposal") |
42 | |
@Override |
43 | |
public void setEm(EntityManager em) { |
44 | 1 | super.setEm(em); |
45 | 1 | } |
46 | |
|
47 | |
@Override |
48 | |
public List<Proposal> getProposalsByIdList(List<String> idList) { |
49 | 2 | Query query = em.createNamedQuery("Proposal.getProposalsByIdList"); |
50 | 2 | query.setParameter("idList", idList); |
51 | |
@SuppressWarnings("unchecked") |
52 | 2 | List<Proposal> proposals = query.getResultList(); |
53 | 2 | return proposals; |
54 | |
} |
55 | |
|
56 | |
@Override |
57 | |
public List<Proposal> getProposalsByProposalType(String proposalTypeId) throws DoesNotExistException{ |
58 | 2 | Query query = em.createNamedQuery("Proposal.getProposalsByProposalType"); |
59 | 2 | query.setParameter("proposalTypeId", proposalTypeId); |
60 | |
@SuppressWarnings("unchecked") |
61 | 2 | List<Proposal> proposals = query.getResultList(); |
62 | 2 | return proposals; |
63 | |
} |
64 | |
|
65 | |
@Override |
66 | |
public List<Proposal> getProposalsByReference(String referenceTypeId, String referenceId) throws DoesNotExistException { |
67 | 3 | Query query = em.createNamedQuery("Proposal.getProposalsByReference"); |
68 | 3 | query.setParameter("referenceId", referenceId); |
69 | 3 | query.setParameter("referenceTypeId", referenceTypeId); |
70 | |
@SuppressWarnings("unchecked") |
71 | 3 | List<Proposal> proposals = query.getResultList(); |
72 | 3 | return proposals; |
73 | |
} |
74 | |
|
75 | |
@Override |
76 | |
public List<Proposal> getProposalsByState(String proposalState, String proposalTypeId) throws DoesNotExistException { |
77 | 3 | Query query = em.createNamedQuery("Proposal.getProposalsByState"); |
78 | 3 | query.setParameter("proposalState", proposalState); |
79 | 3 | query.setParameter("proposalTypeId", proposalTypeId); |
80 | |
@SuppressWarnings("unchecked") |
81 | 3 | List<Proposal> proposals = query.getResultList(); |
82 | 3 | return proposals; |
83 | |
} |
84 | |
|
85 | |
@Override |
86 | |
public Proposal getProposalByWorkflowId(String workflowId) |
87 | |
throws DoesNotExistException { |
88 | 0 | Query query = em.createNamedQuery("Proposal.getProposalByWorkflowId"); |
89 | 0 | query.setParameter("workflowId", workflowId); |
90 | |
|
91 | 0 | Proposal proposal = (Proposal)query.getSingleResult(); |
92 | 0 | return proposal; |
93 | |
} |
94 | |
|
95 | |
@Override |
96 | |
public List<ProposalType> getProposalTypesForReferenceType(String referenceTypeId) throws DoesNotExistException { |
97 | 2 | Query query = em.createNamedQuery("Proposal.getProposalTypesForReferenceType"); |
98 | 2 | query.setParameter("referenceTypeId", referenceTypeId); |
99 | |
@SuppressWarnings("unchecked") |
100 | 2 | List<ProposalType> proposalTypes = query.getResultList(); |
101 | 2 | return proposalTypes; |
102 | |
} |
103 | |
|
104 | |
|
105 | |
@Override |
106 | |
public ProposalPerson getProposalPerson(String proposerId) { |
107 | 0 | Query query = em.createNamedQuery("ProposalPerson.getProposalPerson"); |
108 | 0 | query.setParameter("proposerId", proposerId); |
109 | 0 | ProposalPerson proposalPerson = (ProposalPerson)query.getSingleResult(); |
110 | 0 | return proposalPerson; |
111 | |
} |
112 | |
|
113 | |
@Override |
114 | |
public ProposalOrg getProposalOrg(String orgId) throws NoResultException { |
115 | 0 | Query query = em.createNamedQuery("ProposalOrg.getProposalOrg"); |
116 | 0 | query.setParameter("orgId", orgId); |
117 | 0 | ProposalOrg proposalPerson = (ProposalOrg)query.getSingleResult(); |
118 | 0 | return proposalPerson; |
119 | |
} |
120 | |
|
121 | |
@Override |
122 | |
public ProposalReference getObjectReference(String objectReferenceId, String objectReferenceType) throws NoResultException { |
123 | 3 | Query query = em.createNamedQuery("ProposalReference.getObjectReference"); |
124 | 3 | query.setParameter("objectReferenceType", objectReferenceType); |
125 | 3 | query.setParameter("objectReferenceId", objectReferenceId); |
126 | 3 | ProposalReference objectReference = (ProposalReference)query.getSingleResult(); |
127 | 1 | return objectReference; |
128 | |
} |
129 | |
|
130 | |
@Override |
131 | |
public List<Proposal> getProposalsByRefernceIds(List<String> referenceIds) { |
132 | 0 | Query query = em.createNamedQuery("Proposal.getProposalsByRefernceIds"); |
133 | 0 | query.setParameter("referenceIds", referenceIds); |
134 | 0 | List<Proposal> proposals = query.getResultList(); |
135 | 0 | return proposals; |
136 | |
} |
137 | |
|
138 | |
} |