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.core.util;
17  
18  import org.apache.commons.collections.CollectionUtils;
19  import org.apache.commons.lang.StringUtils;
20  import org.joda.time.DateTime;
21  import org.joda.time.LocalDate;
22  import org.kuali.kpme.core.api.namespace.KPMENamespace;
23  import org.kuali.kpme.core.role.KPMERole;
24  import org.kuali.kpme.core.service.HrServiceLocator;
25  import org.kuali.rice.core.api.config.property.ConfigContext;
26  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
27  import org.kuali.rice.krad.util.GlobalVariables;
28  
29  public class HrContext {
30  
31      public static Boolean userSessionExists() {
32          return GlobalVariables.getUserSession() != null;
33      }
34  
35  	public static String getPrincipalId() {
36  		return GlobalVariables.getUserSession().getPrincipalId();
37  	}
38  
39      public static String getTargetPrincipalId() {
40          String principalId = (String) GlobalVariables.getUserSession().retrieveObject(HrConstants.TK_TARGET_USER_PERSON);
41          if (principalId == null) {
42          	principalId = GlobalVariables.getUserSession().getPerson().getPrincipalId();
43          }
44          return principalId;
45      }
46      
47      public static String getTargetName() {
48      	return KimApiServiceLocator.getIdentityService().getDefaultNamesForPrincipalId(getTargetPrincipalId()).getDefaultName().getCompositeName();
49      }
50      
51  	public static void setTargetPrincipalId(String principalId) {
52  		GlobalVariables.getUserSession().addObject(HrConstants.TK_TARGET_USER_PERSON, principalId);
53  	}
54      
55  	public static boolean isTargetInUse() {
56  		return GlobalVariables.getUserSession().retrieveObject(HrConstants.TK_TARGET_USER_PERSON) != null;
57  	}
58      
59  	public static void clearTargetUser() {
60  		GlobalVariables.getUserSession().removeObject(HrConstants.TK_TARGET_USER_PERSON);
61  	}
62  	
63  	public static boolean isSystemAdmin() {
64  		return HrServiceLocator.getKPMEGroupService().isMemberOfSystemAdministratorGroup(getPrincipalId(), LocalDate.now().toDateTimeAtStartOfDay());
65  	}
66  	
67  	public static boolean isTargetSystemAdmin() {
68  		return HrServiceLocator.getKPMEGroupService().isMemberOfSystemAdministratorGroup(getTargetPrincipalId(), LocalDate.now().toDateTimeAtStartOfDay());
69  	}
70  	
71  	public static boolean isGlobalViewOnly() {
72  		return HrServiceLocator.getKPMEGroupService().isMemberOfSystemViewOnlyGroup(getPrincipalId(), LocalDate.now().toDateTimeAtStartOfDay());
73  	}
74  	
75  	public static boolean isTargetGlobalViewOnly() {
76  		return HrServiceLocator.getKPMEGroupService().isMemberOfSystemViewOnlyGroup(getTargetPrincipalId(), LocalDate.now().toDateTimeAtStartOfDay());
77  	}
78  	
79  	public static boolean isAnyApprover() {
80  		return isApprover() || isApproverDelegate();
81  	}
82  
83      public static boolean isAnyPayrollProcessor() {
84          return isPayrollProcessor() || isPayrollProcessorDelegate();
85      }
86  	
87  	public static boolean isTargetAnyApprover() {
88  		return isTargetApprover() || isTargetApproverDelegate();
89  	}
90  	
91  	public static boolean isUserOrTargetAnyApprover() {
92  		return isAnyApprover() || isTargetAnyApprover();
93  	}
94  	
95  	public static boolean isUserOrTargetAnyPayrollProcessor() {
96  		return isAnyPayrollProcessor() || isTargetAnyPayrollProcessor();
97  	}
98  	
99  	public static boolean isUserOrTargetReviewer() {
100 		return isReviewer() || isTargetReviewer();
101 	}
102 	
103 	public static boolean isTargetAnyPayrollProcessor() {
104 		return isTargetPayrollProcessor() || isTargetPayrollProcessorDelegate();
105 	}
106 
107     public static boolean isAnyAdmin() {
108         String principalId = GlobalVariables.getUserSession().getPrincipalId();
109         DateTime date = LocalDate.now().toDateTimeAtStartOfDay();
110         boolean isSysAdmin = HrServiceLocator.getKPMEGroupService().isMemberOfSystemAdministratorGroup(principalId, new DateTime());
111         boolean isTimeLocationAdmin = HrServiceLocator.getKPMERoleService().principalHasRole(principalId, KPMENamespace.KPME_TK.getNamespaceCode(), KPMERole.TIME_LOCATION_ADMINISTRATOR.getRoleName(), date);
112         boolean isTimeSysAdmin = HrServiceLocator.getKPMERoleService().principalHasRole(principalId, KPMENamespace.KPME_TK.getNamespaceCode(), KPMERole.TIME_SYSTEM_ADMINISTRATOR.getRoleName(), date);
113         boolean isLeaveLocationAdmin = HrServiceLocator.getKPMERoleService().principalHasRole(principalId, KPMENamespace.KPME_LM.getNamespaceCode(), KPMERole.LEAVE_LOCATION_ADMINISTRATOR.getRoleName(), date);
114         boolean isLeaveSysAdmin = HrServiceLocator.getKPMERoleService().principalHasRole(principalId, KPMENamespace.KPME_LM.getNamespaceCode(), KPMERole.LEAVE_SYSTEM_ADMINISTRATOR.getRoleName(), date);
115 
116         return isSysAdmin || isLeaveLocationAdmin || isLeaveSysAdmin || isTimeLocationAdmin || isTimeSysAdmin;
117     }
118 
119 	public static boolean isApprover() {
120 		return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
121 	}
122 	
123 	public static boolean isTargetApprover() {
124 		return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
125 	}
126 	
127 	public static boolean isApproverDelegate() {
128 		return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.APPROVER_DELEGATE.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
129 	}
130 	
131 	public static boolean isTargetApproverDelegate() {
132 		return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.APPROVER_DELEGATE.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
133 	}
134 	
135 	public static boolean isReviewer() {
136 		return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.REVIEWER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
137 	}
138 	
139 	public static boolean isTargetReviewer() {
140 		return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.REVIEWER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
141 	}
142 	
143 	public static boolean isActiveEmployee() {
144     	return CollectionUtils.isNotEmpty(HrServiceLocator.getAssignmentService().getAssignments(getPrincipalId(), LocalDate.now()));
145 	}
146     
147 	public static boolean isTargetActiveEmployee() {
148 		return CollectionUtils.isNotEmpty(HrServiceLocator.getAssignmentService().getAssignments(getTargetPrincipalId(), LocalDate.now()));
149 	}
150 	
151 	// KPME-2532
152 	public static boolean isPayrollProcessor() {
153 		return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.PAYROLL_PROCESSOR.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
154 	}
155 	
156 	public static boolean isTargetPayrollProcessor() {
157 		return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.PAYROLL_PROCESSOR.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
158 	}
159 	
160 	public static boolean isPayrollProcessorDelegate() {
161 		return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.PAYROLL_PROCESSOR_DELEGATE.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
162 	}
163 	
164 	public static boolean isTargetPayrollProcessorDelegate() {
165 		return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.PAYROLL_PROCESSOR_DELEGATE.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
166 	}
167 
168     //KPME-2699
169     public static boolean canEditInactiveRecords() {
170         return isAnyAdmin();
171     }
172     
173     //KPME-3400
174     public static boolean isUserOrTargetKOHRInstitutionAdmin(){
175     	return isUserKOHRInstitutionAdmin() || isTargetKOHRInstitutionAdmin();
176     }
177 
178     public static boolean isUserKOHRInstitutionAdmin(){
179     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.KOHR_INSTITUTION_ADMINISTRATOR.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
180     }
181 
182     public static boolean isTargetKOHRInstitutionAdmin(){
183     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.KOHR_INSTITUTION_ADMINISTRATOR.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
184     }
185 
186     public static boolean isUserOrTargetKOHRAcademicHrAdmin(){
187     	return isUserKOHRAcademicHrAdmin() || isTargetKOHRAcademicHrAdmin();
188     }
189     public static boolean isUserKOHRAcademicHrAdmin(){
190     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.KOHR_ACADEMIC_HR_ADMINISTRATOR.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
191     }
192 
193     public static boolean isTargetKOHRAcademicHrAdmin(){
194     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.KOHR_ACADEMIC_HR_ADMINISTRATOR.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
195     }
196 
197     public static boolean isUserOrTargetKOHRInstitutionViewOnly(){
198     	return isUserKOHRInstitutionViewOnly() || isTargetKOHRInstitutionViewOnly();
199     }
200     public static boolean isUserKOHRInstitutionViewOnly(){
201     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.KOHR_INSTITUTION_VIEW_ONLY.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
202     }
203 
204     public static boolean isTargetKOHRInstitutionViewOnly(){
205     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.KOHR_INSTITUTION_VIEW_ONLY.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
206     }
207 
208     public static boolean isUserOrTargetKOHRLocationViewOnly(){
209     	return isUserKOHRLocationViewOnly() || isTargetKOHRLocationViewOnly();
210     }
211     public static boolean isUserKOHRLocationViewOnly(){
212     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.KOHR_INSTITUTION_VIEW_ONLY.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
213     }
214 
215     public static boolean isTargetKOHRLocationViewOnly(){
216     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.KOHR_INSTITUTION_VIEW_ONLY.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
217     }
218 
219     public static boolean isUserOrTargetKOHRLocationAdmin(){
220     	return isUserKOHRLocationAdmin() || isTargetKOHRLocationAdmin();
221     }
222     public static boolean isUserKOHRLocationAdmin(){
223     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.KOHR_LOCATION_ADMINISTRATOR.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
224     }
225 
226     public static boolean isTargetKOHRLocationAdmin(){
227     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.KOHR_LOCATION_ADMINISTRATOR.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
228     }
229 
230     public static boolean isUserOrTargetKOHROrgAdmin(){
231     	return isUserKOHROrgAdmin() || isTargetKOHROrgAdmin();
232     }
233     public static boolean isUserKOHROrgAdmin(){
234     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.KOHR_ORG_ADMINISTRATOR.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
235     }
236 
237     public static boolean isTargetKOHROrgAdmin(){
238     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.KOHR_ORG_ADMINISTRATOR.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
239     }
240 
241     public static boolean isUserOrTargetKOHROrgViewOnly(){
242     	return isUserKOHROrgViewOnly() || isTargetKOHROrgViewOnly();
243     }
244     public static boolean isTargetKOHROrgViewOnly(){
245     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.KOHR_ORG_VIEW_ONLY.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
246     }
247 
248     public static boolean isUserKOHROrgViewOnly(){
249     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.KOHR_ORG_VIEW_ONLY.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
250     }
251 
252     public static boolean isUserOrTargetHRDepartmentAdmin(){
253     	return isUserHRDepartmentAdmin() || isTargetHRDepartmentAdmin();
254     }
255     public static boolean isTargetHRDepartmentAdmin(){
256     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.HR_DEPARTMENT_ADMINISTRATOR.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
257     }
258 
259     public static boolean isUserHRDepartmentAdmin(){
260     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.HR_DEPARTMENT_ADMINISTRATOR.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
261     }
262 
263     public static boolean isUserOrTargetHRDepartmentViewOnly(){
264     	return isUserHRDepartmentViewOnly() || isTargetHRDepartmentViewOnly();
265     }
266     public static boolean isTargetHRDepartmentViewOnly(){
267     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.HR_DEPARTMENT_VIEW_ONLY.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
268     }
269 
270     public static boolean isUserHRDepartmentViewOnly(){
271     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.HR_DEPARTMENT_VIEW_ONLY.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
272     }
273 
274     public static boolean isUserOrTargetHRInstitutionApprover(){
275     	return isUserHRInstitutionApprover() || isTargetHRInstitutionApprover();
276     }
277     public static boolean isTargetHRInstitutionApprover(){
278     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.HR_INSTITUTION_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
279     }
280 
281     public static boolean isUserHRInstitutionApprover(){
282     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.HR_INSTITUTION_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
283     }
284 
285     public static boolean isUserOrTargetAcademicHRInstitutionApprover(){
286     	return isUserAcademicHRInstitutionApprover() || isTargetAcademicHRInstitutionApprover();
287     }
288     public static boolean isTargetAcademicHRInstitutionApprover(){
289     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.ACADEMIC_HR_INSTITUTION_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
290     }
291 
292     public static boolean isUserAcademicHRInstitutionApprover(){
293     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.ACADEMIC_HR_INSTITUTION_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
294     }
295 
296     public static boolean isUserOrTargetBudgetApprover(){
297     	return isUserBudgetApprover() || isTargetBudgetApprover();
298     }
299     public static boolean isTargetBudgetApprover(){
300     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.BUDGET_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
301     }
302 
303     public static boolean isUserBudgetApprover(){
304     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.BUDGET_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
305     }
306 
307     public static boolean isUserOrTargetPayrollApprover(){
308     	return isUserPayrollApprover() || isTargetPayrollApprover();
309     }
310     public static boolean isTargetPayrollApprover(){
311     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.PAYROLL_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
312     }
313 
314     public static boolean isUserPayrollApprover(){
315     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.PAYROLL_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
316     }
317 
318     public static boolean isUserOrTargetHRLocationApprover(){
319     	return isUserHRLocationApprover() || isTargetHRLocationApprover();
320     }
321     public static boolean isTargetHRLocationApprover(){
322     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.HR_LOCATION_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
323     }
324 
325     public static boolean isUserHRLocationApprover(){
326     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.HR_LOCATION_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
327     }
328 
329     public static boolean isUserOrTargetAcademicHRLocationApprover(){
330     	return isUserAcademicHRLocationApprover() || isTargetAcademicHRLocationApprover();
331     }
332     public static boolean isTargetAcademicHRLocationApprover(){
333     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.ACADEMIC_HR_LOCATION_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
334     }
335 
336     public static boolean isUserAcademicHRLocationApprover(){
337     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.ACADEMIC_HR_LOCATION_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
338     }
339 
340     public static boolean isUserOrTargetFiscalLocationApprover(){
341     	return isUserFiscalLocationApprover() || isTargetFiscalLocationApprover();
342     }
343     public static boolean isTargetFiscalLocationApprover(){
344     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.FISCAL_LOCATION_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
345     }
346 
347     public static boolean isUserFiscalLocationApprover(){
348     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.FISCAL_LOCATION_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
349     }
350 
351     public static boolean isUserOrTargetHROrgApprover(){
352     	return isUserHROrgApprover() || isTargetHROrgApprover();
353     }
354     public static boolean isTargetHROrgApprover(){
355     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.HR_ORG_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
356     }
357 
358     public static boolean isUserHROrgApprover(){
359     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.HR_ORG_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
360     }
361 
362     public static boolean isUserOrTargetFiscalOrgApprover(){
363     	return isUserFiscalOrgApprover() || isTargetFiscalOrgApprover();
364     }
365     public static boolean isTargetFiscalOrgApprover(){
366     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.FISCAL_ORG_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
367     }
368 
369     public static boolean isUserFiscalOrgApprover(){
370     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.FISCAL_ORG_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
371     }
372 
373     public static boolean isUserOrTargetDepartmentApprover(){
374     	return isUserDepartmentApprover() || isTargetDepartmentApprover();
375     }
376     public static boolean isTargetDepartmentApprover(){
377     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.DEPARTMENT_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
378     }
379 
380     public static boolean isUserDepartmentApprover(){
381     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.DEPARTMENT_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
382     }
383 
384     public static boolean isUserOrTargetFiscalDepartmentApprover(){
385     	return isUserFiscalDepartmentApprover() || isTargetFiscalDepartmentApprover();
386     }
387     public static boolean isTargetFiscalDepartmentApprover(){
388     	return HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.FISCAL_DEPARTMENT_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
389     }
390 
391     public static boolean isUserFiscalDepartmentApprover(){
392     	return HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.FISCAL_DEPARTMENT_APPROVER.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay());
393     }
394     public static boolean isUserOrTargetPositionSystemViewOnly(){
395 
396         if (HrServiceLocator.getKPMERoleService().principalHasRole(getPrincipalId(), KPMENamespace.KPME_PM.getNamespaceCode(), KPMERole.POSITION_SYSTEM_VIEW_ONLY.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay()))
397         {
398             return true;
399         }
400 
401         if (HrServiceLocator.getKPMERoleService().principalHasRole(getTargetPrincipalId(), KPMENamespace.KPME_PM.getNamespaceCode(), KPMERole.POSITION_SYSTEM_VIEW_ONLY.getRoleName(), LocalDate.now().toDateTimeAtStartOfDay()))
402         {
403             return true;
404         }
405 
406         return false;
407     }
408 
409     public static boolean isPositionModuleEnabled() {
410     	String status = ConfigContext.getCurrentContextConfig().getProperty("kpme.pm.module.status");
411     	if(StringUtils.equals(status, "On")) {
412     		return true;
413     	} else {
414     		return false;
415     	}
416     }
417 }