Clover Coverage Report - KS LUM 1.2-M2-SNAPSHOT (Aggregated)
Coverage timestamp: Fri Apr 22 2011 05:19:13 EST
../../../../../../../img/srcFileCovDistChart5.png 48% of files have more coverage
89   535   53   1.89
8   354   0.6   47
47     1.13  
1    
 
  LrcServiceImpl       Line # 64 89 0% 53 77 46.5% 0.4652778
 
  (29)
 
1    /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10    * software distributed under the License is distributed on an "AS IS"
11    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12    * or implied. See the License for the specific language governing
13    * permissions and limitations under the License.
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    * @author lindholm
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    public class LrcServiceImpl implements LrcService {
65    private LrcDao lrcDao;
66    private SearchManager searchManager;
67    private DictionaryService dictionaryServiceDelegate;
68    private ValidatorFactory validatorFactory;
69   
70   
71    /* (non-Javadoc)
72    * @see org.kuali.student.lum.lrc.service.LrcService#compareGrades(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
73    */
 
74  0 toggle @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    /* (non-Javadoc)
83    * @see org.kuali.student.lum.lrc.service.LrcService#createResultComponent(java.lang.String, org.kuali.student.lum.lrc.dto.ResultComponentInfo)
84    */
 
85  7 toggle @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    // Validate Result component
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    /* (non-Javadoc)
112    * @see org.kuali.student.lum.lrc.service.LrcService#deleteResultComponent(java.lang.String)
113    */
 
114  3 toggle @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    /* (non-Javadoc)
127    * @see org.kuali.student.lum.lrc.service.LrcService#getCredential(java.lang.String)
128    */
 
129  0 toggle @Override
130    public CredentialInfo getCredential(String credentialKey)
131    throws DoesNotExistException, InvalidParameterException,
132    MissingParameterException, OperationFailedException {
133  0 throw new UnsupportedOperationException();
134    }
135   
136    /* (non-Javadoc)
137    * @see org.kuali.student.lum.lrc.service.LrcService#getCredentialKeysByCredentialType(java.lang.String)
138    */
 
139  0 toggle @Override
140    public List<String> getCredentialKeysByCredentialType(
141    String credentialTypeKey) throws DoesNotExistException,
142    InvalidParameterException, MissingParameterException,
143    OperationFailedException {
144  0 throw new UnsupportedOperationException();
145    }
146   
147    /* (non-Javadoc)
148    * @see org.kuali.student.lum.lrc.service.LrcService#getCredentialType(java.lang.String)
149    */
 
150  0 toggle @Override
151    public CredentialTypeInfo getCredentialType(String credentialTypeKey)
152    throws DoesNotExistException, InvalidParameterException,
153    MissingParameterException, OperationFailedException {
154  0 throw new UnsupportedOperationException();
155    }
156   
157    /* (non-Javadoc)
158    * @see org.kuali.student.lum.lrc.service.LrcService#getCredentialTypes()
159    */
 
160  0 toggle @Override
161    public List<CredentialTypeInfo> getCredentialTypes()
162    throws OperationFailedException {
163  0 throw new UnsupportedOperationException();
164    }
165   
166    /* (non-Javadoc)
167    * @see org.kuali.student.lum.lrc.service.LrcService#getCredentialsByKeyList(java.util.List)
168    */
 
169  0 toggle @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    /* (non-Javadoc)
178    * @see org.kuali.student.lum.lrc.service.LrcService#getCredit(java.lang.String)
179    */
 
180  0 toggle @Override
181    public CreditInfo getCredit(String creditKey) throws DoesNotExistException,
182    InvalidParameterException, MissingParameterException,
183    OperationFailedException {
184  0 throw new UnsupportedOperationException();
185    }
186   
187    /* (non-Javadoc)
188    * @see org.kuali.student.lum.lrc.service.LrcService#getCreditKeysByCreditType(java.lang.String)
189    */
 
190  0 toggle @Override
191    public List<String> getCreditKeysByCreditType(String creditTypeKey)
192    throws DoesNotExistException, InvalidParameterException,
193    MissingParameterException, OperationFailedException {
194  0 throw new UnsupportedOperationException();
195    }
196   
197    /* (non-Javadoc)
198    * @see org.kuali.student.lum.lrc.service.LrcService#getCreditType(java.lang.String)
199    */
 
200  0 toggle @Override
201    public CreditTypeInfo getCreditType(String creditTypeKey)
202    throws DoesNotExistException, InvalidParameterException,
203    MissingParameterException, OperationFailedException {
204  0 throw new UnsupportedOperationException();
205    }
206   
207    /* (non-Javadoc)
208    * @see org.kuali.student.lum.lrc.service.LrcService#getCreditTypes()
209    */
 
210  0 toggle @Override
211    public List<CreditTypeInfo> getCreditTypes()
212    throws OperationFailedException {
213  0 throw new UnsupportedOperationException();
214    }
215   
216    /* (non-Javadoc)
217    * @see org.kuali.student.lum.lrc.service.LrcService#getCreditsByKeyList(java.util.List)
218    */
 
219  0 toggle @Override
220    public List<CreditInfo> getCreditsByKeyList(List<String> creditKeyList)
221    throws DoesNotExistException, InvalidParameterException,
222    MissingParameterException, OperationFailedException {
223  0 throw new UnsupportedOperationException();
224    }
225   
226    /* (non-Javadoc)
227    * @see org.kuali.student.lum.lrc.service.LrcService#getGrade(java.lang.String)
228    */
 
229  0 toggle @Override
230    public GradeInfo getGrade(String gradeKey) throws DoesNotExistException,
231    InvalidParameterException, MissingParameterException,
232    OperationFailedException {
233  0 throw new UnsupportedOperationException();
234    }
235   
236    /* (non-Javadoc)
237    * @see org.kuali.student.lum.lrc.service.LrcService#getGradeKeysByGradeType(java.lang.String)
238    */
 
239  0 toggle @Override
240    public List<String> getGradeKeysByGradeType(String gradeTypeKey)
241    throws DoesNotExistException, InvalidParameterException,
242    MissingParameterException, OperationFailedException {
243  0 throw new UnsupportedOperationException();
244    }
245   
246    /* (non-Javadoc)
247    * @see org.kuali.student.lum.lrc.service.LrcService#getGradeType(java.lang.String)
248    */
 
249  0 toggle @Override
250    public GradeTypeInfo getGradeType(String gradeTypeKey)
251    throws DoesNotExistException, InvalidParameterException,
252    MissingParameterException, OperationFailedException {
253  0 throw new UnsupportedOperationException();
254    }
255   
256    /* (non-Javadoc)
257    * @see org.kuali.student.lum.lrc.service.LrcService#getGradeTypes()
258    */
 
259  0 toggle @Override
260    public List<GradeTypeInfo> getGradeTypes() throws OperationFailedException {
261  0 throw new UnsupportedOperationException();
262    }
263   
264    /* (non-Javadoc)
265    * @see org.kuali.student.lum.lrc.service.LrcService#getGradesByKeyList(java.util.List)
266    */
 
267  0 toggle @Override
268    public List<GradeInfo> getGradesByKeyList(List<String> gradeKeyList)
269    throws DoesNotExistException, InvalidParameterException,
270    MissingParameterException, OperationFailedException {
271  0 throw new UnsupportedOperationException();
272    }
273    /* (non-Javadoc)
274    * @see org.kuali.student.lum.lrc.service.LrcService#getGradesByScale(java.lang.String)
275    */
 
276  0 toggle @Override
277    public List<GradeInfo> getGradesByScale(String scale)
278    throws DoesNotExistException, InvalidParameterException,
279    MissingParameterException, OperationFailedException {
280  0 throw new UnsupportedOperationException();
281    }
282   
283    /* (non-Javadoc)
284    * @see org.kuali.student.lum.lrc.service.LrcService#getResultComponent(java.lang.String)
285    */
 
286  106 toggle @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    /* (non-Javadoc)
297    * @see org.kuali.student.lum.lrc.service.LrcService#getResultComponentIdsByResult(java.lang.String, java.lang.String)
298    */
 
299  5 toggle @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    /* (non-Javadoc)
311    * @see org.kuali.student.lum.lrc.service.LrcService#getResultComponentIdsByResultComponentType(java.lang.String)
312    */
 
313  120 toggle @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    /* (non-Javadoc)
324    * @see org.kuali.student.lum.lrc.service.LrcService#getResultComponentType(java.lang.String)
325    */
 
326  2 toggle @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    /* (non-Javadoc)
337    * @see org.kuali.student.lum.lrc.service.LrcService#getResultComponentTypes()
338    */
 
339  10 toggle @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    /* (non-Javadoc)
347    * @see org.kuali.student.lum.lrc.service.LrcService#getScale(java.lang.String)
348    */
 
349  0 toggle @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    /* (non-Javadoc)
359    * @see org.kuali.student.lum.lrc.service.LrcService#translateGrade(java.lang.String, java.lang.String, java.lang.String)
360    */
 
361  0 toggle @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    /* (non-Javadoc)
369    * @see org.kuali.student.lum.lrc.service.LrcService#updateResultComponent(java.lang.String, org.kuali.student.lum.lrc.dto.ResultComponentInfo)
370    */
 
371  5 toggle @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    // Validate Result component
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    * @return the lrcDao
404    */
 
405  0 toggle public LrcDao getLrcDao() {
406  0 return lrcDao;
407    }
408   
409    /**
410    * @param lrcDao the lrcDao to set
411    */
 
412  5 toggle public void setLrcDao(LrcDao lrcDao) {
413  5 this.lrcDao = lrcDao;
414    }
415   
416    /**
417    * Check for missing parameter and throw localized exception if missing
418    *
419    * @param param
420    * @param parameter name
421    * @throws MissingParameterException
422    */
 
423  262 toggle 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    }
429   
 
430  0 toggle @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  0 toggle @Override
440    public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes()
441    throws OperationFailedException {
442  0 return searchManager.getSearchCriteriaTypes();
443    }
444   
 
445  0 toggle @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  0 toggle @Override
454    public List<SearchResultTypeInfo> getSearchResultTypes()
455    throws OperationFailedException {
456  0 return searchManager.getSearchResultTypes();
457    }
458   
 
459  0 toggle @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  0 toggle @Override
468    public List<SearchTypeInfo> getSearchTypes()
469    throws OperationFailedException {
470  0 return searchManager.getSearchTypes();
471    }
472   
 
473  0 toggle @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  0 toggle @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  0 toggle public SearchManager getSearchManager() {
492  0 return searchManager;
493    }
494   
 
495  4 toggle public void setSearchManager(SearchManager searchManager) {
496  4 this.searchManager = searchManager;
497    }
498   
 
499  0 toggle @Override
500    public SearchResult search(SearchRequest searchRequest) throws MissingParameterException {
501  0 checkForMissingParameter(searchRequest, "searchRequest");
502  0 return searchManager.search(searchRequest, lrcDao);
503    }
504   
 
505  8 toggle @Override
506    public ObjectStructureDefinition getObjectStructure(String objectTypeKey) {
507  8 return dictionaryServiceDelegate.getObjectStructure(objectTypeKey);
508    }
 
509  0 toggle @Override
510    public List<String> getObjectTypes() {
511  0 return dictionaryServiceDelegate.getObjectTypes();
512    }
513   
514    /**
515    * @return the validatorFactory
516    */
 
517  0 toggle public ValidatorFactory getValidatorFactory() {
518  0 return validatorFactory;
519    }
520   
521    /**
522    * @param validatorFactory the validatorFactory to set
523    */
 
524  3 toggle public void setValidatorFactory(ValidatorFactory validatorFactory) {
525  3 this.validatorFactory = validatorFactory;
526    }
527   
 
528  0 toggle public DictionaryService getDictionaryServiceDelegate() {
529  0 return dictionaryServiceDelegate;
530    }
531   
 
532  3 toggle public void setDictionaryServiceDelegate(DictionaryService dictionaryServiceDelegate) {
533  3 this.dictionaryServiceDelegate = dictionaryServiceDelegate;
534    }
535    }