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.service.impl;
017    
018    import org.kuali.kfs.gl.batch.CollectorBatch;
019    import org.kuali.kfs.gl.batch.service.ScrubberProcess;
020    import org.kuali.kfs.gl.report.CollectorReportData;
021    import org.kuali.kfs.gl.service.ScrubberService;
022    import org.kuali.kfs.sys.context.SpringContext;
023    import org.springframework.transaction.annotation.Transactional;
024    
025    /**
026     * The default implementation of ScrubberService
027     */
028    @Transactional
029    public class ScrubberServiceImpl implements ScrubberService {
030        private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ScrubberServiceImpl.class);
031    
032        private ScrubberProcess reportOnlyScrubberProcess;
033        private ScrubberProcess scrubberProcess;
034        private ScrubberProcess demergerScrubberProcess;
035        
036        protected static final String COLLECTOR_SCRUBBER_PROCESS_BEAN_NAME = "batchScrubberProcess";
037        /**
038         * This process will call the scrubber in a read only mode. It will scrub a single group, won't create any output in origin
039         * entry. It will create a the scrubber report
040         * @param group the origin entry group to scrub for report
041         * @param documentNumber the id of documents which generated origin entries that should be scrubbed
042         * @see org.kuali.kfs.gl.service.ScrubberService#scrubGroupReportOnly(org.kuali.kfs.gl.businessobject.OriginEntryGroup)
043         */
044        synchronized public void scrubGroupReportOnly(String fileName, String documentNumber) {
045            LOG.debug("scrubGroupReportOnly() started");
046    
047            reportOnlyScrubberProcess.scrubGroupReportOnly(fileName, documentNumber);
048        }
049    
050        /**
051         * Scrubs all of the entries in all origin entry groups that are up for scrubbing
052         * @see org.kuali.kfs.gl.service.ScrubberService#scrubEntries()
053         */
054        public void scrubEntries() {
055            LOG.debug("scrubEntries() started");
056    
057            scrubberProcess.scrubEntries();
058        }
059    
060        /**
061         * Scrubs data read in by the Collector
062         * 
063         * @param batch the data read by the Collector
064         * @param collectorReportData statistics about 
065         * @param overrideOriginEntryService the implementation of origin entry service to use for this specific Collector scrub
066         * @param overrideOriginEntryGroupService the implementation of origin entry group service to use for this specific Collector scrub
067         * @return the status returned by the Scrubber
068         * @see org.kuali.kfs.gl.service.ScrubberService#scrubCollectorBatch(org.kuali.kfs.gl.batch.CollectorBatch, org.kuali.kfs.gl.report.CollectorReportData, org.kuali.kfs.gl.service.OriginEntryService, org.kuali.kfs.gl.service.OriginEntryGroupService)
069         */
070        public void scrubCollectorBatch(ScrubberStatus scrubberStatus, CollectorBatch batch, CollectorReportData collectorReportData) {
071            ScrubberProcess batchScrubberProcess = (ScrubberProcess) SpringContext.getService(COLLECTOR_SCRUBBER_PROCESS_BEAN_NAME);
072            batchScrubberProcess.scrubCollectorBatch(scrubberStatus, batch, collectorReportData);
073        }
074        
075        public void performDemerger() {
076            LOG.debug("performDemerger() started");
077                //new ScrubberProcessImpl(flexibleOffsetAccountService, accountingCycleCachingService, dateTimeService, offsetDefinitionService, objectCodeService, kualiConfigurationService, universityDateDao, persistenceService, scrubberValidator, generatedCostShareOriginEntryObjectCodeOverride, runDateService, batchFileDirectoryName, null, null, null, null, demergerReportWriterService, demergerRemovedTransactionsListingReportWriterService, null);
078            demergerScrubberProcess.performDemerger();
079        }
080    
081      
082        /**
083         * Sets the reportOnlyScrubberProcess attribute value.
084         * @param reportOnlyScrubberProcess The reportOnlyScrubberProcess to set.
085         */
086        public void setReportOnlyScrubberProcess(ScrubberProcess reportOnlyScrubberProcess) {
087            this.reportOnlyScrubberProcess = reportOnlyScrubberProcess;
088        }
089    
090        /**
091         * Sets the scrubberProcess attribute value.
092         * @param scrubberProcess The scrubberProcess to set.
093         */
094        public void setScrubberProcess(ScrubberProcess scrubberProcess) {
095            this.scrubberProcess = scrubberProcess;
096        }
097    
098        /**
099         * Sets the demergerScrubberProcess attribute value.
100         * @param demergerScrubberProcess The demergerScrubberProcess to set.
101         */
102        public void setDemergerScrubberProcess(ScrubberProcess demergerScrubberProcess) {
103            this.demergerScrubberProcess = demergerScrubberProcess;
104        }
105    }