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.batch.web;
17  
18  import java.util.Date;
19  
20  import javax.servlet.http.HttpServletRequest;
21  import javax.servlet.http.HttpServletResponse;
22  
23  import org.apache.commons.lang.StringUtils;
24  import org.apache.struts.action.ActionForm;
25  import org.apache.struts.action.ActionForward;
26  import org.apache.struts.action.ActionMapping;
27  import org.kuali.hr.time.base.web.TkAction;
28  import org.kuali.hr.time.calendar.CalendarEntries;
29  import org.kuali.hr.time.service.base.TkServiceLocator;
30  import org.kuali.hr.time.util.TkConstants;
31  
32  public class BatchJobAction extends TkAction {
33      
34      public ActionForward runBatchJob(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
35          BatchJobActionForm bjaf = (BatchJobActionForm) form;
36          String batchJobName = bjaf.getSelectedBatchJob();
37  
38          CalendarEntries calendarEntry = TkServiceLocator.getCalendarEntriesService().getCalendarEntries(bjaf.getHrPyCalendarEntryId());
39          Date scheduleDate = new Date();
40          
41          if (StringUtils.equals(batchJobName, TkConstants.BATCH_JOB_NAMES.INITIATE)) {
42          	TkServiceLocator.getBatchJobService().scheduleInitiateJobs(calendarEntry, scheduleDate);
43          }
44          
45          if (StringUtils.equals(batchJobName, TkConstants.BATCH_JOB_NAMES.END_PAY_PERIOD)) {
46          	TkServiceLocator.getBatchJobService().scheduleEndPayPeriodJobs(calendarEntry, scheduleDate);
47          }
48          
49          if (StringUtils.equals(batchJobName, TkConstants.BATCH_JOB_NAMES.END_REPORTING_PERIOD)) {
50          	TkServiceLocator.getBatchJobService().scheduleEndReportingPeriodJobs(calendarEntry, scheduleDate);
51          }
52          
53          if (StringUtils.equals(batchJobName, TkConstants.BATCH_JOB_NAMES.EMPLOYEE_APPROVAL)) {
54          	TkServiceLocator.getBatchJobService().scheduleEmployeeApprovalJobs(calendarEntry, scheduleDate);
55          }
56          
57          if (StringUtils.equals(batchJobName, TkConstants.BATCH_JOB_NAMES.MISSED_PUNCH_APPROVAL)) {
58          	TkServiceLocator.getBatchJobService().scheduleMissedPunchApprovalJobs(calendarEntry, scheduleDate);
59          }
60          
61          if (StringUtils.equals(batchJobName, TkConstants.BATCH_JOB_NAMES.SUPERVISOR_APPROVAL)) {
62          	TkServiceLocator.getBatchJobService().scheduleSupervisorApprovalJobs(calendarEntry, scheduleDate);
63          }
64          
65          return mapping.findForward("basic");
66      }
67  
68  }