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;
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  }