View Javadoc

1   /**
2    * Copyright 2004-2013 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.student.contract.model.test.source;
17  
18  
19  public class DtoConstants {
20   
21      public final static String STATE_DRAFT = "Draft"; 
22      public final static String STATE_SUBMITTED = "Submitted";
23      public final static String STATE_WITHDRAWN = "Withdrawn";
24      public final static String STATE_APPROVED = "Approved";
25      public final static String STATE_NOT_APPROVED = "Not Approved";
26      public final static String STATE_ACTIVE = "Active";
27      public final static String STATE_INACTIVE = "Inactive";
28      public final static String STATE_SUPERSEDED  = "Superseded";
29      public final static String STATE_SUSPENDED  = "Suspended";
30      public final static String STATE_RETIRED = "Retired";
31  
32  	
33  	public static final String DTO_STATE = "DtoState";
34  	public static final String DTO_NEXT_STATE = "DtoNextState"; 
35  
36  	//FIXME: Need to split out proposal states (ie. workflow states) versus dto states
37  	public enum DtoState {
38  		DRAFT, SUBMITTED, APPROVED, ACTIVE, INACTIVE, RETIRED, SUPERSEDED, SAVED, ENROUTE;
39  
40  		public boolean equalsString(String state){
41  			if (state != null){
42  				return this.toString().equals(state.toUpperCase());
43  			}
44  			
45  			return false;
46  		}
47  		
48  		/**
49  	     * This is used to determine the next state.
50  	     * 
51  	     * TODO: Ideally this method should not be hardcoded here.  Also determining next state may
52  	     * be a more complicated and not just be a simple sequence.
53  	     * 
54  	     * @param state
55  	     * @return the next state
56  	     */
57  		public static DtoState getNextState(String state){
58  			// Element States
59  			if (DRAFT.equalsString(state)) {
60  	            return SUBMITTED;
61  	        } else if (SUBMITTED.equalsString(state)) {
62  	            return APPROVED;
63  	        } else if (APPROVED.equalsString(state)) {
64  	        	return ACTIVE;
65  	        } else if (ACTIVE.equalsString(state)) {
66  	        	return INACTIVE;
67  	        } else if (INACTIVE.equalsString(state)) {
68  	        	return RETIRED;
69  	        
70  	        // Proposal States
71  	        } else if (SAVED.equalsString(state)) {
72  	        	return ENROUTE;
73  	        } else if (ENROUTE.equalsString(state)) {
74  	        	return APPROVED;
75  	        }
76  					
77  			
78  			return null;
79  		}
80  		
81  		public static String getNextStateAsString(String state){
82  			DtoState dtoState = getNextState(state);
83  			if (dtoState == null){
84  				return null;
85  			} else {
86  				return dtoState.toString();
87  			}
88  		}
89  	}
90  }