001 /**
002 * Copyright 2004-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.hr.time.batch;
017
018 import org.apache.commons.lang.StringUtils;
019 import org.apache.log4j.Logger;
020 import org.kuali.hr.time.calendar.CalendarEntries;
021 import org.kuali.hr.time.clocklog.ClockLog;
022 import org.kuali.hr.time.service.base.TkServiceLocator;
023 import org.kuali.hr.time.util.TkConstants;
024
025 import java.util.List;
026
027 public class PayPeriodEndBatchJob extends BatchJob {
028 private Logger LOG = Logger.getLogger(PayPeriodEndBatchJob.class);
029 private CalendarEntries calendarEntry;
030
031 public PayPeriodEndBatchJob(CalendarEntries calendarEntry) {
032 this.setBatchJobName(TkConstants.BATCH_JOB_NAMES.PAY_PERIOD_END);
033 this.setHrPyCalendarEntryId(calendarEntry.getHrCalendarEntriesId());
034 this.calendarEntry = calendarEntry;
035 }
036
037 @Override
038 public void doWork() {
039 List<ClockLog> lstOpenClockLogs = TkServiceLocator.getClockLogService().getOpenClockLogs(calendarEntry);
040 for(ClockLog cl : lstOpenClockLogs){
041 populateBatchJobEntry(cl);
042 }
043
044 }
045
046
047 @Override
048 protected void populateBatchJobEntry(Object o) {
049 ClockLog cl = (ClockLog)o;
050 String ip = this.getNextIpAddressInCluster();
051 if(StringUtils.isNotBlank(ip)){
052 //insert a batch job entry here
053 //TODO finish this
054 // BatchJobEntry entry = this.createBatchJobEntry(this.getBatchJobName(), ip, cl.getPrincipalId(), null);
055 // TkServiceLocator.getBatchJobEntryService().saveBatchJobEntry(entry);
056 } else {
057 LOG.info("No ip found in cluster to assign batch jobs");
058 }
059 }
060
061 }