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