001    /**
002     * Copyright 2005-2013 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.krad.service;
017    
018    import org.kuali.rice.krad.datadictionary.validation.result.DictionaryValidationResult;
019    import org.kuali.rice.krad.uif.view.View;
020    import org.kuali.rice.krad.uif.view.ViewModel;
021    
022    /**
023     * Validation service for KRAD views.  The ViewValidationService uses the DictionaryValidationService to validate the
024     * fields of the View by using the constraints that were set at either the InputField or AttributeDefinition level for
025     * that field.  If errors/warnings are found they are added to the messageMap and when the view is returned these
026     * messages are displayed.
027     *
028     * @author Kuali Rice Team (rice.collab@kuali.org)
029     */
030    public interface ViewValidationService {
031    
032        /**
033         * This is the main validation method that should be used when validating Views
034         * Validates the view based on the model passed in, this will correctly use previousView by default
035         * as it automatically contains the generated data the validation requires. Validates against the current state if
036         * state based validation
037         * is setup.
038         *
039         * @param model the model which contains the values (and View) to validated
040         * @return DictionaryValidationResult that contains any errors/messages if any, messages will have already
041         *         been added to the MessageMap
042         */
043        public DictionaryValidationResult validateView(ViewModel model);
044    
045        /**
046         * Additional validation method when you want to explicitly define the View being validated.  Note
047         * that the view must have the correct binding information on its InputFields already generated by
048         * its lifecycle for this method to be used correctly.  Validates against the current state if state based
049         * validation
050         * is setup.
051         *
052         * @param view the View to be validated
053         * @param model the model which contains the values to validated
054         * @return DictionaryValidationResult that contains any errors/messages if any,, messages will have already
055         *         been added to the MessageMap
056         */
057        public DictionaryValidationResult validateView(View view, ViewModel model);
058    
059        /**
060         * Validate the view against the specific validationState instead of the default (current state).  If
061         * forcedValidationState
062         * is null, validates against the current state if state validation is setup.
063         *
064         * @param view the View to be validated
065         * @param model the model which contains the values to validated
066         * @param forcedValidationState the state being validated against
067         * @return that contains any errors/messages if any,, messages will have already
068         *         been added to the MessageMap
069         */
070        public DictionaryValidationResult validateView(View view, ViewModel model, String forcedValidationState);
071    
072        /**
073         * Validate the view against the next state based on the order of the states in the views StateMapping.  This
074         * will validate against current state + 1.  If there is no next state, this will validate against the current
075         * state.
076         *
077         * @param view the View to be validated
078         * @param model the model which contains the values to validated
079         * @return that contains any errors/messages if any,, messages will have already
080         *         been added to the MessageMap
081         */
082        public DictionaryValidationResult validateViewAgainstNextState(View view, ViewModel model);
083    
084        /**
085         * Simulate view validation - this will run all validations against all states from the current state to
086         * the last state in the list of states in the view's stateMapping.  Validation errors received for the current
087         * state will be added as errors to the MessageMap. Validation errors for future states will be warnings.
088         *
089         * @param view the View to be validated
090         * @param model the model which contains the values to validated
091         */
092        public void validateViewSimulation(View view, ViewModel model);
093    
094        /**
095         * Simulate view validation - this will run all validations against all states from the current state to
096         * the untilState specified in the list of states in the view's stateMapping.  Validation errors received for the
097         * current state will be added as errors to the MessageMap. Validation errors for future states will be warnings.
098         *
099         * @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    }