1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.lum.lrc.service.impl; |
17 | |
|
18 | |
import java.util.List; |
19 | |
|
20 | |
import javax.jws.WebService; |
21 | |
|
22 | |
import org.kuali.student.common.dictionary.dto.ObjectStructureDefinition; |
23 | |
import org.kuali.student.common.dictionary.service.DictionaryService; |
24 | |
import org.kuali.student.common.dto.StatusInfo; |
25 | |
import org.kuali.student.common.exceptions.AlreadyExistsException; |
26 | |
import org.kuali.student.common.exceptions.DataValidationErrorException; |
27 | |
import org.kuali.student.common.exceptions.DoesNotExistException; |
28 | |
import org.kuali.student.common.exceptions.InvalidParameterException; |
29 | |
import org.kuali.student.common.exceptions.MissingParameterException; |
30 | |
import org.kuali.student.common.exceptions.OperationFailedException; |
31 | |
import org.kuali.student.common.exceptions.PermissionDeniedException; |
32 | |
import org.kuali.student.common.exceptions.VersionMismatchException; |
33 | |
import org.kuali.student.common.search.dto.SearchCriteriaTypeInfo; |
34 | |
import org.kuali.student.common.search.dto.SearchRequest; |
35 | |
import org.kuali.student.common.search.dto.SearchResult; |
36 | |
import org.kuali.student.common.search.dto.SearchResultTypeInfo; |
37 | |
import org.kuali.student.common.search.dto.SearchTypeInfo; |
38 | |
import org.kuali.student.common.search.service.SearchManager; |
39 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo; |
40 | |
import org.kuali.student.common.validator.Validator; |
41 | |
import org.kuali.student.common.validator.ValidatorFactory; |
42 | |
import org.kuali.student.lum.lrc.dao.LrcDao; |
43 | |
import org.kuali.student.lum.lrc.dto.CredentialInfo; |
44 | |
import org.kuali.student.lum.lrc.dto.CredentialTypeInfo; |
45 | |
import org.kuali.student.lum.lrc.dto.CreditInfo; |
46 | |
import org.kuali.student.lum.lrc.dto.CreditTypeInfo; |
47 | |
import org.kuali.student.lum.lrc.dto.GradeInfo; |
48 | |
import org.kuali.student.lum.lrc.dto.GradeTypeInfo; |
49 | |
import org.kuali.student.lum.lrc.dto.ResultComponentInfo; |
50 | |
import org.kuali.student.lum.lrc.dto.ResultComponentTypeInfo; |
51 | |
import org.kuali.student.lum.lrc.dto.ScaleInfo; |
52 | |
import org.kuali.student.lum.lrc.entity.ResultComponent; |
53 | |
import org.kuali.student.lum.lrc.entity.ResultComponentType; |
54 | |
import org.kuali.student.lum.lrc.entity.Scale; |
55 | |
import org.kuali.student.lum.lrc.service.LrcService; |
56 | |
import org.springframework.transaction.annotation.Transactional; |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
@WebService(endpointInterface = "org.kuali.student.lum.lrc.service.LrcService", serviceName = "LrcService", portName = "LrcService", targetNamespace = "http://student.kuali.org/wsdl/lrc") |
63 | |
@Transactional(readOnly=true,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
64 | 8 | public class LrcServiceImpl implements LrcService { |
65 | |
private LrcDao lrcDao; |
66 | |
private SearchManager searchManager; |
67 | |
private DictionaryService dictionaryServiceDelegate; |
68 | |
private ValidatorFactory validatorFactory; |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
@Override |
75 | |
public String compareGrades(String gradeKey, String scaleKey, |
76 | |
String compareGradeKey, String compareScaleKey) |
77 | |
throws InvalidParameterException, MissingParameterException, |
78 | |
OperationFailedException { |
79 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
80 | |
} |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
@Override |
86 | |
@Transactional(readOnly=false) |
87 | |
public ResultComponentInfo createResultComponent( |
88 | |
String resultComponentTypeKey, |
89 | |
ResultComponentInfo resultComponentInfo) |
90 | |
throws AlreadyExistsException, DataValidationErrorException, |
91 | |
DoesNotExistException, InvalidParameterException, |
92 | |
MissingParameterException, OperationFailedException, |
93 | |
PermissionDeniedException { |
94 | 7 | checkForMissingParameter(resultComponentTypeKey, "resultComponentTypeKey"); |
95 | 6 | checkForMissingParameter(resultComponentInfo, "resultComponentInfo"); |
96 | |
|
97 | |
|
98 | 5 | ObjectStructureDefinition objStructure = this.getObjectStructure(ResultComponentInfo.class.getName()); |
99 | 5 | Validator defaultValidator = validatorFactory.getValidator(); |
100 | 5 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(resultComponentInfo, objStructure); |
101 | |
|
102 | 5 | if (null != validationResults && validationResults.size() > 0) { |
103 | 0 | throw new DataValidationErrorException("Validation error!", validationResults); |
104 | |
} |
105 | |
|
106 | 5 | ResultComponent rc = LrcServiceAssembler.toResultComponent(resultComponentTypeKey, resultComponentInfo, lrcDao); |
107 | 5 | lrcDao.create(rc); |
108 | 5 | return LrcServiceAssembler.toResultComponentInfo(rc); |
109 | |
} |
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
@Override |
115 | |
@Transactional(readOnly=false) |
116 | |
public StatusInfo deleteResultComponent(String resultComponentId) |
117 | |
throws DoesNotExistException, InvalidParameterException, |
118 | |
MissingParameterException, OperationFailedException, |
119 | |
PermissionDeniedException { |
120 | 3 | checkForMissingParameter(resultComponentId, "resultComponentId"); |
121 | 2 | lrcDao.delete(ResultComponent.class, resultComponentId); |
122 | 1 | StatusInfo statusInfo = new StatusInfo(); |
123 | 1 | return statusInfo; |
124 | |
} |
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
@Override |
130 | |
public CredentialInfo getCredential(String credentialKey) |
131 | |
throws DoesNotExistException, InvalidParameterException, |
132 | |
MissingParameterException, OperationFailedException { |
133 | 0 | throw new UnsupportedOperationException(); |
134 | |
} |
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
@Override |
140 | |
public List<String> getCredentialKeysByCredentialType( |
141 | |
String credentialTypeKey) throws DoesNotExistException, |
142 | |
InvalidParameterException, MissingParameterException, |
143 | |
OperationFailedException { |
144 | 0 | throw new UnsupportedOperationException(); |
145 | |
} |
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
@Override |
151 | |
public CredentialTypeInfo getCredentialType(String credentialTypeKey) |
152 | |
throws DoesNotExistException, InvalidParameterException, |
153 | |
MissingParameterException, OperationFailedException { |
154 | 0 | throw new UnsupportedOperationException(); |
155 | |
} |
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
@Override |
161 | |
public List<CredentialTypeInfo> getCredentialTypes() |
162 | |
throws OperationFailedException { |
163 | 0 | throw new UnsupportedOperationException(); |
164 | |
} |
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
@Override |
170 | |
public List<CredentialInfo> getCredentialsByKeyList( |
171 | |
List<String> credentialKeyList) throws DoesNotExistException, |
172 | |
InvalidParameterException, MissingParameterException, |
173 | |
OperationFailedException { |
174 | 0 | throw new UnsupportedOperationException(); |
175 | |
} |
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | |
@Override |
181 | |
public CreditInfo getCredit(String creditKey) throws DoesNotExistException, |
182 | |
InvalidParameterException, MissingParameterException, |
183 | |
OperationFailedException { |
184 | 0 | throw new UnsupportedOperationException(); |
185 | |
} |
186 | |
|
187 | |
|
188 | |
|
189 | |
|
190 | |
@Override |
191 | |
public List<String> getCreditKeysByCreditType(String creditTypeKey) |
192 | |
throws DoesNotExistException, InvalidParameterException, |
193 | |
MissingParameterException, OperationFailedException { |
194 | 0 | throw new UnsupportedOperationException(); |
195 | |
} |
196 | |
|
197 | |
|
198 | |
|
199 | |
|
200 | |
@Override |
201 | |
public CreditTypeInfo getCreditType(String creditTypeKey) |
202 | |
throws DoesNotExistException, InvalidParameterException, |
203 | |
MissingParameterException, OperationFailedException { |
204 | 0 | throw new UnsupportedOperationException(); |
205 | |
} |
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | |
@Override |
211 | |
public List<CreditTypeInfo> getCreditTypes() |
212 | |
throws OperationFailedException { |
213 | 0 | throw new UnsupportedOperationException(); |
214 | |
} |
215 | |
|
216 | |
|
217 | |
|
218 | |
|
219 | |
@Override |
220 | |
public List<CreditInfo> getCreditsByKeyList(List<String> creditKeyList) |
221 | |
throws DoesNotExistException, InvalidParameterException, |
222 | |
MissingParameterException, OperationFailedException { |
223 | 0 | throw new UnsupportedOperationException(); |
224 | |
} |
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | |
@Override |
230 | |
public GradeInfo getGrade(String gradeKey) throws DoesNotExistException, |
231 | |
InvalidParameterException, MissingParameterException, |
232 | |
OperationFailedException { |
233 | 0 | throw new UnsupportedOperationException(); |
234 | |
} |
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
@Override |
240 | |
public List<String> getGradeKeysByGradeType(String gradeTypeKey) |
241 | |
throws DoesNotExistException, InvalidParameterException, |
242 | |
MissingParameterException, OperationFailedException { |
243 | 0 | throw new UnsupportedOperationException(); |
244 | |
} |
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
@Override |
250 | |
public GradeTypeInfo getGradeType(String gradeTypeKey) |
251 | |
throws DoesNotExistException, InvalidParameterException, |
252 | |
MissingParameterException, OperationFailedException { |
253 | 0 | throw new UnsupportedOperationException(); |
254 | |
} |
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
@Override |
260 | |
public List<GradeTypeInfo> getGradeTypes() throws OperationFailedException { |
261 | 0 | throw new UnsupportedOperationException(); |
262 | |
} |
263 | |
|
264 | |
|
265 | |
|
266 | |
|
267 | |
@Override |
268 | |
public List<GradeInfo> getGradesByKeyList(List<String> gradeKeyList) |
269 | |
throws DoesNotExistException, InvalidParameterException, |
270 | |
MissingParameterException, OperationFailedException { |
271 | 0 | throw new UnsupportedOperationException(); |
272 | |
} |
273 | |
|
274 | |
|
275 | |
|
276 | |
@Override |
277 | |
public List<GradeInfo> getGradesByScale(String scale) |
278 | |
throws DoesNotExistException, InvalidParameterException, |
279 | |
MissingParameterException, OperationFailedException { |
280 | 0 | throw new UnsupportedOperationException(); |
281 | |
} |
282 | |
|
283 | |
|
284 | |
|
285 | |
|
286 | |
@Override |
287 | |
public ResultComponentInfo getResultComponent(String resultComponentId) |
288 | |
throws DoesNotExistException, InvalidParameterException, |
289 | |
MissingParameterException, OperationFailedException { |
290 | 106 | checkForMissingParameter(resultComponentId, "resultComponentId"); |
291 | 105 | ResultComponent resultComponent = lrcDao.fetch(ResultComponent.class, resultComponentId); |
292 | |
|
293 | 104 | return LrcServiceAssembler.toResultComponentInfo(resultComponent); |
294 | |
} |
295 | |
|
296 | |
|
297 | |
|
298 | |
|
299 | |
@Override |
300 | |
public List<String> getResultComponentIdsByResult(String resultValueId, |
301 | |
String resultComponentTypeKey) throws DoesNotExistException, |
302 | |
InvalidParameterException, MissingParameterException, |
303 | |
OperationFailedException { |
304 | 5 | checkForMissingParameter(resultValueId, "resultValueId"); |
305 | 4 | checkForMissingParameter(resultComponentTypeKey, "resultComponentTypeKey"); |
306 | 3 | List<String> ids = lrcDao.getResultComponentIdsByResult(resultValueId, resultComponentTypeKey); |
307 | 3 | return ids; |
308 | |
} |
309 | |
|
310 | |
|
311 | |
|
312 | |
|
313 | |
@Override |
314 | |
public List<String> getResultComponentIdsByResultComponentType( |
315 | |
String resultComponentTypeKey) throws DoesNotExistException, |
316 | |
InvalidParameterException, MissingParameterException, |
317 | |
OperationFailedException { |
318 | 120 | checkForMissingParameter(resultComponentTypeKey, "resultComponentTypeKey"); |
319 | 119 | List<String> ids = lrcDao.getResultComponentIdsByResultComponentType(resultComponentTypeKey); |
320 | 119 | return ids; |
321 | |
} |
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
@Override |
327 | |
public ResultComponentTypeInfo getResultComponentType( |
328 | |
String resultComponentTypeKey) throws DoesNotExistException, |
329 | |
InvalidParameterException, MissingParameterException, |
330 | |
OperationFailedException { |
331 | 2 | checkForMissingParameter(resultComponentTypeKey, "resultComponentTypeKey"); |
332 | 2 | ResultComponentType entity = lrcDao.getResultComponentType(resultComponentTypeKey); |
333 | 1 | return LrcServiceAssembler.toResultComponentTypeInfo(entity); |
334 | |
} |
335 | |
|
336 | |
|
337 | |
|
338 | |
|
339 | |
@Override |
340 | |
public List<ResultComponentTypeInfo> getResultComponentTypes() |
341 | |
throws OperationFailedException { |
342 | 10 | List<ResultComponentType> rct = lrcDao.find(ResultComponentType.class); |
343 | 10 | return LrcServiceAssembler.toResultComponentTypeInfos(rct); |
344 | |
} |
345 | |
|
346 | |
|
347 | |
|
348 | |
|
349 | |
@Override |
350 | |
public ScaleInfo getScale(String scaleKey) throws DoesNotExistException, |
351 | |
InvalidParameterException, MissingParameterException, |
352 | |
OperationFailedException { |
353 | 0 | checkForMissingParameter(scaleKey, "scaleKey"); |
354 | 0 | Scale scale = lrcDao.fetch(Scale.class, scaleKey); |
355 | 0 | return LrcServiceAssembler.toScaleInfo(scale); |
356 | |
} |
357 | |
|
358 | |
|
359 | |
|
360 | |
|
361 | |
@Override |
362 | |
public List<GradeInfo> translateGrade(String gradeKey, String scaleKey, |
363 | |
String translateScaleKey) throws InvalidParameterException, |
364 | |
MissingParameterException, OperationFailedException { |
365 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
366 | |
} |
367 | |
|
368 | |
|
369 | |
|
370 | |
|
371 | |
@Override |
372 | |
@Transactional(readOnly=false) |
373 | |
public ResultComponentInfo updateResultComponent(String resultComponentId, |
374 | |
ResultComponentInfo resultComponentInfo) |
375 | |
throws DataValidationErrorException, DoesNotExistException, |
376 | |
InvalidParameterException, MissingParameterException, |
377 | |
OperationFailedException, PermissionDeniedException, |
378 | |
VersionMismatchException { |
379 | 5 | checkForMissingParameter(resultComponentId, "resultComponentId"); |
380 | 4 | checkForMissingParameter(resultComponentInfo, "resultComponentInfo"); |
381 | |
|
382 | |
|
383 | 3 | ObjectStructureDefinition objStructure = this.getObjectStructure(ResultComponentInfo.class.getName()); |
384 | 3 | Validator defaultValidator = validatorFactory.getValidator(); |
385 | 3 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(resultComponentInfo, objStructure); |
386 | |
|
387 | 3 | if (null != validationResults && validationResults.size() > 0) { |
388 | 0 | throw new DataValidationErrorException("Validation error!", validationResults); |
389 | |
} |
390 | |
|
391 | 3 | ResultComponent entity = lrcDao.fetch(ResultComponent.class, resultComponentId); |
392 | |
|
393 | 3 | if (!String.valueOf(entity.getVersionNumber()).equals(resultComponentInfo.getMetaInfo().getVersionInd())){ |
394 | 1 | throw new VersionMismatchException("ResultComponent to be updated is not the current version"); |
395 | |
} |
396 | |
|
397 | 2 | LrcServiceAssembler.toResultComponent(entity, resultComponentInfo, lrcDao); |
398 | 2 | lrcDao.update(entity); |
399 | 2 | return LrcServiceAssembler.toResultComponentInfo(entity); |
400 | |
} |
401 | |
|
402 | |
|
403 | |
|
404 | |
|
405 | |
public LrcDao getLrcDao() { |
406 | 0 | return lrcDao; |
407 | |
} |
408 | |
|
409 | |
|
410 | |
|
411 | |
|
412 | |
public void setLrcDao(LrcDao lrcDao) { |
413 | 4 | this.lrcDao = lrcDao; |
414 | 4 | } |
415 | |
|
416 | |
|
417 | |
|
418 | |
|
419 | |
|
420 | |
|
421 | |
|
422 | |
|
423 | |
private void checkForMissingParameter(Object param, String paramName) |
424 | |
throws MissingParameterException { |
425 | 262 | if (param == null) { |
426 | 9 | throw new MissingParameterException(paramName + " can not be null"); |
427 | |
} |
428 | 253 | } |
429 | |
|
430 | |
@Override |
431 | |
public SearchCriteriaTypeInfo getSearchCriteriaType( |
432 | |
String searchCriteriaTypeKey) throws DoesNotExistException, |
433 | |
InvalidParameterException, MissingParameterException, |
434 | |
OperationFailedException { |
435 | |
|
436 | 0 | return searchManager.getSearchCriteriaType(searchCriteriaTypeKey); |
437 | |
} |
438 | |
|
439 | |
@Override |
440 | |
public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes() |
441 | |
throws OperationFailedException { |
442 | 0 | return searchManager.getSearchCriteriaTypes(); |
443 | |
} |
444 | |
|
445 | |
@Override |
446 | |
public SearchResultTypeInfo getSearchResultType(String searchResultTypeKey) |
447 | |
throws DoesNotExistException, InvalidParameterException, |
448 | |
MissingParameterException, OperationFailedException { |
449 | 0 | checkForMissingParameter(searchResultTypeKey, "searchResultTypeKey"); |
450 | 0 | return searchManager.getSearchResultType(searchResultTypeKey); |
451 | |
} |
452 | |
|
453 | |
@Override |
454 | |
public List<SearchResultTypeInfo> getSearchResultTypes() |
455 | |
throws OperationFailedException { |
456 | 0 | return searchManager.getSearchResultTypes(); |
457 | |
} |
458 | |
|
459 | |
@Override |
460 | |
public SearchTypeInfo getSearchType(String searchTypeKey) |
461 | |
throws DoesNotExistException, InvalidParameterException, |
462 | |
MissingParameterException, OperationFailedException { |
463 | 0 | checkForMissingParameter(searchTypeKey, "searchTypeKey"); |
464 | 0 | return searchManager.getSearchType(searchTypeKey); |
465 | |
} |
466 | |
|
467 | |
@Override |
468 | |
public List<SearchTypeInfo> getSearchTypes() |
469 | |
throws OperationFailedException { |
470 | 0 | return searchManager.getSearchTypes(); |
471 | |
} |
472 | |
|
473 | |
@Override |
474 | |
public List<SearchTypeInfo> getSearchTypesByCriteria( |
475 | |
String searchCriteriaTypeKey) throws DoesNotExistException, |
476 | |
InvalidParameterException, MissingParameterException, |
477 | |
OperationFailedException { |
478 | 0 | checkForMissingParameter(searchCriteriaTypeKey, "searchCriteriaTypeKey"); |
479 | 0 | return searchManager.getSearchTypesByCriteria(searchCriteriaTypeKey); |
480 | |
} |
481 | |
|
482 | |
@Override |
483 | |
public List<SearchTypeInfo> getSearchTypesByResult( |
484 | |
String searchResultTypeKey) throws DoesNotExistException, |
485 | |
InvalidParameterException, MissingParameterException, |
486 | |
OperationFailedException { |
487 | 0 | checkForMissingParameter(searchResultTypeKey, "searchResultTypeKey"); |
488 | 0 | return searchManager.getSearchTypesByResult(searchResultTypeKey); |
489 | |
} |
490 | |
|
491 | |
public SearchManager getSearchManager() { |
492 | 0 | return searchManager; |
493 | |
} |
494 | |
|
495 | |
public void setSearchManager(SearchManager searchManager) { |
496 | 3 | this.searchManager = searchManager; |
497 | 3 | } |
498 | |
|
499 | |
@Override |
500 | |
public SearchResult search(SearchRequest searchRequest) throws MissingParameterException { |
501 | 0 | checkForMissingParameter(searchRequest, "searchRequest"); |
502 | 0 | return searchManager.search(searchRequest, lrcDao); |
503 | |
} |
504 | |
|
505 | |
@Override |
506 | |
public ObjectStructureDefinition getObjectStructure(String objectTypeKey) { |
507 | 8 | return dictionaryServiceDelegate.getObjectStructure(objectTypeKey); |
508 | |
} |
509 | |
@Override |
510 | |
public List<String> getObjectTypes() { |
511 | 0 | return dictionaryServiceDelegate.getObjectTypes(); |
512 | |
} |
513 | |
|
514 | |
|
515 | |
|
516 | |
|
517 | |
public ValidatorFactory getValidatorFactory() { |
518 | 0 | return validatorFactory; |
519 | |
} |
520 | |
|
521 | |
|
522 | |
|
523 | |
|
524 | |
public void setValidatorFactory(ValidatorFactory validatorFactory) { |
525 | 3 | this.validatorFactory = validatorFactory; |
526 | 3 | } |
527 | |
|
528 | |
public DictionaryService getDictionaryServiceDelegate() { |
529 | 0 | return dictionaryServiceDelegate; |
530 | |
} |
531 | |
|
532 | |
public void setDictionaryServiceDelegate(DictionaryService dictionaryServiceDelegate) { |
533 | 3 | this.dictionaryServiceDelegate = dictionaryServiceDelegate; |
534 | 3 | } |
535 | |
} |