1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.batch;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.hr.time.calendar.Calendar;
20 import org.kuali.hr.time.calendar.CalendarEntries;
21 import org.kuali.hr.time.service.base.TkServiceLocator;
22 import org.kuali.rice.kew.api.exception.WorkflowException;
23 import org.quartz.Job;
24 import org.quartz.JobDataMap;
25 import org.quartz.JobExecutionContext;
26 import org.quartz.JobExecutionException;
27
28 public class InitiateJob implements Job {
29
30 public void execute(JobExecutionContext context) throws JobExecutionException {
31 JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
32
33 String hrCalendarEntriesId = jobDataMap.getString("hrCalendarEntriesId");
34 String principalId = jobDataMap.getString("principalId");
35
36 CalendarEntries calendarEntry = TkServiceLocator.getCalendarEntriesService().getCalendarEntries(hrCalendarEntriesId);
37 Calendar calendar = TkServiceLocator.getCalendarService().getCalendar(calendarEntry.getHrCalendarId());
38
39 try {
40 if (StringUtils.equals(calendar.getCalendarTypes(), "Pay")) {
41 TkServiceLocator.getTimesheetService().openTimesheetDocument(principalId, calendarEntry);
42 } else if (StringUtils.equals(calendar.getCalendarTypes(), "Leave")) {
43 TkServiceLocator.getLeaveCalendarService().openLeaveCalendarDocument(principalId, calendarEntry);
44 }
45 } catch (WorkflowException we) {
46 throw new JobExecutionException("Failure to execute job due to WorkflowException", we);
47 }
48 }
49
50 }