001    /**
002     * Copyright 2010-2013 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.common.jdbc.listener;
017    
018    import org.kuali.common.jdbc.JdbcUtils;
019    import org.kuali.common.util.PercentCompleteInformer;
020    
021    /**
022     * Print a dot to the console each time 1% of the SQL finishes executing
023     * 
024     * @deprecated
025     */
026    @Deprecated
027    public class ProgressListener extends NoOpSqlListener {
028    
029            PercentCompleteInformer informer = new PercentCompleteInformer();
030            boolean startInformer = true;
031    
032            @Override
033            public synchronized void beforeExecution(SqlExecutionEvent event) {
034                    // The total number of SQL statements being executed
035                    informer.setTotal(JdbcUtils.getSqlCount(event.getContext().getSuppliers()));
036            }
037    
038            @Override
039            public synchronized void afterExecuteSql(SqlEvent event) {
040                    // The first SQL statement was just executed
041                    if (startInformer) {
042                            informer.start();
043                            startInformer = false;
044                    }
045    
046                    // Increment the counter
047                    informer.incrementProgress();
048            }
049    
050            @Override
051            public void afterExecution(SqlExecutionEvent event) {
052                    informer.stop();
053            }
054    
055            public PercentCompleteInformer getInformer() {
056                    return informer;
057            }
058    
059            public void setInformer(PercentCompleteInformer informer) {
060                    this.informer = informer;
061            }
062    
063    }