Project

General

Profile

Revision 65053ce9

ID65053ce9a3dbab1ce1843bdbad965899c56d7231
Parent b2cdc597
Child b6c2dd01

Added by Andreas Kohlbecker almost 3 years ago

fix #6037 per batch transction commit implemented for excel imports

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/common/ExcelImportConfiguratorBase.java
1 1
/**
2 2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy 
3
 * European Distributed Institute of Taxonomy
4 4
 * http://www.e-taxonomy.eu
5
 * 
5
 *
6 6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
 * See LICENSE.TXT at the top of this package for the full license terms.
8 8
 */
......
23 23

  
24 24
public abstract class ExcelImportConfiguratorBase extends ImportConfiguratorBase<ExcelImportState, URI> implements IImportConfigurator{
25 25
	private static final Logger logger = Logger.getLogger(ExcelImportConfiguratorBase.class);
26
	
26

  
27 27
	//TODO
28 28
	private static IInputTransformer defaultTransformer = null;
29 29

  
30
	private int batchSize = 0;
31

  
30 32

  
31 33
	/**
32 34
	 * @param url
......
35 37
	protected ExcelImportConfiguratorBase(URI uri, ICdmDataSource destination) {
36 38
		this(uri, destination, defaultTransformer);
37 39
	}
38
	
40

  
39 41
	/**
40 42
	 * @param url
41 43
	 * @param destination
......
64 66
		return false;
65 67
	}
66 68

  
69
	public int getBatchSize() {
70
	    return batchSize;
71
	}
72

  
73
	public void setBatchSize(int batchSize) {
74
	    this.batchSize = batchSize;
75
	}
76

  
77

  
67 78

  
68
	
69 79
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/common/ExcelImporterBase.java
109 109
				}finally{
110 110
					state.incCurrentLine();
111 111
				}
112
    			txStatus = perBatchCommit(state, txStatus, i);
112 113
    		}
113 114
    		//second pass
114 115
    		state.setCurrentLine(startingLine);
......
118 119
    			state.setOriginalRecord(record);
119 120
                secondPass(state);
120 121
    			state.incCurrentLine();
122
    			txStatus = perBatchCommit(state, txStatus, i);
121 123
    	   	}
122 124

  
123 125
    		commitTransaction(txStatus);
......
127 129
		return;
128 130
	}
129 131

  
132
    /**
133
     * @param state
134
     * @param txStatus
135
     * @param i
136
     * @return
137
     */
138
    protected TransactionStatus perBatchCommit(STATE state, TransactionStatus txStatus, int i) {
139
        if(state.getConfig().getBatchSize() > 0 &&  (i % state.getConfig().getBatchSize() == 0)) {
140
            commitTransaction(txStatus);
141
            txStatus = startTransaction();
142
        }
143
        return txStatus;
144
    }
145

  
130 146
	/**
131 147
	 * To define a worksheet name override this method. Otherwise the first worksheet is taken.
132 148
	 * @return worksheet name. <code>null</null> if not worksheet is defined.

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)