View Javadoc
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.datadictionary.state;
17  
18  import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
19  
20  import java.util.List;
21  import java.util.Map;
22  
23  /**
24   * StateMapping defines the methods necessary to allow for state validation to apply to a state object
25   *
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   * @since 2.2
28   */
29  public interface StateMapping {
30  
31      /**
32       * Gets the currentState by looking at the statePropertyName on the stateObject passed in
33       *
34       * @param stateObject the object containing the state information
35       * @return the currentState of the object
36       */
37      public String getCurrentState(Object stateObject);
38  
39      /**
40       * Gets the nextState of the object passed in by looking at the statePropertyName and using the states list
41       * to determine the next state in order.  Returns the currentState if there is no next state.
42       *
43       * @param stateObject the object containing the state information
44       * @return the next state of the object, or current state if no next state exists
45       */
46      public String getNextState(Object stateObject);
47  
48      /**
49       * Returns the human readable message determined by the key set for the state passed in
50       * against the stateNameMessageKeyMap.  If the state cannot be found in the states list or the state passed in is
51       * blank, this method will return null.  If the key found does not match a message, this method will return the
52       * state
53       * passed in.
54       *
55       * @param state state to get the message for
56       * @return state message, or the state passed in (if a valid state in states). Otherwise, returns null.
57       */
58      public String getStateNameMessage(String state);
59  
60      /**
61       * Map used by getStateNameMessage to determine the key to use when retrieving the message for the state specified.
62       * The map should be defined as state:messageKeyForState.
63       *
64       * @return map of states and their messageKeys
65       */
66      public Map<String, String> getStateNameMessageKeyMap();
67  
68      /**
69       * Set the stateNameMessageKeyMap
70       *
71       * @param stateNameMessageKeyMap map of states and their messageKeys
72       */
73      public void setStateNameMessageKeyMap(Map<String, String> stateNameMessageKeyMap);
74  
75      /**
76       * The states of this stateMapping.  IMPORTANT: This must be ALL states for this mapping IN ORDER.
77       *
78       * @return list of states, in the order in which they are applied.  If states were never set, returns an empty
79       *         list.
80       */
81      public List<String> getStates();
82  
83      /**
84       * Set the states of this stateMapping, in order
85       *
86       * @param states list of states, in the order in which they are applied.
87       */
88      public void setStates(List<String> states);
89  
90      /**
91       * The property name/path to be used when trying to find state String information on the object.  This is used by
92       * getCurrentState(Object object)
93       * and getNextState(Object object);
94       *
95       * @return the property name/path representing where state information can be found on the object
96       */
97      public String getStatePropertyName();
98  
99      /**
100      * Set the property name/path
101      *
102      * @param name the property name/path that points to the string representation of the object's tate
103      */
104     public void setStatePropertyName(String name);
105 
106     /**
107      * This ONLY applies to client side validations as the controller has full control over what validations to apply
108      * on the server.  This setting determines for what states, if any, the client side validation needs to use for
109      * its validation instead of the default (by default if state validation is setup, the client side validation
110      * will use n+1 as its validation, ie whatever the NEXT state is).
111      *
112      * <p>The map must be defined as such: (state of the object, state to use for validation on the
113      * client when in that state).<br>
114      * Example:<br>
115      * key="INITIAL" value="SUBMIT"<br>
116      * key="SAVE" value="SUBMIT"<br>
117      * In this example, when the object is in the "INITIAL" or the "SAVE" states, validation on the client will
118      * be against the "SUBMIT" state</p>
119      *
120      * @return map representing the state of the object and state to use for validation on the
121      *         client when in that state
122      */
123     public Map<String, String> getCustomClientSideValidationStates();
124 
125     /**
126      * Set the custom client side validation behavior map.  This only applies for client-side validation.
127      *
128      * @param customClientSideValidationStates map representing the state of the object and state to use for validation
129      * on the
130      * client when in that state
131      */
132     public void setCustomClientSideValidationStates(Map<String, String> customClientSideValidationStates);
133 
134     /**
135      * Validates different requirements of component compiling a series of reports detailing information on errors
136      * found in the component.  Used by the RiceDictionaryValidator.
137      *
138      * @param tracer Record of component's location
139      */
140     public void completeValidation(ValidationTrace tracer);
141 
142 }