View Javadoc

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