001    package org.kuali.student.common.dto;
002    
003    public class DtoConstants {
004     
005        public final static String STATE_DRAFT = "Draft"; 
006        public final static String STATE_SUBMITTED = "Submitted";
007        public final static String STATE_WITHDRAWN = "Withdrawn";
008        public final static String STATE_APPROVED = "Approved";
009        public final static String STATE_NOT_APPROVED = "Not Approved";
010        public final static String STATE_ACTIVE = "Active";
011        public final static String STATE_INACTIVE = "Inactive";
012        public final static String STATE_SUPERSEDED  = "Superseded";
013        public final static String STATE_SUSPENDED  = "Suspended";
014        public final static String STATE_RETIRED = "Retired";
015    
016            
017            public static final String DTO_STATE = "DtoState";
018            public static final String DTO_NEXT_STATE = "DtoNextState"; 
019    
020            //FIXME: Need to split out proposal states (ie. workflow states) versus dto states
021            public enum DtoState {
022                    DRAFT, SUBMITTED, APPROVED, ACTIVE, INACTIVE, RETIRED, SUPERSEDED, SAVED, ENROUTE;
023    
024                    public boolean equalsString(String state){
025                            if (state != null){
026                                    return this.toString().equals(state.toUpperCase());
027                            }
028                            
029                            return false;
030                    }
031                    
032                    /**
033                 * This is used to determine the next state.
034                 * 
035                 * TODO: Ideally this method should not be hardcoded here.  Also determining next state may
036                 * be a more complicated and not just be a simple sequence.
037                 * 
038                 * @param state
039                 * @return the next state
040                 */
041                    public static DtoState getNextState(String state){
042                            // Element States
043                            if (DRAFT.equalsString(state)) {
044                        return SUBMITTED;
045                    } else if (SUBMITTED.equalsString(state)) {
046                        return APPROVED;
047                    } else if (APPROVED.equalsString(state)) {
048                            return ACTIVE;
049                    } else if (ACTIVE.equalsString(state)) {
050                            return INACTIVE;
051                    } else if (INACTIVE.equalsString(state)) {
052                            return RETIRED;
053                    
054                    // Proposal States
055                    } else if (SAVED.equalsString(state)) {
056                            return ENROUTE;
057                    } else if (ENROUTE.equalsString(state)) {
058                            return APPROVED;
059                    }
060                                            
061                            
062                            return null;
063                    }
064                    
065                    public static String getNextStateAsString(String state){
066                            DtoState dtoState = getNextState(state);
067                            if (dtoState == null){
068                                    return null;
069                            } else {
070                                    return dtoState.toString();
071                            }
072                    }
073            }
074    }