Coverage Report - org.kuali.student.core.dto.DtoConstants
 
Classes in this File Line Coverage Branch Coverage Complexity
DtoConstants
0%
0/2
N/A
7
DtoConstants$DtoState
0%
0/24
0%
0/18
7
 
 1  
 package org.kuali.student.core.dto;
 2  
 
 3  0
 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  0
         public enum DtoState {
 10  0
                 DRAFT, SUBMITTED, APPROVED, ACTIVE, INACTIVE, RETIRED, SUPERSEDED, SAVED, ENROUTE;
 11  
 
 12  
                 public boolean equalsString(String state){
 13  0
                         if (state != null){
 14  0
                                 return this.toString().equals(state.toUpperCase());
 15  
                         }
 16  
                         
 17  0
                         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  0
                         if (DRAFT.equalsString(state)) {
 32  0
                     return SUBMITTED;
 33  0
                 } else if (SUBMITTED.equalsString(state)) {
 34  0
                     return APPROVED;
 35  0
                 } else if (APPROVED.equalsString(state)) {
 36  0
                         return ACTIVE;
 37  0
                 } else if (ACTIVE.equalsString(state)) {
 38  0
                         return INACTIVE;
 39  0
                 } else if (INACTIVE.equalsString(state)) {
 40  0
                         return RETIRED;
 41  
                 
 42  
                 // Proposal States
 43  0
                 } else if (SAVED.equalsString(state)) {
 44  0
                         return ENROUTE;
 45  0
                 } else if (ENROUTE.equalsString(state)) {
 46  0
                         return APPROVED;
 47  
                 }
 48  
                                         
 49  
                         
 50  0
                         return null;
 51  
                 }
 52  
                 
 53  
                 public static String getNextStateAsString(String state){
 54  0
                         DtoState dtoState = getNextState(state);
 55  0
                         if (dtoState == null){
 56  0
                                 return null;
 57  
                         } else {
 58  0
                                 return dtoState.toString();
 59  
                         }
 60  
                 }
 61  
         }
 62  
 }