Coverage Report - org.kuali.student.common.dto.DtoConstants
 
Classes in this File Line Coverage Branch Coverage Complexity
DtoConstants
0%
0/2
N/A
6.333
DtoConstants$DtoState
0%
0/22
0%
0/16
6.333
 
 1  
 package org.kuali.student.common.dto;
 2  
 
 3  0
 public class DtoConstants {
 4  
  
 5  
     public final static String STATE_DRAFT = "Draft"; 
 6  
     public final static String STATE_SUBMITTED = "Submitted";
 7  
     public final static String STATE_WITHDRAWN = "Withdrawn";
 8  
     public final static String STATE_APPROVED = "Approved";
 9  
     public final static String STATE_NOT_APPROVED = "NotApproved";
 10  
     public final static String STATE_ACTIVE = "Active";
 11  
     public final static String STATE_SUPERSEDED  = "Superseded";
 12  
     public final static String STATE_SUSPENDED  = "Suspended";
 13  
     public final static String STATE_RETIRED = "Retired";
 14  
 
 15  
         
 16  
         public static final String DTO_STATE = "DtoState";
 17  
         public static final String DTO_NEXT_STATE = "DtoNextState";
 18  
         public static final String DTO_WORKFLOW_NODE = "DtoWorkflowNode";
 19  
 
 20  
         //FIXME: Need to split out proposal states (ie. workflow states) versus dto states
 21  0
         public enum DtoState {
 22  0
                 DRAFT, SUBMITTED, APPROVED, ACTIVE, SUSPENDED, RETIRED, SUPERSEDED, SAVED, ENROUTE;
 23  
 
 24  
                 public boolean equalsString(String state){
 25  0
                         if (state != null){
 26  0
                                 return this.toString().equals(state.toUpperCase());
 27  
                         }
 28  
                         
 29  0
                         return false;
 30  
                 }
 31  
                 
 32  
                 /**
 33  
              * This is used to determine the next state.
 34  
              * 
 35  
              * TODO: Ideally this method should not be hardcoded here.  Also determining next state may
 36  
              * be a more complicated and not just be a simple sequence.
 37  
              * 
 38  
              * @param state
 39  
              * @return the next state
 40  
              */
 41  
                 public static DtoState getNextState(String state){
 42  
                         // Element States
 43  0
                         if (DRAFT.equalsString(state)) {
 44  0
                     return ACTIVE;
 45  0
                 } else if (APPROVED.equalsString(state)) {
 46  0
                         return ACTIVE;
 47  0
                 } else if (ACTIVE.equalsString(state)) {
 48  0
                         return SUSPENDED;
 49  0
                 } else if (SUSPENDED.equalsString(state)) {
 50  0
                         return ACTIVE;
 51  
                 
 52  
                 // Proposal States
 53  0
                 } else if (SAVED.equalsString(state)) {
 54  0
                         return ENROUTE;
 55  0
                 } else if (ENROUTE.equalsString(state)) {
 56  0
                         return APPROVED;
 57  
                 }
 58  
                                         
 59  
                         
 60  0
                         return null;
 61  
                 }
 62  
                 
 63  
                 public static String getNextStateAsString(String state){
 64  0
                         DtoState dtoState = getNextState(state);
 65  0
                         if (dtoState == null){
 66  0
                                 return null;
 67  
                         } else {
 68  0
                                 return dtoState.toString();
 69  
                         }
 70  
                 }
 71  
         }
 72  
 }