View Javadoc

1   /**
2    * Copyright 2004-2012 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 org.apache.commons.lang.StringUtils;
19  import org.apache.log4j.Logger;
20  import org.kuali.hr.time.calendar.CalendarEntries;
21  import org.kuali.hr.time.clocklog.ClockLog;
22  import org.kuali.hr.time.service.base.TkServiceLocator;
23  import org.kuali.hr.time.util.TkConstants;
24  
25  import java.util.List;
26  
27  public class PayPeriodEndBatchJob extends BatchJob {
28      private Logger LOG = Logger.getLogger(PayPeriodEndBatchJob.class);
29  
30  
31      public PayPeriodEndBatchJob(String hrPyCalendarEntryId) {
32          super();
33          this.setBatchJobName(TkConstants.BATCH_JOB_NAMES.PAY_PERIOD_END);
34          this.setHrPyCalendarEntryId(hrPyCalendarEntryId);
35      }
36  
37      @Override
38      public void doWork() {
39      	CalendarEntries payCalendarEntry = TkServiceLocator.getCalendarEntriesService().getCalendarEntries(getHrPyCalendarEntryId());
40      	List<ClockLog> lstOpenClockLogs = TkServiceLocator.getClockLogService().getOpenClockLogs(payCalendarEntry);
41      	for(ClockLog cl : lstOpenClockLogs){
42      		populateBatchJobEntry(cl);
43      	}
44      	
45      }
46  
47  
48      @Override
49      protected void populateBatchJobEntry(Object o) {
50      	ClockLog cl = (ClockLog)o;
51          String ip = this.getNextIpAddressInCluster();
52          if(StringUtils.isNotBlank(ip)){
53              //insert a batch job entry here
54          	//TODO finish this
55  //            BatchJobEntry entry = this.createBatchJobEntry(this.getBatchJobName(), ip, cl.getPrincipalId(), null);
56  //            TkServiceLocator.getBatchJobEntryService().saveBatchJobEntry(entry);
57          } else {
58              LOG.info("No ip found in cluster to assign batch jobs");
59          }
60      }
61  
62  }