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.text.DateFormat;
19
20 import org.joda.time.DateTime;
21 import org.kuali.hr.time.calendar.CalendarEntries;
22 import org.kuali.hr.time.service.base.TkServiceLocator;
23 import org.quartz.Job;
24 import org.quartz.JobDataMap;
25 import org.quartz.JobExecutionContext;
26 import org.quartz.JobExecutionException;
27
28 public class EndReportingPeriodJob implements Job {
29
30 public void execute(JobExecutionContext context) throws JobExecutionException {
31 JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
32
33 String hrCalendarEntriesId = jobDataMap.getString("hrCalendarEntriesId");
34 String principalId = jobDataMap.getString("principalId");
35
36 CalendarEntries calendarEntry = TkServiceLocator.getCalendarEntriesService().getCalendarEntries(hrCalendarEntriesId);
37 DateTime endPeriodDateTime = new DateTime(calendarEntry.getEndPeriodDateTime());
38
39 String subject = "End of Reporting Period Reminder";
40 StringBuilder message = new StringBuilder();
41 message.append("Please submit your Leave Calendar for the period ending on ");
42 message.append(DateFormat.getDateInstance(DateFormat.LONG).format(endPeriodDateTime.minusDays(1).toDate()));
43 message.append(", so it can be reviewed and approved by your supervisor.");
44
45 TkServiceLocator.getKPMENotificationService().sendNotification(subject, message.toString(), principalId);
46 }
47
48 }