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