1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.enrollment.class1.hold.service.impl; |
17 | |
|
18 | |
import org.kuali.rice.core.api.criteria.QueryByCriteria; |
19 | |
import org.kuali.student.enrollment.class1.hold.dao.HoldDao; |
20 | |
import org.kuali.student.enrollment.class1.hold.dao.HoldIssueDao; |
21 | |
import org.kuali.student.enrollment.class1.hold.model.HoldEntity; |
22 | |
import org.kuali.student.enrollment.class1.hold.model.HoldIssueEntity; |
23 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
24 | |
import org.kuali.student.r2.common.dto.StatusInfo; |
25 | |
import org.kuali.student.r2.common.dto.ValidationResultInfo; |
26 | |
import org.kuali.student.r2.common.exceptions.*; |
27 | |
import org.kuali.student.r2.common.util.constants.HoldServiceConstants; |
28 | |
import org.kuali.student.r2.core.hold.dto.HoldInfo; |
29 | |
import org.kuali.student.r2.core.hold.dto.IssueInfo; |
30 | |
import org.kuali.student.r2.core.hold.service.HoldService; |
31 | |
import org.springframework.transaction.annotation.Transactional; |
32 | |
|
33 | |
import javax.jws.WebService; |
34 | |
import javax.persistence.PersistenceException; |
35 | |
import java.util.ArrayList; |
36 | |
import java.util.List; |
37 | |
|
38 | |
@WebService(name = "HoldService", serviceName = "HoldService", portName = "HoldService", targetNamespace = "http://student.kuali.org/wsdl/hold") |
39 | |
@Transactional(readOnly = true, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
40 | 0 | public class HoldServiceImpl implements HoldService { |
41 | |
|
42 | |
private HoldIssueDao holdIssueDao; |
43 | |
private HoldDao holdDao; |
44 | |
|
45 | |
public HoldIssueDao getHoldIssueDao() { |
46 | 0 | return holdIssueDao; |
47 | |
} |
48 | |
|
49 | |
public void setHoldIssueDao(HoldIssueDao holdIssueDao) { |
50 | 0 | this.holdIssueDao = holdIssueDao; |
51 | 0 | } |
52 | |
|
53 | |
public HoldDao getHoldDao() { |
54 | 0 | return holdDao; |
55 | |
} |
56 | |
|
57 | |
public void setHoldDao(HoldDao holdDao) { |
58 | 0 | this.holdDao = holdDao; |
59 | 0 | } |
60 | |
|
61 | |
@Override |
62 | |
public HoldInfo getHold(String holdId, ContextInfo context) throws DoesNotExistException, |
63 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
64 | 0 | HoldEntity entity = holdDao.find(holdId); |
65 | |
|
66 | 0 | if (entity == null) { |
67 | 0 | throw new DoesNotExistException(holdId); |
68 | |
} |
69 | |
|
70 | 0 | return entity.toDto(); |
71 | |
} |
72 | |
|
73 | |
@Override |
74 | |
public List<String> searchForHoldIds(QueryByCriteria criteria, ContextInfo context) |
75 | |
throws InvalidParameterException, MissingParameterException, OperationFailedException, |
76 | |
PermissionDeniedException { |
77 | |
|
78 | 0 | return new ArrayList<String>(); |
79 | |
} |
80 | |
|
81 | |
@Override |
82 | |
public List<HoldInfo> searchForHolds(QueryByCriteria criteria, ContextInfo context) |
83 | |
throws InvalidParameterException, MissingParameterException, OperationFailedException, |
84 | |
PermissionDeniedException { |
85 | |
|
86 | 0 | return new ArrayList<HoldInfo>(); |
87 | |
} |
88 | |
|
89 | |
@Override |
90 | |
public List<ValidationResultInfo> validateHold(String validationTypeKey, HoldInfo holdInfo, ContextInfo context) |
91 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
92 | |
OperationFailedException { |
93 | 0 | return new ArrayList<ValidationResultInfo>(); |
94 | |
} |
95 | |
|
96 | |
@Override |
97 | |
@Transactional |
98 | |
public HoldInfo createHold(String personId, |
99 | |
String issueId, |
100 | |
String holdTypeKey, |
101 | |
HoldInfo holdInfo, |
102 | |
ContextInfo context) throws AlreadyExistsException, |
103 | |
DataValidationErrorException, InvalidParameterException, MissingParameterException, |
104 | |
OperationFailedException, PermissionDeniedException { |
105 | 0 | if (!personId.equals(holdInfo.getPersonId())) { |
106 | 0 | throw new InvalidParameterException(personId + " does not match the person Id in the object " + holdInfo.getPersonId()); |
107 | |
} |
108 | 0 | if (!issueId.equals(holdInfo.getIssueId())) { |
109 | 0 | throw new InvalidParameterException(issueId + " does not match the issueId in the object " + holdInfo.getIssueId()); |
110 | |
} |
111 | 0 | if (!holdTypeKey.equals(holdInfo.getTypeKey())) { |
112 | 0 | throw new InvalidParameterException(holdTypeKey + " does not match the hold type key in the object " + holdInfo.getTypeKey()); |
113 | |
} |
114 | 0 | HoldEntity entity = new HoldEntity(holdInfo); |
115 | 0 | entity.setHoldIssue(holdIssueDao.find(issueId)); |
116 | 0 | if (entity.getHoldIssue() == null) { |
117 | 0 | throw new InvalidParameterException(issueId); |
118 | |
} |
119 | |
|
120 | 0 | entity.setEntityCreated(context); |
121 | |
|
122 | 0 | holdDao.persist(entity); |
123 | 0 | return entity.toDto(); |
124 | |
} |
125 | |
|
126 | |
@Override |
127 | |
@Transactional |
128 | |
public HoldInfo updateHold(String holdId, HoldInfo holdInfo, ContextInfo context) |
129 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, |
130 | |
MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException { |
131 | 0 | if (!holdId.equals(holdInfo.getId())) { |
132 | 0 | throw new InvalidParameterException(holdId + " does not match the id in the object " + holdInfo.getId()); |
133 | |
} |
134 | 0 | HoldEntity entity = holdDao.find(holdId); |
135 | 0 | if (null == entity) { |
136 | 0 | throw new DoesNotExistException(holdId); |
137 | |
} |
138 | 0 | entity.fromDto(holdInfo); |
139 | |
|
140 | 0 | entity.setEntityUpdated(context); |
141 | |
|
142 | 0 | holdDao.merge(entity); |
143 | 0 | return entity.toDto(); |
144 | |
} |
145 | |
|
146 | |
@Override |
147 | |
@Transactional |
148 | |
public HoldInfo releaseHold(String holdId, ContextInfo context) throws DoesNotExistException, |
149 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
150 | 0 | HoldInfo info = this.getHold(holdId, context); |
151 | 0 | info.setStateKey(HoldServiceConstants.HOLD_RELEASED_STATE_KEY); |
152 | |
try { |
153 | 0 | return updateHold(holdId, info, context); |
154 | 0 | } catch (DataValidationErrorException ex) { |
155 | 0 | throw new OperationFailedException("unexpected", ex); |
156 | 0 | } catch (VersionMismatchException ex) { |
157 | 0 | throw new OperationFailedException("unexpected", ex); |
158 | |
} |
159 | |
} |
160 | |
|
161 | |
@Override |
162 | |
@Transactional |
163 | |
public StatusInfo deleteHold(String holdId, ContextInfo context) throws DoesNotExistException, |
164 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
165 | 0 | HoldEntity entity = holdDao.find(holdId); |
166 | 0 | if (null == entity) { |
167 | 0 | throw new DoesNotExistException(holdId); |
168 | |
} |
169 | 0 | holdDao.remove(entity); |
170 | 0 | StatusInfo status = new StatusInfo(); |
171 | 0 | status.setSuccess(Boolean.TRUE); |
172 | 0 | return status; |
173 | |
} |
174 | |
|
175 | |
@Override |
176 | |
public IssueInfo getIssue(String issueId, ContextInfo context) throws DoesNotExistException, |
177 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
178 | 0 | HoldIssueEntity entity = holdIssueDao.find(issueId); |
179 | 0 | if (entity == null) { |
180 | 0 | throw new DoesNotExistException(issueId); |
181 | |
} |
182 | 0 | return entity.toDto(); |
183 | |
} |
184 | |
|
185 | |
@Override |
186 | |
public List<String> getIssueIdsByType(String issueTypeKey, ContextInfo context) throws InvalidParameterException, |
187 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
188 | 0 | return new ArrayList<String>(); |
189 | |
} |
190 | |
|
191 | |
@Override |
192 | |
public List<IssueInfo> getIssuesByOrg(String organizationId, ContextInfo context) throws InvalidParameterException, |
193 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
194 | 0 | List<HoldIssueEntity> holdIssues = holdIssueDao.getByOrganizationId(organizationId); |
195 | |
|
196 | 0 | List<IssueInfo> results = new ArrayList<IssueInfo>(holdIssues.size()); |
197 | |
|
198 | 0 | for (HoldIssueEntity holdIssue : holdIssues) { |
199 | 0 | results.add(holdIssue.toDto()); |
200 | |
} |
201 | |
|
202 | 0 | return results; |
203 | |
} |
204 | |
|
205 | |
@Override |
206 | |
public List<String> searchForIssueIds(QueryByCriteria criteria, ContextInfo context) |
207 | |
throws InvalidParameterException, MissingParameterException, OperationFailedException, |
208 | |
PermissionDeniedException { |
209 | |
|
210 | 0 | return new ArrayList<String>(); |
211 | |
} |
212 | |
|
213 | |
@Override |
214 | |
public List<IssueInfo> searchForIssues(QueryByCriteria criteria, ContextInfo context) |
215 | |
throws InvalidParameterException, MissingParameterException, OperationFailedException, |
216 | |
PermissionDeniedException { |
217 | |
|
218 | 0 | return new ArrayList<IssueInfo>(); |
219 | |
} |
220 | |
|
221 | |
@Override |
222 | |
public List<ValidationResultInfo> validateIssue(String validationTypeKey, IssueInfo issueInfo, ContextInfo context) |
223 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
224 | |
OperationFailedException { |
225 | 0 | return new ArrayList<ValidationResultInfo>(); |
226 | |
} |
227 | |
|
228 | |
@Override |
229 | |
@Transactional |
230 | |
public IssueInfo createIssue(String issueTypeKey, IssueInfo issueInfo, ContextInfo context) |
231 | |
throws AlreadyExistsException, |
232 | |
DataValidationErrorException, InvalidParameterException, MissingParameterException, |
233 | |
OperationFailedException, PermissionDeniedException { |
234 | 0 | if (!issueTypeKey.equals(issueInfo.getTypeKey())) { |
235 | 0 | throw new InvalidParameterException(issueTypeKey + " does not match type in object " + issueInfo.getTypeKey()); |
236 | |
} |
237 | 0 | HoldIssueEntity entity = new HoldIssueEntity(issueInfo); |
238 | |
|
239 | 0 | entity.setEntityCreated(context); |
240 | |
|
241 | 0 | holdIssueDao.persist(entity); |
242 | 0 | return entity.toDto(); |
243 | |
} |
244 | |
|
245 | |
@Override |
246 | |
@Transactional |
247 | |
public IssueInfo updateIssue(String issueId, IssueInfo issueInfo, ContextInfo context) |
248 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, |
249 | |
MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException { |
250 | 0 | if (!issueId.equals(issueInfo.getId())) { |
251 | 0 | throw new InvalidParameterException(issueId + " does not match the id in the object " + issueInfo.getId()); |
252 | |
} |
253 | 0 | HoldIssueEntity entity = holdIssueDao.find(issueId); |
254 | 0 | if (null == entity) { |
255 | 0 | throw new DoesNotExistException(issueId); |
256 | |
} |
257 | 0 | entity.fromDto(issueInfo); |
258 | |
|
259 | 0 | entity.setEntityUpdated(context); |
260 | |
|
261 | 0 | holdIssueDao.merge(entity); |
262 | 0 | return entity.toDto(); |
263 | |
} |
264 | |
|
265 | |
@Override |
266 | |
@Transactional |
267 | |
public StatusInfo deleteIssue(String issueId, ContextInfo context) throws DoesNotExistException, |
268 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
269 | 0 | HoldIssueEntity entity = holdIssueDao.find(issueId); |
270 | 0 | if (null == entity) { |
271 | 0 | throw new DoesNotExistException(issueId); |
272 | |
} |
273 | 0 | holdIssueDao.remove(entity); |
274 | 0 | StatusInfo status = new StatusInfo(); |
275 | 0 | status.setSuccess(Boolean.TRUE); |
276 | 0 | return status; |
277 | |
} |
278 | |
|
279 | |
@Override |
280 | |
public List<HoldInfo> getHoldsByIds(List<String> holdIds, ContextInfo contextInfo) throws DoesNotExistException, |
281 | |
InvalidParameterException, MissingParameterException, OperationFailedException, |
282 | |
PermissionDeniedException { |
283 | |
|
284 | 0 | return null; |
285 | |
} |
286 | |
|
287 | |
@Override |
288 | |
public List<String> getHoldIdsByType(String holdTypeKey, ContextInfo contextInfo) throws InvalidParameterException, |
289 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
290 | |
|
291 | 0 | return null; |
292 | |
} |
293 | |
|
294 | |
@Override |
295 | |
public List<HoldInfo> getHoldsByIssue(String issueId, ContextInfo contextInfo) throws InvalidParameterException, |
296 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
297 | |
|
298 | 0 | return null; |
299 | |
} |
300 | |
|
301 | |
@Override |
302 | |
public List<HoldInfo> getHoldsByPerson(String personId, ContextInfo contextInfo) throws InvalidParameterException, |
303 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
304 | |
|
305 | 0 | return null; |
306 | |
} |
307 | |
|
308 | |
@Override |
309 | |
public List<HoldInfo> getActiveHoldsByPerson(String personId, ContextInfo contextInfo) |
310 | |
throws InvalidParameterException, MissingParameterException, OperationFailedException, |
311 | |
PermissionDeniedException { |
312 | |
|
313 | 0 | return null; |
314 | |
} |
315 | |
|
316 | |
@Override |
317 | |
public List<HoldInfo> getHoldsByIssueAndPerson(String issueId, String personId, ContextInfo contextInfo) |
318 | |
throws InvalidParameterException, MissingParameterException, OperationFailedException, |
319 | |
PermissionDeniedException { |
320 | |
|
321 | 0 | return null; |
322 | |
} |
323 | |
|
324 | |
@Override |
325 | |
public List<HoldInfo> getActiveHoldsByIssueAndPerson(String issueId, String personId, ContextInfo contextInfo) |
326 | |
throws InvalidParameterException, MissingParameterException, |
327 | |
OperationFailedException, PermissionDeniedException { |
328 | |
|
329 | 0 | return null; |
330 | |
} |
331 | |
|
332 | |
@Override |
333 | |
public List<IssueInfo> getIssuesByIds(List<String> issueIds, ContextInfo contextInfo) throws DoesNotExistException, |
334 | |
InvalidParameterException, MissingParameterException, OperationFailedException, |
335 | |
PermissionDeniedException { |
336 | 0 | List<HoldIssueEntity> holdIssues = holdIssueDao.findByIds(issueIds); |
337 | |
|
338 | 0 | if (holdIssues == null) { |
339 | 0 | throw new DoesNotExistException(); |
340 | |
} |
341 | |
|
342 | 0 | List<IssueInfo> result = new ArrayList<IssueInfo>(holdIssues.size()); |
343 | 0 | for (HoldIssueEntity entity : holdIssues) { |
344 | 0 | if (entity == null) { |
345 | |
|
346 | 0 | throw new DoesNotExistException(); |
347 | |
} |
348 | 0 | result.add(entity.toDto()); |
349 | |
} |
350 | |
|
351 | 0 | return result; |
352 | |
} |
353 | |
} |