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.List;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.apache.log4j.Logger;
22 import org.kuali.hr.time.calendar.CalendarEntries;
23 import org.kuali.hr.time.service.base.TkServiceLocator;
24 import org.kuali.hr.time.util.TkConstants;
25 import org.kuali.hr.time.workflow.TimesheetDocumentHeader;
26
27 public class SupervisorApprovalBatchJob extends BatchJob {
28 private Logger LOG = Logger.getLogger(PayPeriodEndBatchJob.class);
29 private CalendarEntries calendarEntry;
30
31 public SupervisorApprovalBatchJob(CalendarEntries calendarEntry) {
32 this.setBatchJobName(TkConstants.BATCH_JOB_NAMES.SUPERVISOR_APPROVAL);
33 this.setHrPyCalendarEntryId(calendarEntry.getHrCalendarEntriesId());
34 this.calendarEntry = calendarEntry;
35 }
36
37 @Override
38 public void doWork() {
39 List<TimesheetDocumentHeader> documentHeaders = TkServiceLocator.getTimesheetDocumentHeaderService().getDocumentHeaders(calendarEntry.getBatchEmployeeApprovalDate());
40 for(TimesheetDocumentHeader timesheetDocumentHeader : documentHeaders){
41 populateBatchJobEntry(timesheetDocumentHeader);
42 }
43 }
44
45
46 @Override
47 protected void populateBatchJobEntry(Object o) {
48 TimesheetDocumentHeader tdh = (TimesheetDocumentHeader)o;
49 String ip = this.getNextIpAddressInCluster();
50 if(StringUtils.isNotBlank(ip)){
51
52 BatchJobEntry entry = this.createBatchJobEntry(this.getBatchJobName(), ip, tdh.getPrincipalId(), tdh.getDocumentId(),null);
53 TkServiceLocator.getBatchJobEntryService().saveBatchJobEntry(entry);
54 } else {
55 LOG.info("No ip found in cluster to assign batch jobs");
56 }
57 }
58
59 }