View Javadoc

1   /**
2    * Copyright 2004-2014 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.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  }