001    /**
002     * Copyright 2004-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.hr.time.util;
017    
018    import java.math.BigDecimal;
019    import java.math.MathContext;
020    import java.math.RoundingMode;
021    import java.util.ArrayList;
022    import java.util.HashMap;
023    import java.util.HashSet;
024    import java.util.LinkedHashMap;
025    import java.util.List;
026    import java.util.Map;
027    import java.util.Set;
028    import java.util.TimeZone;
029    
030    import org.joda.time.DateTimeZone;
031    import org.joda.time.format.DateTimeFormat;
032    import org.joda.time.format.DateTimeFormatter;
033    import org.kuali.hr.lm.accrual.AccrualCategory;
034    import org.kuali.hr.lm.leaveplan.LeavePlan;
035    import org.kuali.hr.time.earncode.EarnCode;
036    import org.kuali.rice.kew.api.KewApiConstants;
037    import org.kuali.rice.kew.api.document.DocumentStatus;
038    
039    public class TkConstants {
040        public static final int DEFAULT_CACHE_TIME = 900;
041        public static final String TK_TARGET_USER_RETURN = "tkTargetReturn";
042        public static final String TK_TARGET_USER_PERSON = "tkTargetPerson";
043    
044        public static final String WILDCARD_CHARACTER = "%";
045        public static final Long WILDCARD_LONG = -1L;
046    
047        //in days
048        public static final Integer LENGTH_OF_WORK_SCHEDULE = 10;
049    
050        public static final String CLOCK_IN = "CI";
051        public static final String CLOCK_OUT = "CO";
052        public static final String LUNCH_IN = "LI"; // Coming back from Lunch
053        public static final String LUNCH_OUT = "LO"; // Leaving for Lunch
054    
055        public static final List<String> ON_THE_CLOCK_CODES = new ArrayList<String>();
056    
057        static {
058            ON_THE_CLOCK_CODES.add(CLOCK_IN);
059            ON_THE_CLOCK_CODES.add(LUNCH_IN);
060        }
061    
062        // action history
063        public static final String DELETE = "DELETE";
064        public static final String ADD = "ADD";
065        public static final String MODIFIED = "MODIFIED";
066    
067        // earn code type
068        public static final String EARN_CODE_HOUR = "H";
069        public static final String EARN_CODE_TIME = "T";
070        public static final String EARN_CODE_AMOUNT = "A";
071        public static final String EARN_CODE_OVT = "OVT";
072        public static final String EARN_CODE_CPE = "CPE";
073        public static final String EARN_CODE_DAY = "D";
074        
075        public static final String GMT_TIME_ZONE_ID = "Etc/GMT";
076        public static final TimeZone GMT_TIME_ZONE = TimeZone.getTimeZone(GMT_TIME_ZONE_ID);
077        //public static final String SYSTEM_TIME_ZONE = TimeZone.getDefault().getDisplayName();
078    
079        //public static final DateTimeZone SYSTEM_DATE_TIME_ZONE = DateTimeZone.forID(TKUtils.getSystemTimeZone());
080        public static final  DateTimeFormatter DT_BASIC_TIME_FORMAT = DateTimeFormat.forPattern("hh:mm aa");
081        public static final DateTimeFormatter DT_MILITARY_TIME_FORMAT = DateTimeFormat.forPattern("H:mm");
082        public static final DateTimeFormatter DT_BASIC_DATE_FORMAT = DateTimeFormat.forPattern("MM/dd/yyyy");
083        public static final DateTimeFormatter DT_ABBREV_DATE_FORMAT = DateTimeFormat.forPattern("MM/dd");
084        public static final DateTimeFormatter DT_FULL_DATE_TIME_FORMAT = DateTimeFormat.forPattern("MM/dd/yyyy hh:mm aa");
085    
086        public static DateTimeFormatter DT_JUST_DAY_FORMAT = DateTimeFormat.forPattern("dd");
087    
088        public static final int BIG_DECIMAL_SCALE = 2;
089        public static final RoundingMode BIG_DECIMAL_SCALE_ROUNDING = RoundingMode.HALF_EVEN;
090        public static final BigDecimal BIG_DECIMAL_SCALED_ZERO = BigDecimal.ZERO.setScale(TkConstants.BIG_DECIMAL_SCALE, TkConstants.BIG_DECIMAL_SCALE_ROUNDING);
091        public static final BigDecimal BIG_DECIMAL_NEGATIVE_ONE = new BigDecimal("-1");
092    
093        public static final MathContext MATH_CONTEXT = new MathContext(5, BIG_DECIMAL_SCALE_ROUNDING);
094        public static final BigDecimal BIG_DECIMAL_1000 = BigDecimal.TEN.multiply(BigDecimal.TEN).multiply(BigDecimal.TEN);
095        public static final BigDecimal BIG_DECIMAL_60 = BigDecimal.TEN.multiply(new BigDecimal("6"));
096        public static final BigDecimal BIG_DECIMAL_MS_IN_H = BIG_DECIMAL_1000.multiply(BIG_DECIMAL_60).multiply(BIG_DECIMAL_60);
097        public static final BigDecimal BIG_DECIMAL_MS_IN_M = BIG_DECIMAL_1000.multiply(BIG_DECIMAL_60);
098        public static final BigDecimal BIG_DECIMAL_HRS_IN_DAY = new BigDecimal(24);
099    
100        public static final String SUPER_USER = TkConstants.ROLE_TK_SYS_ADMIN;
101    
102        //Used to map job locations to specify the timezone for display purposes
103        public static final Map<String, String> LOCATION_TO_TIME_ZONE_MAP = new HashMap<String, String>();
104    
105        static {
106            LOCATION_TO_TIME_ZONE_MAP.put("NW", "America/Chicago");
107        }
108    
109        /**
110         * The following ROLE_* constants need to match what is in the workflow database.  They will be
111         * used internally to obtain a reference to the underlying IDs in the workflow system.
112         * <p/>
113         * Used in *ValuesFinder classes for maintenance page dropdowns.
114         */
115        public static final String ROLE_NAMESAPCE = "KUALI";
116        public static final String ROLE_TK_GLOBAL_VO = "TK_GLOBAL_VO";
117        public static final String ROLE_TK_DEPT_VO = "TK_DEPT_VO";
118        public static final String ROLE_LV_DEPT_VO = "LV_DEPT_VO"; // KPME-1411
119        public static final String ROLE_TK_LOCATION_VO = "TK_LOCATION_VO";
120        public static final String ROLE_TK_REVIEWER = "TK_REVIEWER";
121        public static final String ROLE_TK_APPROVER = "TK_APPROVER";
122        public static final String ROLE_TK_APPROVER_DELEGATE = "TK_APPROVER_DELEGATE";
123        public static final String ROLE_TK_EMPLOYEE = "TK_EMPLOYEE";
124        public static final String ROLE_TK_LOCATION_ADMIN = "TK_ORG_ADMIN";
125        public static final String ROLE_TK_DEPT_ADMIN = "TK_DEPT_ADMIN";
126        public static final String ROLE_LV_DEPT_ADMIN = "LV_DEPT_ADMIN"; // KPME-1411
127        public static final String ROLE_TK_SYS_ADMIN = "TK_SYS_ADMIN";
128        public static final String ROLE_WORK_AREA_QUALIFIER_ID = "workArea";
129        public static final List<String> ROLE_ASSIGNMENT_FOR_WORK_AREA = new ArrayList<String>(2);
130        public static final List<String> ROLE_ASSIGNMENT_FOR_USER_ROLES = new ArrayList<String>(6);
131        public static final Map<String, String> ALL_ROLES_MAP = new HashMap<String, String>();
132        public static final List<String> ROLE_ASSIGNMENT_FOR_WORK_AREA_OT_EDIT = new ArrayList<String>(3);
133    
134        static {
135            ROLE_ASSIGNMENT_FOR_WORK_AREA.add(TkConstants.ROLE_TK_APPROVER);
136            ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_GLOBAL_VO);
137            ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_DEPT_VO);
138            ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_DEPT_ADMIN);
139            ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_REVIEWER);
140            ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_APPROVER);
141            ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_APPROVER_DELEGATE);
142            ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_LOCATION_ADMIN);
143            ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_LOCATION_VO);
144            ROLE_ASSIGNMENT_FOR_USER_ROLES.add(TkConstants.ROLE_TK_SYS_ADMIN);
145    
146            ROLE_ASSIGNMENT_FOR_WORK_AREA_OT_EDIT.add(TkConstants.ROLE_TK_EMPLOYEE);
147            ROLE_ASSIGNMENT_FOR_WORK_AREA_OT_EDIT.add(TkConstants.ROLE_TK_APPROVER);
148            ROLE_ASSIGNMENT_FOR_WORK_AREA_OT_EDIT.add(TkConstants.ROLE_TK_APPROVER_DELEGATE);
149            ROLE_ASSIGNMENT_FOR_WORK_AREA_OT_EDIT.add(TkConstants.ROLE_TK_DEPT_ADMIN);
150    
151            ALL_ROLES_MAP.put(TkConstants.ROLE_TK_REVIEWER, "Reviewer"); // attach at 'work area' level, like approvers without departmental rules
152            ALL_ROLES_MAP.put(TkConstants.ROLE_TK_GLOBAL_VO, "Global View Only"); // can see everything in the system, but not modify
153            ALL_ROLES_MAP.put(TkConstants.ROLE_TK_DEPT_VO, "Time Department View Only"); // can only see objects belonging to a department
154            ALL_ROLES_MAP.put(TkConstants.ROLE_LV_DEPT_VO, "Leave Department View Only"); // kpme1411
155            
156            ALL_ROLES_MAP.put(TkConstants.ROLE_TK_LOCATION_VO, "Location View Only");
157            ALL_ROLES_MAP.put(TkConstants.ROLE_TK_APPROVER, "Approver"); // attach at 'work area', view only departmental rules
158            ALL_ROLES_MAP.put(TkConstants.ROLE_TK_APPROVER_DELEGATE, "Approver Delegate"); // attach at 'work area'
159            ALL_ROLES_MAP.put(TkConstants.ROLE_TK_EMPLOYEE, "Employee"); // only people with active assignments have this role.
160            ALL_ROLES_MAP.put(TkConstants.ROLE_TK_LOCATION_ADMIN, "Location Admin"); // location admin rename
161            ALL_ROLES_MAP.put(TkConstants.ROLE_TK_DEPT_ADMIN, "Time Department Admin");
162            ALL_ROLES_MAP.put(TkConstants.ROLE_LV_DEPT_ADMIN, "Leave Department Admin"); // kpme1411
163            ALL_ROLES_MAP.put(TkConstants.ROLE_TK_SYS_ADMIN, "System Admin");
164    
165        }
166    
167        public static final class ACTIONS {
168            public static final String CLOCK_IN = "clockIn";
169            public static final String CLOCK_OUT = "clockOut";
170            public static final String ADD_TIME_BLOCK = "addTimeBlock";
171            public static final String UPDATE_TIME_BLOCK = "updateTimeBlock";
172            public static final String DELETE_TIME_BLOCK = "deleteTimeBlock";
173        }
174    
175        public static final List<String> ClOCK_ACTIONS = new ArrayList<String>();
176    
177        static {
178            ClOCK_ACTIONS.add("CI");
179            ClOCK_ACTIONS.add("CO");
180            ClOCK_ACTIONS.add("LI"); // Coming back for Lunch
181            ClOCK_ACTIONS.add("LO"); // Leaving for Lunch
182        }
183    
184        /**
185         * Simplistic state transition map, created statically for speed.
186         */
187        public static final Map<String, Set<String>> CLOCK_ACTION_TRANSITION_MAP = new HashMap<String, Set<String>>(4);
188    
189        static {
190            Set<String> ci = new HashSet<String>();
191            ci.add(LUNCH_OUT);
192            ci.add(CLOCK_OUT);
193    
194            Set<String> co = new HashSet<String>();
195            co.add(CLOCK_IN);
196    
197            Set<String> li = new HashSet<String>();
198            li.add(CLOCK_OUT);
199    
200            Set<String> lo = new HashSet<String>();
201            lo.add(LUNCH_IN);
202    
203            CLOCK_ACTION_TRANSITION_MAP.put(CLOCK_IN, ci);
204            CLOCK_ACTION_TRANSITION_MAP.put(CLOCK_OUT, co);
205            CLOCK_ACTION_TRANSITION_MAP.put(LUNCH_IN, li);
206            CLOCK_ACTION_TRANSITION_MAP.put(LUNCH_OUT, lo);
207        }
208    
209        // available Clock actions to choose from when user's modifying an existing Missed Punch Document based on
210        // the initial clock action
211        public static final Map<String, Set<String>> CLOCK_AVAILABLE_ACTION_MAP = new HashMap<String, Set<String>>(4);
212    
213        static {
214            Set<String> ci = new HashSet<String>();
215            ci.add(CLOCK_IN);
216    
217            Set<String> co = new HashSet<String>();
218            co.add(CLOCK_OUT);
219            co.add(LUNCH_OUT);
220    
221            Set<String> li = new HashSet<String>();
222            li.add(LUNCH_IN);
223    
224            Set<String> lo = new HashSet<String>();
225            lo.add(CLOCK_OUT);
226            lo.add(LUNCH_OUT);
227    
228            CLOCK_AVAILABLE_ACTION_MAP.put(CLOCK_IN, ci);
229            CLOCK_AVAILABLE_ACTION_MAP.put(CLOCK_OUT, co);
230            CLOCK_AVAILABLE_ACTION_MAP.put(LUNCH_IN, li);
231            CLOCK_AVAILABLE_ACTION_MAP.put(LUNCH_OUT, lo);
232        }
233        
234        public static final Map<String, String> CLOCK_ACTION_STRINGS = new HashMap<String, String>(4);
235    
236        static {
237            CLOCK_ACTION_STRINGS.put(CLOCK_IN, "Clock In");
238            CLOCK_ACTION_STRINGS.put(CLOCK_OUT, "Clock Out");
239            CLOCK_ACTION_STRINGS.put(LUNCH_IN, "Lunch In"); // Coming back for Lunch
240            CLOCK_ACTION_STRINGS.put(LUNCH_OUT, "Lunch Out"); // Going to Lunch
241        }
242    
243        public static final class DOCUMENT_ACTIONS {
244            public static final String ROUTE = "R";
245            public static final String APPROVE = "A";
246            public static final String DISAPPROVE = "D";
247        }
248    
249        public static final class BATCH_JOB_ACTIONS {
250            public static final String BATCH_JOB_INITIATE = "BI";
251            public static final String BATCH_JOB_ROUTE = "BR";
252            public static final String BATCH_JOB_APPROVE = "BA";
253        }
254    
255        public static final class ROUTE_STATUS {
256            public static final String INITIATED = DocumentStatus.INITIATED.getCode();
257            public static final String ENROUTE = DocumentStatus.ENROUTE.getCode();
258            public static final String FINAL = DocumentStatus.FINAL.getCode();
259            public static final String CANCEL = DocumentStatus.CANCELED.getCode();
260            public static final String SAVED = DocumentStatus.SAVED.getCode();
261            public static final String DISAPPROVED = DocumentStatus.DISAPPROVED.getCode();
262            public static final String EXCEPTION = DocumentStatus.EXCEPTION.getCode();
263        }
264    
265        public static final Map<String, String> DOC_ROUTE_STATUS = new HashMap<String, String>(8);
266    
267        static {
268            DOC_ROUTE_STATUS.put(KewApiConstants.ROUTE_HEADER_INITIATED_CD, KewApiConstants.ROUTE_HEADER_INITIATED_LABEL);
269            DOC_ROUTE_STATUS.put(KewApiConstants.ROUTE_HEADER_CANCEL_CD, KewApiConstants.ROUTE_HEADER_CANCEL_LABEL);
270            DOC_ROUTE_STATUS.put(KewApiConstants.ROUTE_HEADER_ENROUTE_CD, KewApiConstants.ROUTE_HEADER_ENROUTE_LABEL);
271            DOC_ROUTE_STATUS.put(KewApiConstants.ROUTE_HEADER_FINAL_CD, KewApiConstants.ROUTE_HEADER_FINAL_LABEL);
272            DOC_ROUTE_STATUS.put(KewApiConstants.ROUTE_HEADER_DISAPPROVED_CD, KewApiConstants.ROUTE_HEADER_DISAPPROVED_LABEL);
273            DOC_ROUTE_STATUS.put(KewApiConstants.ROUTE_HEADER_EXCEPTION_CD, KewApiConstants.ROUTE_HEADER_EXCEPTION_LABEL);
274            DOC_ROUTE_STATUS.put(KewApiConstants.ROUTE_HEADER_SAVED_CD, KewApiConstants.ROUTE_HEADER_SAVED_LABEL);
275        }
276    
277        public static final class BATCH_JOB_NAMES {
278            public static final String INITIATE = "Initiate";
279            public static final String END_PAY_PERIOD = "End Pay Period";
280            public static final String END_REPORTING_PERIOD = "End Reporting Period";
281            public static final String EMPLOYEE_APPROVAL = "Employee Approval";
282            public static final String MISSED_PUNCH_APPROVAL = "Missed Punch Approval";
283            public static final String SUPERVISOR_APPROVAL = "Supervisor Approval";
284        }
285    
286        public static final String ASSIGNMENT_KEY_DELIMITER = "_";
287        public static final String HOLIDAY_EARN_CODE = "HOL";
288        // Special System earn code to represent lunch deductions.
289        public static final String LUNCH_EARN_CODE = "LUN";
290    
291        // calendar navigation
292        public static final String NEXT_TIMESHEET = "next";
293        public static final String PREV_TIMESHEET = "prev";
294    
295        // Timesheet document ID request parameter name
296        public static final String TIMESHEET_DOCUMENT_ID_REQUEST_NAME = "tdocid";
297        // document ID request parameter name
298        public static final String DOCUMENT_ID_REQUEST_NAME = "docid";
299        //Threshold in hours for clockin highlighting on approvers tab
300        public static final Integer NUMBER_OF_HOURS_CLOCKED_IN_APPROVE_TAB_HIGHLIGHT = 12;
301    
302        public static final List<String> TIME_ZONES = new ArrayList<String>();
303    
304        static {
305            TIME_ZONES.add("America/Chicago");
306            TIME_ZONES.add("America/Denver");
307            TIME_ZONES.add("America/Detroit");
308            TIME_ZONES.add("America/Indiana/Indianapolis");
309            TIME_ZONES.add("America/Phoenix");
310        }
311    
312        public String getLUNCH_EARN_CODE() {
313            return LUNCH_EARN_CODE;
314        }
315    
316        public String getEARN_CODE_AMOUNT() {
317            return EARN_CODE_AMOUNT;
318        }
319    
320        public String getHOLIDAY_EARN_CODE() {
321            return HOLIDAY_EARN_CODE;
322        }
323    
324        public static class ConfigSettings {
325            public static final String SESSION_TIMEOUT = "session.timeout";
326            public static final String KPME_SYSTEM_TIMEZONE = "kpme.system.timezone";
327        }
328    
329        public static final Integer PAGE_SIZE = 20;
330        public static final String APPROVAL_TABLE_ID = "row";
331    
332        public static final String IP_SEPERATOR = ".";
333        public static final String IP_WILDCARD_PATTERN = "(%|(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))";
334    
335        public static final String TASK_DEFAULT_DESP = "Default";
336    
337        public static final Map<String, String> SERVICE_UNIT_OF_TIME = new LinkedHashMap<String, String>(3);
338    
339            static {
340                    SERVICE_UNIT_OF_TIME.put("Y", "Years");
341                    SERVICE_UNIT_OF_TIME.put("M", "Months");
342                    //SERVICE_UNIT_OF_TIME.put("H", "Hours");
343            }
344    
345            public static final Map<String, String> UNIT_OF_TIME = new LinkedHashMap<String, String>(2);
346    
347            static {
348                    UNIT_OF_TIME.put("D", "Days");
349                    UNIT_OF_TIME.put("H", "Hours");
350            }
351            
352            public static final Map<String, String> MAX_BAL_FLAG = new LinkedHashMap<String, String>(2);
353    
354            static {
355                    MAX_BAL_FLAG.put("Y", "Yes");
356                    MAX_BAL_FLAG.put("N", "No");
357            }
358            
359            public static final Map<String, String> MAX_BALANCE_ACTION_FREQUENCY = new LinkedHashMap<String, String>(3);
360    
361            static {
362                    MAX_BALANCE_ACTION_FREQUENCY.put("LA", "Leave Approve");
363                    MAX_BALANCE_ACTION_FREQUENCY.put("YE", "Year End");
364                    MAX_BALANCE_ACTION_FREQUENCY.put("OD", "On Demand");
365                    //MAX_BALANCE_ACTION_FREQUENCY.put("NA", "Not Applicable");
366            }
367    
368            public static final Map<String, String> ACTION_AT_MAX_BALANCE = new LinkedHashMap<String, String>(3);
369    
370            static {
371                    ACTION_AT_MAX_BALANCE.put("T", "Transfer");
372                    ACTION_AT_MAX_BALANCE.put("P", "Payout");
373                    ACTION_AT_MAX_BALANCE.put("L", "Lose");
374                    //ACTION_AT_MAX_BALANCE.put("NA", "Not Applicable");
375            }
376    
377            public static final Map<String, String> EMPLOYEE_OVERRIDE_TYPE = new LinkedHashMap<String, String>(5);
378    
379            static {
380                    EMPLOYEE_OVERRIDE_TYPE.put("MB", "Max Balance");
381                    EMPLOYEE_OVERRIDE_TYPE.put("MTA", "Max Transfer Amount");
382                    EMPLOYEE_OVERRIDE_TYPE.put("MPA", "Max Payout Amount");
383                    EMPLOYEE_OVERRIDE_TYPE.put("MU", "Max Usage");
384                    EMPLOYEE_OVERRIDE_TYPE.put("MAC", "Max Annual Carryover");
385            }
386    
387        public static final String DAILY_OVT_CODE = "DOT";
388        
389        public static final Map<String, Set<String>> CLASS_INQUIRY_KEY_MAP = new HashMap<String, Set<String>>(4);
390    
391        static {
392            Set<String> keys = new HashSet<String>();
393            keys.add("leavePlan");
394            keys.add("effectiveDate");
395            CLASS_INQUIRY_KEY_MAP.put(LeavePlan.class.getName(), keys);
396            
397            keys = new HashSet<String>();
398            keys.add("accrualCategory");
399            keys.add("effectiveDate");
400            CLASS_INQUIRY_KEY_MAP.put(AccrualCategory.class.getName(), keys);
401            
402            keys = new HashSet<String>();
403            keys.add("earnCode");
404            keys.add("effectiveDate");
405            CLASS_INQUIRY_KEY_MAP.put(EarnCode.class.getName(), keys);
406        }
407    
408        public static final String FLSA_STATUS_NON_EXEMPT ="NE";
409        public static final String FLSA_STATUS_EXEMPT ="E";
410        
411        public static final String PAY_CALENDAR_TYPE = "payCalendar";
412        
413        // Calendar Types
414        public static final String CALENDAR_TYPE_PAY = "Pay";
415        public static final String CALENDAR_TYPE_LEAVE = "Leave";
416        
417        public static final String BATCH_USER_PRINCIPAL_NAME = "kpme.batch.user.principalName";
418    }