Coverage Report - org.kuali.student.r2.common.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  
 /*
 2  
  * Copyright 2010 The Kuali Foundation 
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the
 5  
  * "License"); you may not use this file except in compliance with the
 6  
  * License. You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.osedu.org/licenses/ECL-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 13  
  * implied. See the License for the specific language governing
 14  
  * permissions and limitations under the License.
 15  
  */
 16  
 
 17  
 package org.kuali.student.r2.common.dto;
 18  
 
 19  
 /**
 20  
  * These constants should be in the Constants files for their
 21  
  * respective services. This is used quite a bit in lum so left here
 22  
  * for compatibility.
 23  
  */
 24  
 
 25  
 @Deprecated
 26  0
 public class DtoConstants {
 27  
  
 28  
     public final static String STATE_DRAFT = "Draft"; 
 29  
     public final static String STATE_SUBMITTED = "Submitted";
 30  
     public final static String STATE_WITHDRAWN = "Withdrawn";
 31  
     public final static String STATE_APPROVED = "Approved";
 32  
     public final static String STATE_NOT_APPROVED = "Not Approved";
 33  
     public final static String STATE_ACTIVE = "Active";
 34  
     public final static String STATE_INACTIVE = "Inactive";
 35  
     public final static String STATE_SUPERSEDED  = "Superseded";
 36  
     public final static String STATE_SUSPENDED  = "Suspended";
 37  
     public final static String STATE_RETIRED = "Retired";
 38  
 
 39  
         
 40  
     public static final String DTO_STATE = "DtoState";
 41  
     public static final String DTO_NEXT_STATE = "DtoNextState"; 
 42  
     
 43  
     //FIXME: Need to split out proposal states (ie. workflow states) versus dto states
 44  0
     public enum DtoState {
 45  0
         DRAFT, SUBMITTED, APPROVED, ACTIVE, INACTIVE, RETIRED, SUPERSEDED, SAVED, ENROUTE;
 46  
         
 47  
         public boolean equalsString(String state) {
 48  0
             if (state != null) {
 49  0
                 return this.toString().equals(state.toUpperCase());
 50  
             }
 51  
             
 52  0
             return false;
 53  
         }
 54  
         
 55  
         /**
 56  
          * This is used to determine the next state.
 57  
          * 
 58  
          * TODO: Ideally this method should not be hardcoded here.
 59  
          * Also determining next state may be a more complicated and
 60  
          * not just be a simple sequence.
 61  
          * 
 62  
          * @param state
 63  
          * @return the next state
 64  
          */
 65  
         public static DtoState getNextState(String state) {
 66  
             // Element States
 67  0
             if (DRAFT.equalsString(state)) {
 68  0
                 return SUBMITTED;
 69  0
             } else if (SUBMITTED.equalsString(state)) {
 70  0
                 return APPROVED;
 71  0
             } else if (APPROVED.equalsString(state)) {
 72  0
                 return ACTIVE;
 73  0
             } else if (ACTIVE.equalsString(state)) {
 74  0
                 return INACTIVE;
 75  0
             } else if (INACTIVE.equalsString(state)) {
 76  0
                 return RETIRED;
 77  
                 
 78  
                 // Proposal States
 79  0
             } else if (SAVED.equalsString(state)) {
 80  0
                 return ENROUTE;
 81  0
             } else if (ENROUTE.equalsString(state)) {
 82  0
                 return APPROVED;
 83  
             }
 84  
                     
 85  0
             return null;
 86  
         }
 87  
         
 88  
         public static String getNextStateAsString(String state) {
 89  0
             DtoState dtoState = getNextState(state);
 90  0
             if (dtoState == null) {
 91  0
                 return null;
 92  
             } else {
 93  0
                 return dtoState.toString();
 94  
             }
 95  
         }
 96  
     }
 97  
 }