View Javadoc

1   /**
2    * Copyright 2012 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.student.r2.core.constants;
17  
18  import org.kuali.student.r2.common.constants.CommonServiceConstants;
19  import org.kuali.student.r2.core.class1.state.dto.StateInfo;
20  import org.kuali.student.r2.core.class1.state.dto.LifecycleInfo;
21  
22  /**
23   * This class holds the constants used by the state service
24   *
25   * @version 2.0
26   * @author Sri komandur@uw.edu
27   */
28  public class StateServiceConstants {
29  
30      /**
31       * Reference Object URIs
32       */
33      public static final String SERVICE_NAME_LOCAL_PART = "StateService";
34      public static final String NAMESPACE = CommonServiceConstants.REF_OBJECT_URI_GLOBAL_PREFIX + "state";
35      public static final String REF_OBJECT_URI_STATE = NAMESPACE + "/" + StateInfo.class.getSimpleName();
36      public static final String REF_OBJECT_URI_LIFECYCLE = NAMESPACE + "/" + LifecycleInfo.class.getSimpleName();
37  
38      /**
39       * StateChange types
40       */
41      public static final String STATE_CHANGE_TYPE_KEY = "kuali.state.change.type";
42  
43      /**
44      * StateConstraint types
45      */
46      public static final String PRECONDITION_STATE_CONSTRAINT_TYPE_KEY = "kuali.state.constraint.type.precondition";
47      public static final String PROPAGATION_STATE_CONSTRAINT_TYPE_KEY = "kuali.state.constraint.type.propagation";
48  
49      /**
50       * StatePropagation types
51       */
52      public static final String STATE_PROPAGATION_TYPE_KEY = "kuali.state.propagation.type";
53  
54  
55  
56      /**
57       *  StateChange states
58       */
59      public static final String STATE_CHANGE_LIFECYCLE_KEY = "kuali.state.change.lifecycle";
60      public static final String STATE_CHANGE_STATE_ACTIVE_KEY = "kuali.state.change.state.active";
61  
62      public static final String[] STATE_CHANGE_LIFECYCLE_STATE_KEYS = {
63              STATE_CHANGE_STATE_ACTIVE_KEY
64      };
65  
66      public static boolean isValidStateChangeState(String possibleState) {
67          if (possibleState == null) {
68              return false;
69          }
70          for (String state: STATE_CHANGE_LIFECYCLE_STATE_KEYS) {
71              if (state.equals(possibleState)) {
72                  return true;
73              }
74          }
75          return false;
76      }
77  
78      /**
79       *  StateConstraint states
80       */
81      public static final String STATE_CONSTRAINT_LIFECYCLE_KEY = "kuali.state.constraint.lifecycle";
82      public static final String STATE_CONSTRAINT_STATE_ACTIVE_KEY = "kuali.state.constraint.state.active";
83  
84      public static final String[] STATE_CONSTRAINT_LIFECYCLE_STATE_KEYS = {
85              STATE_CONSTRAINT_STATE_ACTIVE_KEY
86      };
87  
88      public static boolean isValidStateConstraintState(String possibleState) {
89          if (possibleState == null) {
90              return false;
91          }
92          for (String state: STATE_CONSTRAINT_LIFECYCLE_STATE_KEYS) {
93              if (state.equals(possibleState)) {
94                  return true;
95              }
96          }
97          return false;
98      }
99  
100     /**
101      *  StatePropagation states
102      */
103     public static final String STATE_PROPAGATION_LIFECYCLE_KEY = "kuali.state.propagation.lifecycle";
104     public static final String STATE_PROPAGATION_STATE_ACTIVE_KEY = "kuali.state.propagation.state.active";
105 
106     public static final String[] STATE_PROPAGATION_LIFECYCLE_STATE_KEYS = {
107             STATE_PROPAGATION_STATE_ACTIVE_KEY
108     };
109 
110     public static boolean isValidStatePropagationState(String possibleState) {
111         if (possibleState == null) {
112             return false;
113         }
114         for (String state: STATE_PROPAGATION_LIFECYCLE_STATE_KEYS) {
115             if (state.equals(possibleState)) {
116                 return true;
117             }
118         }
119         return false;
120     }
121 }