Coverage Report - org.kuali.rice.edl.impl.UserAction
 
Classes in this File Line Coverage Branch Coverage Complexity
UserAction
0%
0/47
0%
0/38
3.111
 
 1  
 /*
 2  
  * Copyright 2007-2008 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 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 implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.edl.impl;
 17  
 
 18  
 
 19  
 /**
 20  
  * Represents a User Action in eDoc Lite.  Also contains methods
 21  
  * for classifying the user action.
 22  
  * 
 23  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 24  
  */
 25  
 public class UserAction {
 26  
 
 27  
     public static final String ACTION_CREATE = "initiate";
 28  
     public static final String ACTION_LOAD = "load";
 29  
     public static final String ACTION_UNDEFINED = "undefined";
 30  
     public static final String ACTION_ROUTE = "route";
 31  
     public static final String ACTION_APPROVE = "approve";
 32  
     public static final String ACTION_DISAPPROVE = "disapprove";
 33  
     public static final String ACTION_CANCEL = "cancel";
 34  
     public static final String ACTION_BLANKETAPPROVE = "blanketApprove";
 35  
     public static final String ACTION_FYI = "fyi";
 36  
     public static final String ACTION_ACKNOWLEDGE = "acknowledge";
 37  
     public static final String ACTION_SAVE = "save";
 38  
     public static final String ACTION_COMPLETE = "complete";
 39  
     public static final String ACTION_DELETE = "delete";
 40  
     public static final String ACTION_RETURN_TO_PREVIOUS = "returnToPrevious";
 41  
     public static final String ACTION_REFRESH_FROM_LOOKUP = "refresh";
 42  
     
 43  
     public static final String ACTION_CREATE_LABEL = "initiate";
 44  
     public static final String ACTION_LOAD_LABEL = "load";
 45  
     public static final String ACTION_ROUTE_LABEL = "submit";
 46  
     public static final String ACTION_APPROVE_LABEL = "approve";
 47  
     public static final String ACTION_DISAPPROVE_LABEL = "disapprove";
 48  
     public static final String ACTION_CANCEL_LABEL = "cancel";
 49  
     public static final String ACTION_BLANKETAPPROVE_LABEL = "blanket approve";
 50  
     public static final String ACTION_FYI_LABEL = "fyi";
 51  
     public static final String ACTION_ACKNOWLEDGE_LABEL = "acknowledge";
 52  
     public static final String ACTION_SAVE_LABEL = "save";
 53  
     public static final String ACTION_COMPLETE_LABEL = "complete";
 54  
     public static final String ACTION_DELETE_LABEL = "delete";
 55  
     public static final String ACTION_RETURN_TO_PREVIOUS_LABEL = "return to previous";
 56  
     public static final String ACTION_REFRESH_FROM_LOOKUP_LABEL = ACTION_REFRESH_FROM_LOOKUP;
 57  
     
 58  0
     public static final String[] LOAD_ACTIONS = new String[] {
 59  
         ACTION_LOAD,
 60  
         ACTION_CREATE
 61  
     };
 62  
     
 63  0
     public static final String[] REPLACE_VERSION_ACTIONS = new String[] {
 64  
         ACTION_UNDEFINED
 65  
     };
 66  
     
 67  0
     public static final String[] VALIDATABLE_ACTIONS = new String[] {
 68  
         ACTION_SAVE,
 69  
         ACTION_ROUTE,
 70  
         ACTION_APPROVE,
 71  
         ACTION_ACKNOWLEDGE,
 72  
         ACTION_COMPLETE,
 73  
         ACTION_FYI,
 74  
         ACTION_DISAPPROVE,
 75  
         ACTION_RETURN_TO_PREVIOUS
 76  
     };
 77  
     
 78  0
     public static final String[] ANNOTATABLE_ACTIONS = new String[] {
 79  
             ACTION_APPROVE,
 80  
             ACTION_ACKNOWLEDGE,
 81  
             ACTION_COMPLETE,
 82  
             ACTION_FYI,
 83  
             ACTION_DISAPPROVE,
 84  
             ACTION_CANCEL,
 85  
             ACTION_RETURN_TO_PREVIOUS
 86  
     };
 87  
     
 88  0
     public static final String[] EDITABLE_ACTIONS = new String[] { 
 89  
         ACTION_CREATE,
 90  
         ACTION_ROUTE,
 91  
         ACTION_APPROVE,
 92  
         ACTION_DISAPPROVE,
 93  
         ACTION_COMPLETE
 94  
     };
 95  
     
 96  
     private String action;
 97  
     
 98  0
     public UserAction(String action) {
 99  0
                 if (action.equals(ACTION_CREATE_LABEL)) {
 100  0
                         this.action = ACTION_CREATE;
 101  0
                 } else if (action.equals(ACTION_LOAD_LABEL)) {
 102  0
                         this.action = ACTION_LOAD;
 103  0
                 } else if (action.equals(ACTION_ROUTE_LABEL)) {
 104  0
                         this.action = ACTION_ROUTE;
 105  0
                 } else if (action.equals(ACTION_APPROVE_LABEL)) {
 106  0
                         this.action = ACTION_APPROVE;
 107  0
                 } else if (action.equals(ACTION_DISAPPROVE_LABEL)) {
 108  0
                         this.action = ACTION_DISAPPROVE;
 109  0
                 } else if (action.equals(ACTION_CANCEL_LABEL)) {
 110  0
                         this.action = ACTION_CANCEL;
 111  0
                 } else if (action.equals(ACTION_BLANKETAPPROVE_LABEL)) {
 112  0
                         this.action = ACTION_BLANKETAPPROVE;
 113  0
                 } else if (action.equals(ACTION_FYI_LABEL)) {
 114  0
                         this.action = ACTION_FYI;
 115  0
                 } else if (action.equals(ACTION_ACKNOWLEDGE_LABEL)) {
 116  0
                         this.action = ACTION_ACKNOWLEDGE;
 117  0
                 } else if (action.equals(ACTION_SAVE_LABEL)) {
 118  0
                         this.action = ACTION_SAVE;
 119  0
                 } else if (action.equals(ACTION_COMPLETE_LABEL)) {
 120  0
                         this.action = ACTION_COMPLETE;
 121  0
                 } else if (action.equals(ACTION_DELETE_LABEL)) {
 122  0
                         this.action = ACTION_DELETE;
 123  0
                 } else if (action.equals(ACTION_RETURN_TO_PREVIOUS_LABEL)) {
 124  0
                         this.action = ACTION_RETURN_TO_PREVIOUS;
 125  0
                 } else if (action.equals(ACTION_REFRESH_FROM_LOOKUP_LABEL)) {
 126  0
                         this.action = ACTION_REFRESH_FROM_LOOKUP;
 127  
                 } else {
 128  0
                         this.action = action;
 129  
                 }
 130  0
         }
 131  
     
 132  
     public String getAction() {
 133  0
         return action;
 134  
     }
 135  
     
 136  
     public boolean isLoadAction() {
 137  0
         return containsAction(LOAD_ACTIONS, action);
 138  
     }
 139  
     
 140  
     public boolean isIncrementVersionAction() {
 141  0
         return !isLoadAction() && !isReplaceVersionAction() && !ACTION_REFRESH_FROM_LOOKUP.equals(action);
 142  
     }
 143  
     
 144  
     public boolean isReplaceVersionAction() {
 145  0
         return containsAction(REPLACE_VERSION_ACTIONS, action);
 146  
     }
 147  
 
 148  
     public boolean isValidatableAction() {
 149  0
         return containsAction(VALIDATABLE_ACTIONS, action);
 150  
     }
 151  
     
 152  
     public boolean isAnnotatableAction() {
 153  0
         return containsAction(ANNOTATABLE_ACTIONS, action);
 154  
     }
 155  
     
 156  
     public boolean isEditableAction() {
 157  0
         return containsAction(EDITABLE_ACTIONS, action);
 158  
     }
 159  
     
 160  
     private boolean containsAction(String[] actions, String action) {
 161  0
         for (int index = 0; index < actions.length; index++) {
 162  0
             if (actions[index].equals(action)) {
 163  0
                 return true;
 164  
             }
 165  
         }
 166  0
         return false;
 167  
     }
 168  
     
 169  
 }