1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.time.batch;
17
18 import java.text.DateFormat;
19
20 import org.joda.time.DateTime;
21 import org.kuali.kpme.core.batch.BatchJob;
22 import org.kuali.kpme.core.calendar.entry.CalendarEntry;
23 import org.kuali.kpme.core.service.HrServiceLocator;
24 import org.quartz.Job;
25 import org.quartz.JobDataMap;
26 import org.quartz.JobExecutionContext;
27 import org.quartz.JobExecutionException;
28
29 public class EndReportingPeriodJob extends BatchJob {
30
31 public void execute(JobExecutionContext context) throws JobExecutionException {
32 JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
33
34 String hrCalendarEntryId = jobDataMap.getString("hrCalendarEntryId");
35 String principalId = jobDataMap.getString("principalId");
36
37 CalendarEntry calendarEntry = HrServiceLocator.getCalendarEntryService().getCalendarEntry(hrCalendarEntryId);
38 DateTime endPeriodDateTime = calendarEntry.getEndPeriodFullDateTime();
39
40 String subject = "End of Reporting Period Reminder";
41 StringBuilder message = new StringBuilder();
42 message.append("Please submit your Leave Calendar for the period ending on ");
43 message.append(DateFormat.getDateInstance(DateFormat.LONG).format(endPeriodDateTime.minusDays(1).toDate()));
44 message.append(", so it can be reviewed and approved by your supervisor.");
45
46 HrServiceLocator.getKPMENotificationService().sendNotification(subject, message.toString(), principalId);
47 }
48
49 }