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 org.kuali.ole.gl.service.ScrubberService;
19  import org.kuali.ole.sys.batch.AbstractWrappedBatchStep;
20  import org.kuali.ole.sys.batch.service.WrappedBatchExecutorService.CustomBatchExecutor;
21  import org.springframework.util.StopWatch;
22  
23  /**
24   * A step to run the scrubber process.
25   */
26  public class DemergerStep extends AbstractWrappedBatchStep {
27      private ScrubberService scrubberService;
28      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DemergerStep.class);
29      
30      /**
31       * Overridden to run the scrubber demerger process.
32       * @see org.kuali.ole.batch.Step#execute(java.lang.String)
33       */
34      @Override
35      protected CustomBatchExecutor getCustomBatchExecutor() {
36          return new CustomBatchExecutor() {
37              public boolean execute() {
38                  final String jobName = "demerger";
39                  StopWatch stopWatch = new StopWatch();
40                  stopWatch.start(jobName);
41                  scrubberService.performDemerger();
42  
43                  stopWatch.stop();
44                  LOG.info("scrubber step of " + jobName + " took " + (stopWatch.getTotalTimeSeconds() / 60.0) + " minutes to complete");
45                  if (LOG.isDebugEnabled()) {
46                      LOG.debug("scrubber step of " + jobName + " took " + (stopWatch.getTotalTimeSeconds() / 60.0) + " minutes to complete");
47                  }
48                  return true;
49              }
50          };
51      }
52  
53        /**
54         * Sets the scrubberSerivce, allowing the injection of an implementation of that service
55         * 
56         * @param scrubberService the scrubberServiceService implementation to set
57         * @see org.kuali.module.gl.service.ScrubberService
58         */
59        public void setScrubberService(ScrubberService ss) {
60            scrubberService = ss;
61        }
62  }