001/* 002 * Copyright 2005-2009 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 */ 016package org.kuali.ole.gl.batch; 017 018import org.kuali.ole.gl.service.ScrubberService; 019import org.kuali.ole.sys.batch.AbstractWrappedBatchStep; 020import org.kuali.ole.sys.batch.service.WrappedBatchExecutorService.CustomBatchExecutor; 021import org.springframework.util.StopWatch; 022 023/** 024 * A step to run the scrubber process. 025 */ 026public class DemergerStep extends AbstractWrappedBatchStep { 027 private ScrubberService scrubberService; 028 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DemergerStep.class); 029 030 /** 031 * Overridden to run the scrubber demerger process. 032 * @see org.kuali.ole.batch.Step#execute(java.lang.String) 033 */ 034 @Override 035 protected CustomBatchExecutor getCustomBatchExecutor() { 036 return new CustomBatchExecutor() { 037 public boolean execute() { 038 final String jobName = "demerger"; 039 StopWatch stopWatch = new StopWatch(); 040 stopWatch.start(jobName); 041 scrubberService.performDemerger(); 042 043 stopWatch.stop(); 044 LOG.info("scrubber step of " + jobName + " took " + (stopWatch.getTotalTimeSeconds() / 60.0) + " minutes to complete"); 045 if (LOG.isDebugEnabled()) { 046 LOG.debug("scrubber step of " + jobName + " took " + (stopWatch.getTotalTimeSeconds() / 60.0) + " minutes to complete"); 047 } 048 return true; 049 } 050 }; 051 } 052 053 /** 054 * Sets the scrubberSerivce, allowing the injection of an implementation of that service 055 * 056 * @param scrubberService the scrubberServiceService implementation to set 057 * @see org.kuali.module.gl.service.ScrubberService 058 */ 059 public void setScrubberService(ScrubberService ss) { 060 scrubberService = ss; 061 } 062}