1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.common;
17
18 import javax.servlet.http.HttpServletRequest;
19 import javax.servlet.http.HttpServletResponse;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.apache.struts.action.ActionForm;
23 import org.apache.struts.action.ActionForward;
24 import org.apache.struts.action.ActionMapping;
25 import org.joda.time.DateTime;
26 import org.kuali.kpme.core.api.calendar.entry.CalendarEntry;
27 import org.kuali.kpme.core.calendar.entry.CalendarEntryBo;
28 import org.kuali.kpme.core.service.HrServiceLocator;
29 import org.kuali.kpme.core.util.HrConstants;
30 import org.kuali.kpme.core.web.KPMEAction;
31 import org.kuali.kpme.tklm.time.service.TkServiceLocator;
32
33 public class BatchJobAction extends KPMEAction {
34
35 public ActionForward runBatchJob(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
36 BatchJobActionForm bjaf = (BatchJobActionForm) form;
37 String batchJobName = bjaf.getSelectedBatchJob();
38
39 CalendarEntry calendarEntry = HrServiceLocator.getCalendarEntryService().getCalendarEntry(bjaf.getHrPyCalendarEntryId());
40 DateTime scheduleDate = new DateTime();
41 if(calendarEntry != null) {
42
43
44 if (StringUtils.equals(batchJobName, HrConstants.BATCH_JOB_NAMES.INITIATE)) {
45 TkServiceLocator.getBatchJobService().scheduleInitiateJobs(calendarEntry, scheduleDate);
46 }
47
48 if (StringUtils.equals(batchJobName, HrConstants.BATCH_JOB_NAMES.END_PAY_PERIOD)) {
49 TkServiceLocator.getBatchJobService().scheduleEndPayPeriodJobs(calendarEntry, scheduleDate);
50 }
51
52 if (StringUtils.equals(batchJobName, HrConstants.BATCH_JOB_NAMES.END_REPORTING_PERIOD)) {
53 TkServiceLocator.getBatchJobService().scheduleEndReportingPeriodJobs(calendarEntry, scheduleDate);
54 }
55
56 if (StringUtils.equals(batchJobName, HrConstants.BATCH_JOB_NAMES.EMPLOYEE_APPROVAL)) {
57 TkServiceLocator.getBatchJobService().scheduleEmployeeApprovalJobs(calendarEntry, scheduleDate);
58 }
59
60 if (StringUtils.equals(batchJobName, HrConstants.BATCH_JOB_NAMES.MISSED_PUNCH_APPROVAL)) {
61 TkServiceLocator.getBatchJobService().scheduleMissedPunchApprovalJobs(calendarEntry, scheduleDate);
62 }
63
64 if (StringUtils.equals(batchJobName, HrConstants.BATCH_JOB_NAMES.SUPERVISOR_APPROVAL)) {
65 TkServiceLocator.getBatchJobService().scheduleSupervisorApprovalJobs(calendarEntry, scheduleDate);
66 }
67
68 if (StringUtils.equals(batchJobName, HrConstants.BATCH_JOB_NAMES.PAYROLL_APPROVAL)) {
69 TkServiceLocator.getBatchJobService().schedulePayrollApprovalJobs(calendarEntry, scheduleDate);
70 }
71
72 if (StringUtils.equals(batchJobName, HrConstants.BATCH_JOB_NAMES.LEAVE_CALENDAR_DELINQUENCY)) {
73 TkServiceLocator.getBatchJobService().scheduleLeaveCalendarDelinquencyJobs(calendarEntry,scheduleDate);
74 }
75
76
77 } else {
78
79 if (StringUtils.equals(batchJobName, HrConstants.BATCH_JOB_NAMES.CLOCKED_IN_EMPLOYEE)) {
80 TkServiceLocator.getBatchJobService().scheduleClockedInEmployeeJob(scheduleDate);
81 }
82 }
83 bjaf.setMessage("Batch job ran sucessfully.");
84 return mapping.findForward("basic");
85 }
86
87 }