001/** 002 * Copyright 2004-2014 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 */ 016package org.kuali.kpme.tklm.common; 017 018import java.util.ArrayList; 019import java.util.HashMap; 020import java.util.HashSet; 021import java.util.LinkedHashMap; 022import java.util.List; 023import java.util.Map; 024import java.util.Set; 025import java.util.TimeZone; 026 027import org.joda.time.format.DateTimeFormat; 028import org.joda.time.format.DateTimeFormatter; 029import org.kuali.kpme.core.KPMEConstants; 030import org.kuali.rice.kew.api.document.DocumentStatus; 031 032public class TkConstants { 033 034 //in days 035 public static final Integer LENGTH_OF_WORK_SCHEDULE = 10; 036 037 public static final String CLOCK_IN = "CI"; 038 public static final String CLOCK_OUT = "CO"; 039 public static final String LUNCH_IN = "LI"; // Coming back from Lunch 040 public static final String LUNCH_OUT = "LO"; // Leaving for Lunch 041 042 public static final List<String> ON_THE_CLOCK_CODES = new ArrayList<String>(); 043 044 static { 045 ON_THE_CLOCK_CODES.add(CLOCK_IN); 046 ON_THE_CLOCK_CODES.add(LUNCH_IN); 047 } 048 049 // Calendar Types 050 public static final String CALENDAR_TYPE_PAY = "Pay"; 051 public static final String CALENDAR_TYPE_LEAVE = "Leave"; 052 053 public static final String EARN_CODE_CPE = "CPE"; 054 055 // action history 056 public static final String DELETE = "DELETE"; 057 public static final String ADD = "ADD"; 058 public static final String MODIFIED = "MODIFIED"; 059 060 public static final Map<String,String> ACTION_HISTORY_CODES = new HashMap<String,String>(); 061 062 static { 063 ACTION_HISTORY_CODES.put("A", "Add"); 064 ACTION_HISTORY_CODES.put("M", "Modify"); 065 ACTION_HISTORY_CODES.put("D", "Delete"); 066 } 067 068 public static final String SUPER_USER = TkConstants.ROLE_TK_SYS_ADMIN; 069 070 //Used to map job locations to specify the timezone for display purposes 071 public static final Map<String, String> LOCATION_TO_TIME_ZONE_MAP = new HashMap<String, String>(); 072 073 static { 074 LOCATION_TO_TIME_ZONE_MAP.put("NW", "America/Chicago"); 075 } 076 077 /** 078 * The following ROLE_* constants need to match what is in the workflow database. They will be 079 * used internally to obtain a reference to the underlying IDs in the workflow system. 080 * <p/> 081 * Used in *ValuesFinder classes for maintenance page dropdowns. 082 */ 083 public static final String ROLE_NAMESAPCE = "KUALI"; 084 public static final String ROLE_TK_GLOBAL_VO = "TK_GLOBAL_VO"; 085 public static final String ROLE_TK_DEPT_VO = "TK_DEPT_VO"; 086 public static final String ROLE_LV_DEPT_VO = "LV_DEPT_VO"; // KPME-1411 087 public static final String ROLE_TK_LOCATION_VO = "TK_LOCATION_VO"; 088 public static final String ROLE_TK_REVIEWER = "TK_REVIEWER"; 089 public static final String ROLE_TK_APPROVER = "TK_APPROVER"; 090 public static final String ROLE_TK_APPROVER_DELEGATE = "TK_APPROVER_DELEGATE"; 091 public static final String ROLE_TK_EMPLOYEE = "TK_EMPLOYEE"; 092 public static final String ROLE_TK_LOCATION_ADMIN = "TK_ORG_ADMIN"; 093 public static final String ROLE_TK_DEPT_ADMIN = "TK_DEPT_ADMIN"; 094 public static final String ROLE_LV_DEPT_ADMIN = "LV_DEPT_ADMIN"; // KPME-1411 095 public static final String ROLE_TK_SYS_ADMIN = "TK_SYS_ADMIN"; 096 public static final String ROLE_WORK_AREA_QUALIFIER_ID = "workArea"; 097 public static final List<String> ROLE_ASSIGNMENT_FOR_USER_ROLES = new ArrayList<String>(6); 098 public static final Map<String, String> ALL_ROLES_MAP = new HashMap<String, String>(); 099 100 static { 101 ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_GLOBAL_VO); 102 ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_DEPT_VO); 103 ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_DEPT_ADMIN); 104 ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_REVIEWER); 105 ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_APPROVER); 106 ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_APPROVER_DELEGATE); 107 ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_LOCATION_ADMIN); 108 ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_LOCATION_VO); 109 ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_SYS_ADMIN); 110 111 ALL_ROLES_MAP.put(TkConstants.ROLE_TK_REVIEWER, "Reviewer"); // attach at 'work area' level, like approvers without departmental rules 112 ALL_ROLES_MAP.put(TkConstants.ROLE_TK_GLOBAL_VO, "Global View Only"); // can see everything in the system, but not modify 113 ALL_ROLES_MAP.put(TkConstants.ROLE_TK_DEPT_VO, "Time Department View Only"); // can only see objects belonging to a department 114 ALL_ROLES_MAP.put(TkConstants.ROLE_LV_DEPT_VO, "Leave Department View Only"); // kpme1411 115 116 ALL_ROLES_MAP.put(TkConstants.ROLE_TK_LOCATION_VO, "Location View Only"); 117 ALL_ROLES_MAP.put(TkConstants.ROLE_TK_APPROVER, "Approver"); // attach at 'work area', view only departmental rules 118 ALL_ROLES_MAP.put(TkConstants.ROLE_TK_APPROVER_DELEGATE, "Approver Delegate"); // attach at 'work area' 119 ALL_ROLES_MAP.put(TkConstants.ROLE_TK_EMPLOYEE, "Employee"); // only people with active assignments have this role. 120 ALL_ROLES_MAP.put(TkConstants.ROLE_TK_LOCATION_ADMIN, "Location Admin"); // location admin rename 121 ALL_ROLES_MAP.put(TkConstants.ROLE_TK_DEPT_ADMIN, "Time Department Admin"); 122 ALL_ROLES_MAP.put(TkConstants.ROLE_LV_DEPT_ADMIN, "Leave Department Admin"); // kpme1411 123 ALL_ROLES_MAP.put(TkConstants.ROLE_TK_SYS_ADMIN, "System Admin"); 124 125 } 126 127 128 129 public static final class ACTIONS { 130 public static final String CLOCK_IN = "clockIn"; 131 public static final String CLOCK_OUT = "clockOut"; 132 public static final String ADD_TIME_BLOCK = "addTimeBlock"; 133 public static final String UPDATE_TIME_BLOCK = "updateTimeBlock"; 134 public static final String DELETE_TIME_BLOCK = "deleteTimeBlock"; 135 } 136 137 public static final List<String> ClOCK_ACTIONS = new ArrayList<String>(); 138 139 static { 140 ClOCK_ACTIONS.add("CI"); 141 ClOCK_ACTIONS.add("CO"); 142 ClOCK_ACTIONS.add("LI"); // Coming back for Lunch 143 ClOCK_ACTIONS.add("LO"); // Leaving for Lunch 144 } 145 146 /** 147 * Simplistic state transition map, created statically for speed. 148 */ 149 public static final Map<String, Set<String>> CLOCK_ACTION_TRANSITION_MAP = new HashMap<String, Set<String>>(4); 150 151 static { 152 Set<String> ci = new HashSet<String>(); 153 ci.add(LUNCH_OUT); 154 ci.add(CLOCK_OUT); 155 156 Set<String> co = new HashSet<String>(); 157 co.add(CLOCK_IN); 158 159 Set<String> li = new HashSet<String>(); 160 li.add(CLOCK_OUT); 161 li.add(LUNCH_OUT); 162 163 Set<String> lo = new HashSet<String>(); 164 lo.add(LUNCH_IN); 165 166 CLOCK_ACTION_TRANSITION_MAP.put(CLOCK_IN, ci); 167 CLOCK_ACTION_TRANSITION_MAP.put(CLOCK_OUT, co); 168 CLOCK_ACTION_TRANSITION_MAP.put(LUNCH_IN, li); 169 CLOCK_ACTION_TRANSITION_MAP.put(LUNCH_OUT, lo); 170 } 171 172 // available Clock actions to choose from when user's modifying an existing Missed Punch Document based on 173 // the initial clock action 174 public static final Map<String, Set<String>> CLOCK_AVAILABLE_ACTION_MAP = new HashMap<String, Set<String>>(4); 175 176 static { 177 Set<String> ci = new HashSet<String>(); 178 ci.add(CLOCK_IN); 179 180 Set<String> co = new HashSet<String>(); 181 co.add(CLOCK_OUT); 182 co.add(LUNCH_OUT); 183 184 Set<String> li = new HashSet<String>(); 185 li.add(LUNCH_IN); 186 187 Set<String> lo = new HashSet<String>(); 188 lo.add(CLOCK_OUT); 189 lo.add(LUNCH_OUT); 190 191 CLOCK_AVAILABLE_ACTION_MAP.put(CLOCK_IN, ci); 192 CLOCK_AVAILABLE_ACTION_MAP.put(CLOCK_OUT, co); 193 CLOCK_AVAILABLE_ACTION_MAP.put(LUNCH_IN, li); 194 CLOCK_AVAILABLE_ACTION_MAP.put(LUNCH_OUT, lo); 195 } 196 197 public static final Map<String, String> CLOCK_ACTION_STRINGS = new HashMap<String, String>(4); 198 199 static { 200 CLOCK_ACTION_STRINGS.put(CLOCK_IN, "Clock In"); 201 CLOCK_ACTION_STRINGS.put(CLOCK_OUT, "Clock Out"); 202 CLOCK_ACTION_STRINGS.put(LUNCH_IN, "Lunch In"); // Coming back for Lunch 203 CLOCK_ACTION_STRINGS.put(LUNCH_OUT, "Lunch Out"); // Going to Lunch 204 } 205 206 // document ID request parameter name 207 public static final String DOCUMENT_ID_REQUEST_NAME = "docid"; 208 //Threshold in hours for clockin highlighting on approvers tab 209 public static final Integer NUMBER_OF_HOURS_CLOCKED_IN_APPROVE_TAB_HIGHLIGHT = 12; 210 211 public static final String GMT_TIME_ZONE_ID = "Etc/GMT"; 212 public static final TimeZone GMT_TIME_ZONE = TimeZone.getTimeZone(GMT_TIME_ZONE_ID); 213 //public static final String SYSTEM_TIME_ZONE = TimeZone.getDefault().getDisplayName(); 214 215 //public static final DateTimeZone SYSTEM_DATE_TIME_ZONE = DateTimeZone.forID(TKUtils.getSystemTimeZone()); 216 public static final DateTimeFormatter DT_BASIC_TIME_FORMAT = DateTimeFormat.forPattern("hh:mm aa"); 217 public static final DateTimeFormatter DT_MILITARY_TIME_FORMAT = DateTimeFormat.forPattern("H:mm"); 218 public static final DateTimeFormatter DT_ABBREV_DATE_FORMAT = DateTimeFormat.forPattern("MM/dd"); 219 public static final DateTimeFormatter DT_FULL_DATE_TIME_FORMAT = DateTimeFormat.forPattern("MM/dd/yyyy hh:mm aa"); 220 221 public static DateTimeFormatter DT_JUST_DAY_FORMAT = DateTimeFormat.forPattern("dd"); 222 223 224 public static final Map<String, String> EMPLOYEE_OVERRIDE_TYPE = new LinkedHashMap<String, String>(5); 225 226 static { 227 EMPLOYEE_OVERRIDE_TYPE.put("MB", "Max Balance"); 228 EMPLOYEE_OVERRIDE_TYPE.put("MTA", "Max Transfer Amount"); 229 EMPLOYEE_OVERRIDE_TYPE.put("MPA", "Max Payout Amount"); 230 EMPLOYEE_OVERRIDE_TYPE.put("MU", "Max Usage"); 231 EMPLOYEE_OVERRIDE_TYPE.put("MAC", "Max Annual Carryover"); 232 } 233 234 public static final String DAILY_OVT_CODE = "DOT"; 235 236 public static final class CacheNamespace { 237 public static final String MODULE_NAME = "tklm"; 238 public static final String NAMESPACE_PREFIX = KPMEConstants.CacheNamespace.ROOT_NAMESPACE_PREFIX + "/" 239 + MODULE_NAME +'/'; 240 } 241 242 public static final List<String> EMPLOYEE_APPROVAL_DOC_STATUS = new ArrayList<String>(); 243 static { 244 EMPLOYEE_APPROVAL_DOC_STATUS.add(DocumentStatus.INITIATED.getCode()); 245 EMPLOYEE_APPROVAL_DOC_STATUS.add(DocumentStatus.SAVED.getCode()); 246 } 247 248 public static final List<String> MISSEDPUNCH_APPROVAL_TIME_DOC_STATUS = new ArrayList<String>(); 249 static { 250 MISSEDPUNCH_APPROVAL_TIME_DOC_STATUS.add(DocumentStatus.INITIATED.getCode()); 251 MISSEDPUNCH_APPROVAL_TIME_DOC_STATUS.add(DocumentStatus.SAVED.getCode()); 252 MISSEDPUNCH_APPROVAL_TIME_DOC_STATUS.add(DocumentStatus.ENROUTE.getCode()); 253 } 254 255}