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.util.List;
19  
20  import org.kuali.hr.time.missedpunch.MissedPunchDocument;
21  import org.kuali.hr.time.service.base.TkServiceLocator;
22  
23  public class BatchApproveMissedPunchJobRunnable extends BatchJobEntryRunnable {
24  
25  	public BatchApproveMissedPunchJobRunnable(BatchJobEntry entry) {
26          super(entry);
27      }
28  
29  	@Override
30  	public void doWork() throws Exception {
31  		String clockLogId = batchJobEntry.getClockLogId();
32  		if(clockLogId != null) {	// if clock log id is provided, just approve the specified missed punch document
33  			MissedPunchDocument document = TkServiceLocator.getMissedPunchService().getMissedPunchByClockLogId(clockLogId);
34  			if(document != null) {
35  				TkServiceLocator.getMissedPunchService().approveMissedPunch(document);
36  			}
37  		} else if( batchJobEntry.getDocumentId() != null) {
38  			MissedPunchDocument document = TkServiceLocator.getMissedPunchService().getMissedPunchByRouteHeader(batchJobEntry.getDocumentId());
39  			if(document != null) {
40  				TkServiceLocator.getMissedPunchService().approveMissedPunch(document);
41  			}
42  		} else { // if batch job does not have clock log id, approve all enrouted missed punch docs for the given pay period
43  			List<MissedPunchDocument> docList = TkServiceLocator.getMissedPunchService().getMissedPunchDocsByBatchJobEntry(batchJobEntry);
44  			for(MissedPunchDocument aDoc : docList) {
45  				TkServiceLocator.getMissedPunchService().approveMissedPunch(aDoc);
46  			}
47  		}
48  		
49  	}
50  }