001 /* 002 * Copyright 2011 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.kfs.gl.batch; 017 018 import java.io.File; 019 import java.util.Comparator; 020 import java.util.Date; 021 import java.util.Map; 022 023 import org.kuali.kfs.gl.GeneralLedgerConstants; 024 import org.kuali.kfs.gl.batch.service.BatchSortService; 025 import org.kuali.kfs.gl.businessobject.OriginEntryFieldUtil; 026 import org.kuali.kfs.gl.exception.LoadException; 027 import org.kuali.kfs.gl.service.ScrubberService; 028 import org.kuali.kfs.sys.KFSKeyConstants; 029 import org.kuali.kfs.sys.KFSPropertyConstants; 030 import org.kuali.kfs.sys.batch.AbstractStep; 031 import org.kuali.rice.kns.util.GlobalVariables; 032 import org.springframework.util.StopWatch; 033 import org.kuali.kfs.gl.batch.PosterSortComparator; 034 035 /** 036 * A step to run the scrubber process. 037 */ 038 public class IcrSortStep extends AbstractStep { 039 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(IcrSortStep.class); 040 private String batchFileDirectoryName; 041 /** 042 * Runs the scrubber process. 043 * 044 * @param jobName the name of the job this step is being run as part of 045 * @param jobRunDate the time/date the job was started 046 * @return true if the job completed successfully, false if otherwise 047 * @see org.kuali.kfs.sys.batch.Step#execute(java.lang.String) 048 */ 049 public boolean execute(String jobName, Date jobRunDate) { 050 StopWatch stopWatch = new StopWatch(); 051 stopWatch.start(jobName); 052 String inputFile = batchFileDirectoryName + File.separator + GeneralLedgerConstants.BatchFileSystem.ICR_TRANSACTIONS_OUTPUT_FILE + GeneralLedgerConstants.BatchFileSystem.EXTENSION; 053 String outputFile = batchFileDirectoryName + File.separator + GeneralLedgerConstants.BatchFileSystem.ICR_POSTER_INPUT_FILE + GeneralLedgerConstants.BatchFileSystem.EXTENSION; 054 055 BatchSortUtil.sortTextFileWithFields(inputFile, outputFile, new PosterSortComparator()); 056 057 stopWatch.stop(); 058 if (LOG.isDebugEnabled()) { 059 LOG.debug("IcrSort step of " + jobName + " took " + (stopWatch.getTotalTimeSeconds() / 60.0) + " minutes to complete"); 060 } 061 return true; 062 } 063 064 public void setBatchFileDirectoryName(String batchFileDirectoryName) { 065 this.batchFileDirectoryName = batchFileDirectoryName; 066 } 067 068 }