1 /** 2 * Copyright 2005-2014 The Kuali Foundation 3 * 4 * Licensed under the Educational Community License, Version 2.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/ecl2.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.rice.krad.service; 17 18 import org.kuali.rice.krad.datadictionary.validation.result.DictionaryValidationResult; 19 import org.kuali.rice.krad.uif.view.View; 20 import org.kuali.rice.krad.uif.view.ViewModel; 21 22 /** 23 * Validation service for KRAD views. The ViewValidationService uses the DictionaryValidationService to validate the 24 * fields of the View by using the constraints that were set at either the InputField or AttributeDefinition level for 25 * that field. If errors/warnings are found they are added to the messageMap and when the view is returned these 26 * messages are displayed. 27 * 28 * @author Kuali Rice Team (rice.collab@kuali.org) 29 */ 30 public interface ViewValidationService { 31 32 /** 33 * This is the main validation method that should be used when validating Views 34 * Validates the view based on the model passed in, this will correctly use previousView by default 35 * as it automatically contains the generated data the validation requires. Validates against the current state if 36 * state based validation 37 * is setup. 38 * 39 * @param model the model which contains the values (and View) to validated 40 * @return DictionaryValidationResult that contains any errors/messages if any, messages will have already 41 * been added to the MessageMap 42 */ 43 public DictionaryValidationResult validateView(ViewModel model); 44 45 /** 46 * Additional validation method when you want to explicitly define the View being validated. Note 47 * that the view must have the correct binding information on its InputFields already generated by 48 * its lifecycle for this method to be used correctly. Validates against the current state if state based 49 * validation 50 * is setup. 51 * 52 * @param view the View to be validated 53 * @param model the model which contains the values to validated 54 * @return DictionaryValidationResult that contains any errors/messages if any,, messages will have already 55 * been added to the MessageMap 56 */ 57 public DictionaryValidationResult validateView(View view, ViewModel model); 58 59 /** 60 * Validate the view against the specific validationState instead of the default (current state). If 61 * forcedValidationState 62 * is null, validates against the current state if state validation is setup. 63 * 64 * @param view the View to be validated 65 * @param model the model which contains the values to validated 66 * @param forcedValidationState the state being validated against 67 * @return that contains any errors/messages if any,, messages will have already 68 * been added to the MessageMap 69 */ 70 public DictionaryValidationResult validateView(View view, ViewModel model, String forcedValidationState); 71 72 /** 73 * Validate the view against the next state based on the order of the states in the views StateMapping. This 74 * will validate against current state + 1. If there is no next state, this will validate against the current 75 * state. 76 * 77 * @param view the View to be validated 78 * @param model the model which contains the values to validated 79 * @return that contains any errors/messages if any,, messages will have already 80 * been added to the MessageMap 81 */ 82 public DictionaryValidationResult validateViewAgainstNextState(View view, ViewModel model); 83 84 /** 85 * Simulate view validation - this will run all validations against all states from the current state to 86 * the last state in the list of states in the view's stateMapping. Validation errors received for the current 87 * state will be added as errors to the MessageMap. Validation errors for future states will be warnings. 88 * 89 * @param view the View to be validated 90 * @param model the model which contains the values to validated 91 */ 92 public void validateViewSimulation(View view, ViewModel model); 93 94 /** 95 * Simulate view validation - this will run all validations against all states from the current state to 96 * the untilState specified in the list of states in the view's stateMapping. Validation errors received for the 97 * current state will be added as errors to the MessageMap. Validation errors for future states will be warnings. 98 * 99 * @param view the View to be validated 100 * @param model the model which contains the values to validated 101 * @param untilState state to perform simulation to, if not set performs simulation up to the last state 102 */ 103 public void validateViewSimulation(View view, ViewModel model, String untilState); 104 105 }