Update CsvCallback API to use Database instead of EbeanServer (#2010)

* Update CsvCallback API to use Database instead of EbeanServer
This commit is contained in:
Rob Bygrave
2020-09-14 18:33:12 +12:00
committed by GitHub
parent 6839f869f5
commit 90b1b88be6
3 changed files with 10 additions and 16 deletions
@@ -1,6 +1,6 @@
package io.ebean.text.csv;
import io.ebean.EbeanServer;
import io.ebean.Database;
/**
* Provides callback methods for customisation of CSV processing.
@@ -8,9 +8,6 @@ import io.ebean.EbeanServer;
* You can provide your own CsvCallback implementation to customise the CSV
* processing. It is expected that the DefaultCsvCallback provides a good base
* class that you can extend.
* </p>
*
* @param <T>
*/
public interface CsvCallback<T> {
@@ -21,7 +18,7 @@ public interface CsvCallback<T> {
* size etc.
* </p>
*/
void begin(EbeanServer server);
void begin(Database database);
/**
* Read the header row.
@@ -73,8 +70,8 @@ public interface CsvCallback<T> {
* was created.
* </p>
*
* @param row the row that the error has occured on
* @param e the error that occured
* @param row the row that the error has occurred on
* @param e the error that occurred
*/
void endWithError(int row, Exception e);
@@ -1,6 +1,6 @@
package io.ebean.text.csv;
import io.ebean.EbeanServer;
import io.ebean.Database;
import io.ebean.Transaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,7 +35,7 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
/**
* The EbeanServer used to save the beans.
*/
protected EbeanServer server;
protected Database server;
/**
* Used to log a message to indicate progress through large files.
@@ -69,7 +69,6 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
* Construct with explicit batch size and logging info frequency.
*/
public DefaultCsvCallback(int persistBatchSize, int logInfoFrequency) {
this.persistBatchSize = persistBatchSize;
this.logInfoFrequency = logInfoFrequency;
}
@@ -78,10 +77,9 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
* Create a transaction if required.
*/
@Override
public void begin(EbeanServer server) {
public void begin(Database server) {
this.server = server;
this.startTime = System.currentTimeMillis();
initTransactionIfRequired();
}
@@ -1,6 +1,6 @@
package io.ebeaninternal.server.text.csv;
import io.ebean.EbeanServer;
import io.ebean.Database;
import io.ebean.bean.EntityBean;
import io.ebean.plugin.ExpressionPath;
import io.ebean.text.StringParser;
@@ -31,7 +31,7 @@ public class TCsvReader<T> implements CsvReader<T> {
private static final TimeStringParser TIME_PARSER = new TimeStringParser();
private final EbeanServer server;
private final Database server;
private final BeanDescriptor<T> descriptor;
@@ -55,7 +55,7 @@ public class TCsvReader<T> implements CsvReader<T> {
private boolean addPropertiesFromHeader;
public TCsvReader(EbeanServer server, BeanDescriptor<T> descriptor) {
public TCsvReader(Database server, BeanDescriptor<T> descriptor) {
this.server = server;
this.descriptor = descriptor;
}
@@ -349,7 +349,6 @@ public class TCsvReader<T> implements CsvReader<T> {
try {
Date dt = dateFormat.parse(value);
return path.parseDateTime(dt.getTime());
} catch (ParseException e) {
throw new TextException("Error parsing [{}] using format[" + format + "]", value, e);
}