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.businessobject.OriginEntryFieldUtil;
025 import org.kuali.kfs.sys.KFSPropertyConstants;
026 import org.kuali.kfs.sys.batch.AbstractStep;
027 import org.springframework.util.StopWatch;
028 import org.kuali.kfs.gl.batch.DemergerSortComparator;
029
030 /**
031 * A step to run the scrubber process.
032 */
033 public class DemergerSortStep extends AbstractStep {
034 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DemergerSortStep.class);
035 protected String batchFileDirectoryName;
036
037 /**
038 * Runs the scrubber process.
039 *
040 * @param jobName the name of the job this step is being run as part of
041 * @param jobRunDate the time/date the job was started
042 * @return true if the job completed successfully, false if otherwise
043 * @see org.kuali.kfs.sys.batch.Step#execute(java.lang.String)
044 */
045 public boolean execute(String jobName, Date jobRunDate) {
046 StopWatch stopWatch = new StopWatch();
047 stopWatch.start(jobName);
048 String inputFile = batchFileDirectoryName + File.separator + GeneralLedgerConstants.BatchFileSystem.SCRUBBER_ERROR_OUTPUT_FILE + GeneralLedgerConstants.BatchFileSystem.EXTENSION;
049 String outputFile = batchFileDirectoryName + File.separator + GeneralLedgerConstants.BatchFileSystem.SCRUBBER_ERROR_SORTED_FILE + GeneralLedgerConstants.BatchFileSystem.EXTENSION;
050
051 BatchSortUtil.sortTextFileWithFields(inputFile, outputFile, new DemergerSortComparator());
052
053 stopWatch.stop();
054 if (LOG.isDebugEnabled()) {
055 LOG.debug("scrubber step of " + jobName + " took " + (stopWatch.getTotalTimeSeconds() / 60.0) + " minutes to complete");
056 }
057 return true;
058 }
059
060 public void setBatchFileDirectoryName(String batchFileDirectoryName) {
061 this.batchFileDirectoryName = batchFileDirectoryName;
062 }
063 }