View Javadoc
1   /*
2    * Copyright 2005-2009 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.ole.gl.batch;
17  
18  import java.io.File;
19  import java.util.Date;
20  
21  import org.kuali.ole.gl.GeneralLedgerConstants;
22  import org.kuali.ole.sys.batch.AbstractStep;
23  import org.springframework.util.StopWatch;
24  
25  /**
26   * A step to run the scrubber process.
27   */
28  public class IcrSortStep extends AbstractStep {
29      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(IcrSortStep.class);
30      private String batchFileDirectoryName;
31      /**
32       * Runs the scrubber process.
33       *
34       * @param jobName the name of the job this step is being run as part of
35       * @param jobRunDate the time/date the job was started
36       * @return true if the job completed successfully, false if otherwise
37       * @see org.kuali.ole.sys.batch.Step#execute(java.lang.String)
38       */
39      @Override
40      public boolean execute(String jobName, Date jobRunDate) {
41          StopWatch stopWatch = new StopWatch();
42          stopWatch.start(jobName);
43          String inputFile = batchFileDirectoryName + File.separator + GeneralLedgerConstants.BatchFileSystem.ICR_TRANSACTIONS_OUTPUT_FILE + GeneralLedgerConstants.BatchFileSystem.EXTENSION;
44          String outputFile = batchFileDirectoryName + File.separator + GeneralLedgerConstants.BatchFileSystem.ICR_POSTER_INPUT_FILE + GeneralLedgerConstants.BatchFileSystem.EXTENSION;
45  
46          BatchSortUtil.sortTextFileWithFields(inputFile, outputFile, new PosterSortComparator());
47  
48          stopWatch.stop();
49          if (LOG.isDebugEnabled()) {
50              LOG.debug("IcrSort step of " + jobName + " took " + (stopWatch.getTotalTimeSeconds() / 60.0) + " minutes to complete");
51          }
52          return true;
53      }
54  
55      public void setBatchFileDirectoryName(String batchFileDirectoryName) {
56          this.batchFileDirectoryName = batchFileDirectoryName;
57      }
58  
59  }