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