View Javadoc

1   /**
2    * Copyright 2004-2014 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.kpme.tklm.common;
17  
18  import java.util.ArrayList;
19  import java.util.HashMap;
20  import java.util.HashSet;
21  import java.util.LinkedHashMap;
22  import java.util.List;
23  import java.util.Map;
24  import java.util.Set;
25  import java.util.TimeZone;
26  
27  import org.joda.time.format.DateTimeFormat;
28  import org.joda.time.format.DateTimeFormatter;
29  import org.kuali.kpme.core.KPMEConstants;
30  import org.kuali.rice.kew.api.document.DocumentStatus;
31  
32  public class TkConstants {
33  
34      //in days
35      public static final Integer LENGTH_OF_WORK_SCHEDULE = 10;
36  
37      public static final String CLOCK_IN = "CI";
38      public static final String CLOCK_OUT = "CO";
39      public static final String LUNCH_IN = "LI"; // Coming back from Lunch
40      public static final String LUNCH_OUT = "LO"; // Leaving for Lunch
41  
42      public static final List<String> ON_THE_CLOCK_CODES = new ArrayList<String>();
43  
44      static {
45          ON_THE_CLOCK_CODES.add(CLOCK_IN);
46          ON_THE_CLOCK_CODES.add(LUNCH_IN);
47      }
48  
49      // Calendar Types
50      public static final String CALENDAR_TYPE_PAY = "Pay";
51      public static final String CALENDAR_TYPE_LEAVE = "Leave";
52      
53      public static final String EARN_CODE_CPE = "CPE";
54      
55      // action history
56      public static final String DELETE = "DELETE";
57      public static final String ADD = "ADD";
58      public static final String MODIFIED = "MODIFIED";
59      
60      public static final Map<String,String> ACTION_HISTORY_CODES = new HashMap<String,String>();
61      
62      static {
63      	ACTION_HISTORY_CODES.put("A", "Add");
64      	ACTION_HISTORY_CODES.put("M", "Modify");
65      	ACTION_HISTORY_CODES.put("D", "Delete");
66      }
67  
68      public static final String SUPER_USER = TkConstants.ROLE_TK_SYS_ADMIN;
69  
70      //Used to map job locations to specify the timezone for display purposes
71      public static final Map<String, String> LOCATION_TO_TIME_ZONE_MAP = new HashMap<String, String>();
72  
73      static {
74          LOCATION_TO_TIME_ZONE_MAP.put("NW", "America/Chicago");
75      }
76  
77      /**
78       * The following ROLE_* constants need to match what is in the workflow database.  They will be
79       * used internally to obtain a reference to the underlying IDs in the workflow system.
80       * <p/>
81       * Used in *ValuesFinder classes for maintenance page dropdowns.
82       */
83      public static final String ROLE_NAMESAPCE = "KUALI";
84      public static final String ROLE_TK_GLOBAL_VO = "TK_GLOBAL_VO";
85      public static final String ROLE_TK_DEPT_VO = "TK_DEPT_VO";
86      public static final String ROLE_LV_DEPT_VO = "LV_DEPT_VO"; // KPME-1411
87      public static final String ROLE_TK_LOCATION_VO = "TK_LOCATION_VO";
88      public static final String ROLE_TK_REVIEWER = "TK_REVIEWER";
89      public static final String ROLE_TK_APPROVER = "TK_APPROVER";
90      public static final String ROLE_TK_APPROVER_DELEGATE = "TK_APPROVER_DELEGATE";
91      public static final String ROLE_TK_EMPLOYEE = "TK_EMPLOYEE";
92      public static final String ROLE_TK_LOCATION_ADMIN = "TK_ORG_ADMIN";
93      public static final String ROLE_TK_DEPT_ADMIN = "TK_DEPT_ADMIN";
94      public static final String ROLE_LV_DEPT_ADMIN = "LV_DEPT_ADMIN"; // KPME-1411
95      public static final String ROLE_TK_SYS_ADMIN = "TK_SYS_ADMIN";
96      public static final String ROLE_WORK_AREA_QUALIFIER_ID = "workArea";
97      public static final List<String> ROLE_ASSIGNMENT_FOR_USER_ROLES = new ArrayList<String>(6);
98      public static final Map<String, String> ALL_ROLES_MAP = new HashMap<String, String>();
99  
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 }