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