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 java.util.Date;
19 import java.util.List;
20
21 import org.kuali.hr.time.batch.service.BatchJobService;
22 import org.kuali.hr.time.calendar.CalendarEntries;
23 import org.kuali.hr.time.service.base.TkServiceLocator;
24 import org.kuali.hr.time.util.TKUtils;
25 import org.quartz.JobExecutionContext;
26 import org.quartz.JobExecutionException;
27 import org.quartz.SchedulerException;
28 import org.springframework.scheduling.quartz.QuartzJobBean;
29
30 public class CalendarEntrySchedulerJob extends QuartzJobBean {
31
32 private static int CALENDAR_ENTRIES_POLLING_WINDOW;
33
34 private static BatchJobService batchJobService;
35
36 @Override
37 protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
38 Date asOfDate = TKUtils.getCurrentDate();
39 List<CalendarEntries> calendarEntries = TkServiceLocator.getCalendarEntriesService().getCurrentCalendarEntryNeedsScheduled(getCalendarEntriesPollingWindow(), asOfDate);
40
41 try {
42 for (CalendarEntries calendarEntry : calendarEntries) {
43 if (calendarEntry.getEndPeriodDateTime() != null) {
44 getBatchJobService().scheduleEndReportingPeriodJobs(calendarEntry);
45 }
46
47 if (calendarEntry.getBatchInitiateDateTime() != null) {
48 getBatchJobService().scheduleInitiateJobs(calendarEntry);
49 }
50
51 if (calendarEntry.getBatchEndPayPeriodDateTime() != null) {
52 getBatchJobService().scheduleEndPayPeriodJobs(calendarEntry);
53 }
54
55 if (calendarEntry.getBatchEmployeeApprovalDateTime() != null) {
56 getBatchJobService().scheduleEmployeeApprovalJobs(calendarEntry);
57 }
58
59 if (calendarEntry.getBatchSupervisorApprovalDateTime() != null) {
60 getBatchJobService().scheduleMissedPunchApprovalJobs(calendarEntry);
61 }
62
63 if (calendarEntry.getBatchSupervisorApprovalDateTime() != null) {
64 getBatchJobService().scheduleSupervisorApprovalJobs(calendarEntry);
65 }
66 }
67 } catch (SchedulerException se) {
68 throw new JobExecutionException("Exception thrown during job scheduling", se);
69 }
70 }
71
72 public int getCalendarEntriesPollingWindow() {
73 return CALENDAR_ENTRIES_POLLING_WINDOW;
74 }
75
76 public void setCalendarEntriesPollingWindow(int calendarEntriesPollingWindow) {
77 CALENDAR_ENTRIES_POLLING_WINDOW = calendarEntriesPollingWindow;
78 }
79
80 public static BatchJobService getBatchJobService() {
81 return CalendarEntrySchedulerJob.batchJobService;
82 }
83
84 public void setBatchJobService(BatchJobService batchJobService) {
85 CalendarEntrySchedulerJob.batchJobService = batchJobService;
86 }
87
88 }