View Javadoc

1   /**
2    * Copyright 2004-2013 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.hr.time.service.base;
17  
18  import org.kuali.hr.earncodesec.service.EarnCodeSecurityService;
19  import org.kuali.hr.job.service.JobService;
20  import org.kuali.hr.location.service.LocationService;
21  import org.kuali.hr.paygrade.service.PayGradeService;
22  import org.kuali.hr.time.accrual.service.AccrualCategoryService;
23  import org.kuali.hr.time.accrual.service.TimeOffAccrualService;
24  import org.kuali.hr.time.approval.service.TimeApproveService;
25  import org.kuali.hr.time.assignment.dao.AssignmentDao;
26  import org.kuali.hr.time.assignment.service.AssignmentService;
27  import org.kuali.hr.time.batch.service.BatchJobEntryService;
28  import org.kuali.hr.time.batch.service.BatchJobService;
29  import org.kuali.hr.time.calendar.service.CalendarEntriesService;
30  import org.kuali.hr.time.calendar.service.CalendarService;
31  import org.kuali.hr.time.clock.location.service.ClockLocationRuleService;
32  import org.kuali.hr.time.clocklog.service.ClockLogService;
33  import org.kuali.hr.time.department.service.DepartmentService;
34  import org.kuali.hr.time.dept.lunch.service.DepartmentLunchRuleService;
35  import org.kuali.hr.time.docsearch.TkSearchableAttributeService;
36  import org.kuali.hr.time.earncode.service.EarnCodeService;
37  import org.kuali.hr.time.earngroup.service.EarnGroupService;
38  import org.kuali.hr.time.graceperiod.service.GracePeriodService;
39  import org.kuali.hr.time.holidaycalendar.service.HolidayCalendarService;
40  import org.kuali.hr.time.missedpunch.service.MissedPunchService;
41  import org.kuali.hr.time.overtime.daily.rule.service.DailyOvertimeRuleService;
42  import org.kuali.hr.time.overtime.weekly.rule.service.WeeklyOvertimeRuleService;
43  import org.kuali.hr.time.paytype.service.PayTypeService;
44  import org.kuali.hr.time.permissions.TkPermissionsService;
45  import org.kuali.hr.time.person.service.PersonService;
46  import org.kuali.hr.time.position.service.PositionService;
47  import org.kuali.hr.time.principal.service.PrincipalHRAttributesService;
48  import org.kuali.hr.time.roles.service.TkRoleGroupService;
49  import org.kuali.hr.time.roles.service.TkRoleService;
50  import org.kuali.hr.time.rule.TkRuleControllerService;
51  import org.kuali.hr.time.salgroup.service.SalGroupService;
52  import org.kuali.hr.time.shiftdiff.rule.service.ShiftDifferentialRuleService;
53  import org.kuali.hr.time.syslunch.service.SystemLunchRuleService;
54  import org.kuali.hr.time.task.service.TaskService;
55  import org.kuali.hr.time.timeblock.service.TimeBlockHistoryDetailService;
56  import org.kuali.hr.time.timeblock.service.TimeBlockHistoryService;
57  import org.kuali.hr.time.timeblock.service.TimeBlockService;
58  import org.kuali.hr.time.timecollection.rule.service.TimeCollectionRuleService;
59  import org.kuali.hr.time.timehourdetail.service.TimeHourDetailService;
60  import org.kuali.hr.time.timesheet.service.TimesheetService;
61  import org.kuali.hr.time.timesummary.service.TimeSummaryService;
62  import org.kuali.hr.time.timezone.service.TimezoneService;
63  import org.kuali.hr.time.user.pref.service.UserPreferenceService;
64  import org.kuali.hr.time.warning.TkWarningService;
65  import org.kuali.hr.time.workarea.service.WorkAreaService;
66  import org.kuali.hr.time.workflow.service.TimesheetDocumentHeaderService;
67  import org.kuali.rice.core.impl.cache.DistributedCacheManagerDecorator;
68  import org.springframework.beans.BeansException;
69  import org.springframework.context.ApplicationContext;
70  import org.springframework.context.ApplicationContextAware;
71  import org.springframework.jdbc.core.JdbcTemplate;
72  import org.springframework.transaction.PlatformTransactionManager;
73  import org.springframework.transaction.support.TransactionTemplate;
74  import org.springmodules.orm.ojb.PersistenceBrokerTemplate;
75  
76  public class TkServiceLocator implements ApplicationContextAware {
77  	public static String SPRING_BEANS = "classpath:SpringBeans.xml";
78  	public static ApplicationContext CONTEXT;
79  	public static final String TK_PERMISSIONS_SERVICE = "permissionsService";
80  	public static final String TK_CLOCK_LOG_SERVICE = "clockLogService";
81  	public static final String TK_ASSIGNMENT_SERVICE = "assignmentService";
82  	public static final String TK_ASSIGNMENT_DAO     = "assignmentDao";
83  	public static final String TK_TIME_BLOCK_SERVICE = "timeBlockService";
84  	public static final String TK_TIME_BLOCK_HISTORY_SERVICE = "timeBlockHistoryService";
85  	public static final String TK_TIME_BLOCK_HISTORY_DETAIL_SERVICE = "timeBlockHistoryDetailService";
86  	public static final String TK_JOB_SERVICE = "jobService";
87  	public static final String TK_PAY_TYPE_SERVICE = "payTypeService";
88  	public static final String TK_PAY_CALENDAR_SERVICE = "calendarService";
89  	public static final String TK_PAY_CALENDAR_ENTRIES_SERVICE = "calendarEntriesService";
90  	public static final String TK_PERSISTENCE_BROKER_TEMPLATE = "tkPersistenceBrokerTemplate";
91  	public static final String TK_CACHE_MANAGER_SERVICE = "cacheManager";
92  	public static final String TK_WORK_AREA_SERVICE = "workAreaService";
93  	public static final String TK_TIMESHEET_SERVICE = "timesheetService";
94  	public static final String TK_TIMESHEET_DOCUMENT_HEADER_SERVICE = "timesheetDocumentHeaderService";
95  	public static final String TK_DEPARTMENT_SERVICE = "departmentService";
96  	public static final String TK_EARN_CODE_SECURITY = "earnCodeSecurityService";
97  	public static final String TK_EARN_CODE = "earnCodeService";
98  	public static final String TK_TIME_COLLECTION_RULE_SERVICE = "timeCollectionRuleService";
99  	public static final String TK_ROLE_SERVICE = "tkRoleService";
100 	public static final String TK_ROLE_GROUP_SERVICE = "tkRoleGroupService";
101 	public static final String TK_TIME_SUMMARY_SERVICE = "timeSummaryService";
102 	public static final String TK_TIME_EARN_CODE_GROUP_SERVICE = "earnGroupService";
103 	public static final String TK_TIME_HOUR_DETAIL_SERVICE= "timeHourDetailService";
104 	public static final String TK_DAILY_OVERTIME_RULE_SERVICE = "dailyOvertimeRuleService";
105 	public static final String TK_WEEKLY_OVERTIME_RULE_SERVICE = "weeklyOvertimeRuleService";
106 	public static final String TK_SHIFT_DIFFERENTIAL_RULE_SERVICE = "shiftDifferentialRuleService";
107 	public static final String TK_WORK_SCHEDULE_SERVICE = "workScheduleService";
108     public static final String TK_WORK_SCHEDULE_ASSIGNMENT_SERVICE = "workScheduleAssignmentService";
109 	public static final String TK_CLOCK_LOCATION_RULE_SERVICE = "clockLocationService";
110 	public static final String TK_GRACE_PERIOD_SERVICE = "gracePeriodService";
111 	public static final String TK_SYSTEM_LUNCH_RULE_SERVICE = "systemLunchRuleService";
112 	public static final String TK_DEPT_LUNCH_RULE_SERVICE = "deptLunchRuleService";
113 	public static final String TK_HOLIDAY_CALENDAR_SERVICE = "holidayCalendarService";
114 	public static final String TK_USER_PREF_SERVICE = "userPrefService";
115 	public static final String TK_TIME_ZONE_SERVICE = "timezoneService";
116 	public static final String TK_TIME_OFF_ACCRUAL_SERVICE = "timeOffAccrualService";
117 	public static final String hr_sal_group_SERVICE = "salGroupService";
118 	public static final String TK_ACCRUAL_CATEGORY_SERVICE = "accrualCategoryService";
119 	public static final String TK_ACCRUAL_CATEGORY_RULE_SERVICE = "accrualCategoryRuleService";
120     public static final String TK_TASK_SERVICE = "taskService";
121     public static final String TK_LOCATION_SERVICE = "locationService";
122     public static final String TK_PAY_GRADE_SERVICE = "payGradeService";
123     public static final String TK_PERSON_SERVICE = "tkPersonService";
124     public static final String TK_APPROVE_SERVICE = "timeApproveService";
125     public static final String TK_BATCH_JOB_SERVICE = "batchJobService";
126     public static final String TK_MISSED_PUNCH_SERVICE = "missedPunchService";
127     public static final String TK_BATCH_JOB_ENTRY_SERVICE = "batchJobEntryService";
128     public static final String TK_WARNINGS_SERVICE = "tkWarningService";
129     public static final String HR_POSITION_SERVICE = "positionService";
130     public static final String TK_SEARCH_ATTR_SERVICE = "tkSearchableAttributeService";
131     public static final String TK_PRINCIPAL_HR_ATTRIBUTES_SERVICE = "principalHRAttributesService";
132     public static final String KPME_DISTRIBUTED_CACHE_MANAGER = "kpmeDistributedCacheManager";
133     
134     public static MissedPunchService getMissedPunchService() {
135         return (MissedPunchService) CONTEXT.getBean(TK_MISSED_PUNCH_SERVICE);
136     }
137 
138     public static TaskService getTaskService() {
139         return (TaskService) CONTEXT.getBean(TK_TASK_SERVICE);
140     }
141 
142 	public static SalGroupService getSalGroupService() {
143 		return (SalGroupService) CONTEXT.getBean(hr_sal_group_SERVICE);
144 	}
145 
146 	public static DepartmentService getDepartmentService() {
147 		return (DepartmentService) CONTEXT.getBean(TK_DEPARTMENT_SERVICE);
148 	}
149 
150 	public static ShiftDifferentialRuleService getShiftDifferentialRuleService() {
151 		return (ShiftDifferentialRuleService) CONTEXT.getBean(TK_SHIFT_DIFFERENTIAL_RULE_SERVICE);
152 	}
153 
154 	public static WeeklyOvertimeRuleService getWeeklyOvertimeRuleService() {
155 		return (WeeklyOvertimeRuleService) CONTEXT.getBean(TK_WEEKLY_OVERTIME_RULE_SERVICE);
156 	}
157 
158 	public static DailyOvertimeRuleService getDailyOvertimeRuleService() {
159 		return (DailyOvertimeRuleService) CONTEXT.getBean(TK_DAILY_OVERTIME_RULE_SERVICE);
160 	}
161 
162 	public static TkRoleService getTkRoleService() {
163 		return (TkRoleService) CONTEXT.getBean(TK_ROLE_SERVICE);
164 	}
165 
166 	public static TkRoleGroupService getTkRoleGroupService() {
167 		return (TkRoleGroupService) CONTEXT.getBean(TK_ROLE_GROUP_SERVICE);
168 	}
169 	
170 	public static TimesheetDocumentHeaderService getTimesheetDocumentHeaderService() {
171 		return (TimesheetDocumentHeaderService) CONTEXT.getBean(TK_TIMESHEET_DOCUMENT_HEADER_SERVICE);
172 	}
173 
174 	public static TimesheetService getTimesheetService() {
175 		return (TimesheetService) CONTEXT.getBean(TK_TIMESHEET_SERVICE);
176 	}
177 
178 	public static WorkAreaService getWorkAreaService() {
179 	    return (WorkAreaService)CONTEXT.getBean(TK_WORK_AREA_SERVICE);
180 	}
181 
182 	public static ClockLogService getClockLogService(){
183 	    return (ClockLogService)CONTEXT.getBean(TK_CLOCK_LOG_SERVICE);
184 	}
185 	
186 	public static TkPermissionsService getPermissionsService(){
187 	    return (TkPermissionsService)CONTEXT.getBean(TK_PERMISSIONS_SERVICE);
188 	}
189 
190     public static DistributedCacheManagerDecorator getDistributedCacheManager() {
191         return (DistributedCacheManagerDecorator)CONTEXT.getBean(KPME_DISTRIBUTED_CACHE_MANAGER);
192     }
193 
194 
195 
196 
197 	public static AssignmentService getAssignmentService(){
198 	    return (AssignmentService)CONTEXT.getBean(TK_ASSIGNMENT_SERVICE);
199 	}
200 
201 	public static TimeBlockService getTimeBlockService(){
202 		return (TimeBlockService)CONTEXT.getBean(TK_TIME_BLOCK_SERVICE);
203 	}
204 
205 	public static TimeBlockHistoryService getTimeBlockHistoryService(){
206 		return (TimeBlockHistoryService)CONTEXT.getBean(TK_TIME_BLOCK_HISTORY_SERVICE);
207 	}
208 	
209 	public static TimeBlockHistoryDetailService getTimeBlockHistoryDetailService(){
210 		return (TimeBlockHistoryDetailService)CONTEXT.getBean(TK_TIME_BLOCK_HISTORY_DETAIL_SERVICE);
211 	}
212 
213 	public static AssignmentDao getAssignmentDao() {
214 	    return (AssignmentDao)CONTEXT.getBean(TK_ASSIGNMENT_DAO);
215 	}
216 
217 	public static JobService getJobService() {
218 		return (JobService)CONTEXT.getBean(TK_JOB_SERVICE);
219 	}
220 
221 	public static PayTypeService getPayTypeService() {
222 		return (PayTypeService)CONTEXT.getBean(TK_PAY_TYPE_SERVICE);
223 	}
224 
225 	public static PersistenceBrokerTemplate getTkPersistenceBrokerTemplate() {
226 	    return (PersistenceBrokerTemplate) CONTEXT.getBean(TK_PERSISTENCE_BROKER_TEMPLATE);
227 	}
228 
229 	public static TkRuleControllerService getTkRuleControllerService(){
230 		return (TkRuleControllerService) CONTEXT.getBean("tkRuleControllerService");
231 	}
232 
233 	public static EarnCodeService getEarnCodeService() {
234 		return (EarnCodeService) CONTEXT.getBean(TK_EARN_CODE);
235 	}
236 
237 	public static TimeCollectionRuleService getTimeCollectionRuleService() {
238 		return (TimeCollectionRuleService) CONTEXT.getBean(TK_TIME_COLLECTION_RULE_SERVICE);
239 	}
240 
241 	public static TimeSummaryService getTimeSummaryService(){
242 		return (TimeSummaryService) CONTEXT.getBean(TK_TIME_SUMMARY_SERVICE);
243 	}
244 
245 	public static EarnGroupService getEarnGroupService(){
246 		return (EarnGroupService) CONTEXT.getBean(TK_TIME_EARN_CODE_GROUP_SERVICE);
247 	}
248 
249 	public static TimeHourDetailService getTimeHourDetailService(){
250 		return (TimeHourDetailService) CONTEXT.getBean(TK_TIME_HOUR_DETAIL_SERVICE);
251 	}
252 
253 	public static ClockLocationRuleService getClockLocationRuleService(){
254 		return (ClockLocationRuleService) CONTEXT.getBean(TK_CLOCK_LOCATION_RULE_SERVICE);
255 	}
256 
257 	public static GracePeriodService getGracePeriodService(){
258 		return (GracePeriodService) CONTEXT.getBean(TK_GRACE_PERIOD_SERVICE);
259 	}
260 
261 	public static SystemLunchRuleService getSystemLunchRuleService(){
262 		return (SystemLunchRuleService) CONTEXT.getBean(TK_SYSTEM_LUNCH_RULE_SERVICE);
263 	}
264 
265 	public static DepartmentLunchRuleService getDepartmentLunchRuleService(){
266 		return (DepartmentLunchRuleService) CONTEXT.getBean(TK_DEPT_LUNCH_RULE_SERVICE);
267 	}
268 
269 	public static HolidayCalendarService getHolidayCalendarService(){
270 		return (HolidayCalendarService) CONTEXT.getBean(TK_HOLIDAY_CALENDAR_SERVICE);
271 	}
272 
273 	public static UserPreferenceService getUserPreferenceService(){
274 		return (UserPreferenceService) CONTEXT.getBean(TK_USER_PREF_SERVICE);
275 	}
276 
277 	public static TimezoneService getTimezoneService(){
278 		return (TimezoneService) CONTEXT.getBean(TK_TIME_ZONE_SERVICE);
279 	}
280 
281 	public static TimeOffAccrualService getTimeOffAccrualService(){
282 		return (TimeOffAccrualService) CONTEXT.getBean(TK_TIME_OFF_ACCRUAL_SERVICE);
283 	}
284 
285 	public static AccrualCategoryService getAccrualCategoryService() {
286 	    return (AccrualCategoryService)CONTEXT.getBean(TK_ACCRUAL_CATEGORY_SERVICE);
287 	}
288 	
289 	public static LocationService getLocationService() {
290 	    return (LocationService)CONTEXT.getBean(TK_LOCATION_SERVICE);
291 	}
292 
293 	public static PayGradeService getPayGradeService() {
294 	    return (PayGradeService)CONTEXT.getBean(TK_PAY_GRADE_SERVICE);
295 	}
296 
297 	public static PersonService getPersonService(){
298 		return (PersonService)CONTEXT.getBean(TK_PERSON_SERVICE);
299 	}
300 	public static TimeApproveService getTimeApproveService(){
301 		return (TimeApproveService)CONTEXT.getBean(TK_APPROVE_SERVICE);
302 	}
303 
304 	public static BatchJobService getBatchJobService(){
305 		return (BatchJobService)CONTEXT.getBean(TK_BATCH_JOB_SERVICE);
306 	}
307 
308 	public static BatchJobEntryService getBatchJobEntryService(){
309 		return (BatchJobEntryService)CONTEXT.getBean(TK_BATCH_JOB_ENTRY_SERVICE);
310 	}
311 
312 	public static TkWarningService getWarningService(){
313 		return (TkWarningService) CONTEXT.getBean(TK_WARNINGS_SERVICE);
314 	}
315 	
316 	public static PositionService getPositionService(){
317 		return (PositionService) CONTEXT.getBean(HR_POSITION_SERVICE);
318 	}
319 	
320 	public static TkSearchableAttributeService getTkSearchableAttributeService(){
321 		return (TkSearchableAttributeService) CONTEXT.getBean(TK_SEARCH_ATTR_SERVICE);
322 	}
323 
324 	public static PlatformTransactionManager getPlatformTransactionManager() {
325 		return (PlatformTransactionManager)CONTEXT.getBean("transactionManager");
326 	}
327 
328 	public static TransactionTemplate getTransactionTemplate() {
329 		return new TransactionTemplate(getPlatformTransactionManager());
330 	}
331 	
332     public static PrincipalHRAttributesService getPrincipalHRAttributeService(){
333     	return (PrincipalHRAttributesService)CONTEXT.getBean(TK_PRINCIPAL_HR_ATTRIBUTES_SERVICE);
334     }
335     
336 	public static CalendarService getCalendarService() {
337 		return (CalendarService)CONTEXT.getBean(TK_PAY_CALENDAR_SERVICE);
338 	}
339 	
340 	public static CalendarEntriesService getCalendarEntriesService() {
341 		return (CalendarEntriesService)CONTEXT.getBean(TK_PAY_CALENDAR_ENTRIES_SERVICE);
342 	}
343 
344     public static EarnCodeSecurityService getEarnCodeSecurityService() {
345         return (EarnCodeSecurityService) CONTEXT.getBean(TK_EARN_CODE_SECURITY);
346     }
347 	
348 	@Override
349 	public void setApplicationContext(ApplicationContext arg0) throws BeansException {
350 	    CONTEXT = arg0;
351 	}
352 	
353 
354     /**
355      * This is for the approval only
356      */
357     public static JdbcTemplate getTkJdbcTemplate() {
358 		return (JdbcTemplate) CONTEXT.getBean("tkJdbcTemplate");
359 	}
360     
361     public static JdbcTemplate getRiceJdbcTemplate() {
362 		return (JdbcTemplate) CONTEXT.getBean("riceJdbcTemplate");
363 	}
364 }