1 /** 2 * Copyright 2005-2016 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 /** 47 * Validate the view against the specific validationState instead of the default (current state). If 48 * forcedValidationState 49 * is null, validates against the current state if state validation is setup. 50 * 51 * @param model the model which contains the values to validated 52 * @param forcedValidationState the state being validated against 53 * @return that contains any errors/messages if any,, messages will have already 54 * been added to the MessageMap 55 */ 56 public DictionaryValidationResult validateView(ViewModel model, String forcedValidationState); 57 58 /** 59 * Validate the view against the next state based on the order of the states in the views StateMapping. This 60 * will validate against current state + 1. If there is no next state, this will validate against the current 61 * state. 62 * 63 * @param model the model which contains the values to validated 64 * @return that contains any errors/messages if any,, messages will have already 65 * been added to the MessageMap 66 */ 67 public DictionaryValidationResult validateViewAgainstNextState(ViewModel model); 68 69 /** 70 * Simulate view validation - this will run all validations against all states from the current state to 71 * the last state in the list of states in the view's stateMapping. Validation errors received for the current 72 * state will be added as errors to the MessageMap. Validation errors for future states will be warnings. 73 * 74 * @param model the model which contains the values to validated 75 */ 76 public void validateViewSimulation(ViewModel model); 77 78 /** 79 * Simulate view validation - this will run all validations against all states from the current state to 80 * the untilState specified in the list of states in the view's stateMapping. Validation errors received for the 81 * current state will be added as errors to the MessageMap. Validation errors for future states will be warnings. 82 * 83 * @param model the model which contains the values to validated 84 * @param untilState state to perform simulation to, if not set performs simulation up to the last state 85 */ 86 public void validateViewSimulation(ViewModel model, String untilState); 87 88 }