Clover Coverage Report - KS Services 0.0.1-SNAPSHOT (Aggregated)
Coverage timestamp: Mon May 23 2011 04:06:57 EDT
../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
16   92   8   2.67
4   51   0.5   6
6     1.33  
1    
 
  RiceDataDictionaryValidatorImpl       Line # 43 16 0% 8 26 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 1.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl1.php
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
15    */
16    package org.kuali.student.datadictionary;
17   
18    import java.util.List;
19    import org.kuali.rice.kns.datadictionary.DataObjectEntry;
20    import org.kuali.rice.kns.datadictionary.validation.result.DictionaryValidationResult;
21    import org.kuali.rice.kns.service.DictionaryValidationService;
22    import org.kuali.student.common.dto.ContextInfo;
23    import org.kuali.student.common.dto.ValidationResultInfo;
24    import org.kuali.student.common.exceptions.InvalidParameterException;
25    import org.kuali.student.common.exceptions.MissingParameterException;
26    import org.kuali.student.common.exceptions.OperationFailedException;
27    import org.kuali.student.common.exceptions.PermissionDeniedException;
28   
29    /**
30    * This is an implementation that gets the dictionary directly using KS methods but then calls
31    * the rice validation method that takes in the dictionary entry to be used.
32    *
33    * *** THIS IS THE ONLY WAY I COULD GET THE INTEGRATION TO WORK ***
34    *
35    * I could not figure out how to get the validation to work by simply calling
36    * the validate(info, doOptionalProcessing) method so instead I had to read the dictionary
37    * myself and pass the dictionary in on the call using the
38    * validate(info,entryName, dictEntry, doOptionalProcessing) method instead
39    *
40    *
41    * @author nwright
42    */
 
43    public class RiceDataDictionaryValidatorImpl implements DataDictionaryValidatorInfc {
44   
45    private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(RiceDataDictionaryValidatorImpl.class);
46    private RiceDataDictionaryServiceInfc riceDataDictionaryService;
47    private DictionaryValidationService riceDictionaryValidationService;
48   
 
49  0 toggle public RiceDataDictionaryValidatorImpl() {
50    }
51   
 
52  0 toggle public RiceDataDictionaryServiceInfc getRiceDataDictionaryService() {
53  0 return riceDataDictionaryService;
54    }
55   
 
56  0 toggle public void setRiceDataDictionaryService(RiceDataDictionaryServiceInfc riceDataDictionaryService) {
57  0 this.riceDataDictionaryService = riceDataDictionaryService;
58    }
59   
 
60  0 toggle public DictionaryValidationService getRiceDictionaryValidationService() {
61  0 return riceDictionaryValidationService;
62    }
63   
 
64  0 toggle public void setRiceDictionaryValidationService(DictionaryValidationService riceDictionaryValidationService) {
65  0 this.riceDictionaryValidationService = riceDictionaryValidationService;
66    }
67   
68   
 
69  0 toggle @Override
70    public List<ValidationResultInfo> validate(ValidationType validationType, Object info, ContextInfo context)
71    throws OperationFailedException, MissingParameterException, InvalidParameterException, PermissionDeniedException {
72  0 boolean doOptionalProcessing = true;
73    // @param doOptionalProcessing true if the validation should do optional validation
74    // (e.g. to check if empty values are required or not), false otherwise
75  0 if (validationType.equals(DataDictionaryValidatorInfc.ValidationType.SKIP_REQUREDNESS_VALIDATIONS)) {
76  0 doOptionalProcessing = false;
77    }
78  0 String entryName = info.getClass().getName();
79  0 DataObjectEntry dictEntry;
80  0 dictEntry = this.riceDataDictionaryService.getDataObjectEntry(entryName);
81  0 if (dictEntry == null) {
82  0 throw new OperationFailedException("Dictionary entry for " + entryName + " does not exist");
83    }
84  0 DictionaryValidationResult dvr = this.riceDictionaryValidationService.validate(info,
85    entryName,
86    dictEntry,
87    doOptionalProcessing);
88  0 Rice2ValidationResultConverter converter = new Rice2ValidationResultConverter();
89  0 List<ValidationResultInfo> vrs = converter.convert(dvr);
90  0 return vrs;
91    }
92    }