001 /** 002 * Copyright 2005-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.edl.impl; 017 018 019 /** 020 * Represents a User Action in eDoc Lite. Also contains methods 021 * for classifying the user action. 022 * 023 * @author Kuali Rice Team (rice.collab@kuali.org) 024 */ 025 public class UserAction { 026 027 public static final String ACTION_CREATE = "initiate"; 028 public static final String ACTION_LOAD = "load"; 029 public static final String ACTION_UNDEFINED = "undefined"; 030 public static final String ACTION_ROUTE = "route"; 031 public static final String ACTION_APPROVE = "approve"; 032 public static final String ACTION_DISAPPROVE = "disapprove"; 033 public static final String ACTION_CANCEL = "cancel"; 034 public static final String ACTION_BLANKETAPPROVE = "blanketApprove"; 035 public static final String ACTION_FYI = "fyi"; 036 public static final String ACTION_ACKNOWLEDGE = "acknowledge"; 037 public static final String ACTION_SAVE = "save"; 038 public static final String ACTION_COMPLETE = "complete"; 039 public static final String ACTION_DELETE = "delete"; 040 public static final String ACTION_RETURN_TO_PREVIOUS = "returnToPrevious"; 041 public static final String ACTION_REFRESH_FROM_LOOKUP = "refresh"; 042 043 public static final String ACTION_CREATE_LABEL = "initiate"; 044 public static final String ACTION_LOAD_LABEL = "load"; 045 public static final String ACTION_ROUTE_LABEL = "submit"; 046 public static final String ACTION_APPROVE_LABEL = "approve"; 047 public static final String ACTION_DISAPPROVE_LABEL = "disapprove"; 048 public static final String ACTION_CANCEL_LABEL = "cancel"; 049 public static final String ACTION_BLANKETAPPROVE_LABEL = "blanket approve"; 050 public static final String ACTION_FYI_LABEL = "fyi"; 051 public static final String ACTION_ACKNOWLEDGE_LABEL = "acknowledge"; 052 public static final String ACTION_SAVE_LABEL = "save"; 053 public static final String ACTION_COMPLETE_LABEL = "complete"; 054 public static final String ACTION_DELETE_LABEL = "delete"; 055 public static final String ACTION_RETURN_TO_PREVIOUS_LABEL = "return to previous"; 056 public static final String ACTION_REFRESH_FROM_LOOKUP_LABEL = ACTION_REFRESH_FROM_LOOKUP; 057 058 public static final String[] LOAD_ACTIONS = new String[] { 059 ACTION_LOAD, 060 ACTION_CREATE 061 }; 062 063 public static final String[] REPLACE_VERSION_ACTIONS = new String[] { 064 ACTION_UNDEFINED 065 }; 066 067 public static final String[] VALIDATABLE_ACTIONS = new String[] { 068 ACTION_SAVE, 069 ACTION_ROUTE, 070 ACTION_APPROVE, 071 ACTION_ACKNOWLEDGE, 072 ACTION_COMPLETE, 073 ACTION_FYI, 074 ACTION_DISAPPROVE, 075 ACTION_RETURN_TO_PREVIOUS 076 }; 077 078 public static final String[] ANNOTATABLE_ACTIONS = new String[] { 079 ACTION_APPROVE, 080 ACTION_ACKNOWLEDGE, 081 ACTION_COMPLETE, 082 ACTION_FYI, 083 ACTION_DISAPPROVE, 084 ACTION_CANCEL, 085 ACTION_RETURN_TO_PREVIOUS 086 }; 087 088 public static final String[] EDITABLE_ACTIONS = new String[] { 089 ACTION_CREATE, 090 ACTION_ROUTE, 091 ACTION_APPROVE, 092 ACTION_DISAPPROVE, 093 ACTION_COMPLETE 094 }; 095 096 private String action; 097 098 public UserAction(String action) { 099 if (action.equals(ACTION_CREATE_LABEL)) { 100 this.action = ACTION_CREATE; 101 } else if (action.equals(ACTION_LOAD_LABEL)) { 102 this.action = ACTION_LOAD; 103 } else if (action.equals(ACTION_ROUTE_LABEL)) { 104 this.action = ACTION_ROUTE; 105 } else if (action.equals(ACTION_APPROVE_LABEL)) { 106 this.action = ACTION_APPROVE; 107 } else if (action.equals(ACTION_DISAPPROVE_LABEL)) { 108 this.action = ACTION_DISAPPROVE; 109 } else if (action.equals(ACTION_CANCEL_LABEL)) { 110 this.action = ACTION_CANCEL; 111 } else if (action.equals(ACTION_BLANKETAPPROVE_LABEL)) { 112 this.action = ACTION_BLANKETAPPROVE; 113 } else if (action.equals(ACTION_FYI_LABEL)) { 114 this.action = ACTION_FYI; 115 } else if (action.equals(ACTION_ACKNOWLEDGE_LABEL)) { 116 this.action = ACTION_ACKNOWLEDGE; 117 } else if (action.equals(ACTION_SAVE_LABEL)) { 118 this.action = ACTION_SAVE; 119 } else if (action.equals(ACTION_COMPLETE_LABEL)) { 120 this.action = ACTION_COMPLETE; 121 } else if (action.equals(ACTION_DELETE_LABEL)) { 122 this.action = ACTION_DELETE; 123 } else if (action.equals(ACTION_RETURN_TO_PREVIOUS_LABEL)) { 124 this.action = ACTION_RETURN_TO_PREVIOUS; 125 } else if (action.equals(ACTION_REFRESH_FROM_LOOKUP_LABEL)) { 126 this.action = ACTION_REFRESH_FROM_LOOKUP; 127 } else { 128 this.action = action; 129 } 130 } 131 132 public String getAction() { 133 return action; 134 } 135 136 public boolean isLoadAction() { 137 return containsAction(LOAD_ACTIONS, action); 138 } 139 140 public boolean isIncrementVersionAction() { 141 return !isLoadAction() && !isReplaceVersionAction() && !ACTION_REFRESH_FROM_LOOKUP.equals(action); 142 } 143 144 public boolean isReplaceVersionAction() { 145 return containsAction(REPLACE_VERSION_ACTIONS, action); 146 } 147 148 public boolean isValidatableAction() { 149 return containsAction(VALIDATABLE_ACTIONS, action); 150 } 151 152 public boolean isAnnotatableAction() { 153 return containsAction(ANNOTATABLE_ACTIONS, action); 154 } 155 156 public boolean isEditableAction() { 157 return containsAction(EDITABLE_ACTIONS, action); 158 } 159 160 private boolean containsAction(String[] actions, String action) { 161 for (int index = 0; index < actions.length; index++) { 162 if (actions[index].equals(action)) { 163 return true; 164 } 165 } 166 return false; 167 } 168 169 }