View Javadoc

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