1
2
3
4 package org.kuali.ole.sys.batch;
5
6 import java.io.File;
7 import java.util.Comparator;
8 import java.util.Date;
9
10 import org.kuali.ole.gl.batch.BatchSortUtil;
11 import org.kuali.ole.sys.batch.AbstractStep;
12
13
14
15
16
17
18 public class FlatFileSortStep extends AbstractStep {
19 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(FlatFileSortStep.class);
20 protected String inputFileName;
21 protected String outputFileName;
22 protected Class<? extends Comparator<String>> lineComparatorClass;
23
24 public boolean execute(String jobName, Date jobRunDate) throws InterruptedException {
25 try {
26 if ( new File(inputFileName).canRead() ) {
27 BatchSortUtil.sortTextFileWithFields(inputFileName, outputFileName, lineComparatorClass.newInstance());
28 } else {
29 LOG.warn( "Input file: " + inputFileName + " does not exist.");
30 }
31 } catch (Exception ex) {
32 throw new RuntimeException( "Unable to instantiate comparator class for sort: " + lineComparatorClass, ex );
33 }
34 return true;
35 }
36
37 public void setInputFileName(String inputFileName) {
38 this.inputFileName = inputFileName;
39 }
40
41 public void setOutputFileName(String outputFileName) {
42 this.outputFileName = outputFileName;
43 }
44
45 public void setLineComparatorClass( Class<? extends Comparator<String>> lineComparatorClass) {
46 this.lineComparatorClass = lineComparatorClass;
47 }
48 }