View Javadoc

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.r2.common.datadictionary;
17  
18  import java.util.List;
19  import org.kuali.rice.krad.service.DictionaryValidationService;
20  import org.kuali.rice.krad.datadictionary.validation.result.DictionaryValidationResult;
21  import org.kuali.student.r2.common.datadictionary.DataDictionaryValidator.ValidationType;
22  import org.kuali.student.r2.common.dto.ContextInfo;
23  import org.kuali.student.r2.common.dto.ValidationResultInfo;
24  import org.kuali.student.r2.common.exceptions.InvalidParameterException;
25  import org.kuali.student.r2.common.exceptions.MissingParameterException;
26  import org.kuali.student.r2.common.exceptions.OperationFailedException;
27  import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
28  
29  
30  /**
31   * This is an adapter that calls rice to do the valication
32   *
33   * TODO: figure why this does not validate anything
34   *
35   * @author nwright
36   */
37  public class RiceDataDictionaryValidatorImplDoesNotWorkButShould implements DataDictionaryValidator {
38  
39      private DictionaryValidationService riceService;
40  
41      public RiceDataDictionaryValidatorImplDoesNotWorkButShould() {
42      }
43  
44  
45      public RiceDataDictionaryValidatorImplDoesNotWorkButShould(DictionaryValidationService riceService) {
46          this.riceService = riceService;
47      }
48  
49      public DictionaryValidationService getRiceService() {
50          return riceService;
51      }
52  
53      public void setRiceService(DictionaryValidationService riceService) {
54          this.riceService = riceService;
55      }
56  
57      @Override
58      public List<ValidationResultInfo> validate(ValidationType validationType, Object info, ContextInfo context)
59              throws OperationFailedException, MissingParameterException, InvalidParameterException, PermissionDeniedException {
60         boolean doOptionalProcessing = true;
61  //       @param doOptionalProcessing true if the validation should do optional validation
62  //       (e.g. to check if empty values are required or not), false otherwise
63         if (validationType.equals(DataDictionaryValidator.ValidationType.SKIP_REQUREDNESS_VALIDATIONS)) {
64             doOptionalProcessing = false;
65         }
66          DictionaryValidationResult dvr = riceService.validate(info);
67          Rice2ValidationResultConverter converter = new Rice2ValidationResultConverter ();
68          List<ValidationResultInfo> vrs = converter.convert(dvr);
69          return vrs;
70      }
71  }