001 package org.kuali.student.r2.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 = "NotApproved"; 010 public final static String STATE_ACTIVE = "Active"; 011 public final static String STATE_SUPERSEDED = "Superseded"; 012 public final static String STATE_SUSPENDED = "Suspended"; 013 public final static String STATE_RETIRED = "Retired"; 014 015 016 017 public static final String DTO_STATE = "DtoState"; 018 public static final String DTO_NEXT_STATE = "DtoNextState"; 019 public static final String DTO_WORKFLOW_NODE = "DtoWorkflowNode"; 020 public static final String WORKFLOW_NODE_PRE_ROUTE = "PreRoute"; 021 022 //FIXME: Need to split out proposal states (ie. workflow states) versus dto states 023 public enum DtoState { 024 DRAFT, SUBMITTED, APPROVED, ACTIVE, SUSPENDED, RETIRED, SUPERSEDED, SAVED, ENROUTE; 025 026 public boolean equalsString(String state){ 027 if (state != null){ 028 return this.toString().equals(state.toUpperCase()); 029 } 030 031 return false; 032 } 033 034 /** 035 * This is used to determine the next state. 036 * 037 * TODO: Ideally this method should not be hardcoded here. Also determining next state may 038 * be a more complicated and not just be a simple sequence. 039 * 040 * @param state 041 * @return the next state 042 */ 043 public static DtoState getNextState(String state){ 044 // Element States 045 if (DRAFT.equalsString(state)) { 046 return ACTIVE; 047 } else if (APPROVED.equalsString(state)) { 048 return ACTIVE; 049 } else if (ACTIVE.equalsString(state)) { 050 return SUSPENDED; 051 } else if (SUSPENDED.equalsString(state)) { 052 return ACTIVE; 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 }