T - Class of the objects that are affected when processing records.public class DataLoader<T extends Serializable> extends Object
RecordStream. Any record consumer should extend this class.
Base implementation reads through the whole stream, but does nothing with the records.| Modifier and Type | Field and Description |
|---|---|
protected int |
createRows |
protected int |
createRowsTest |
protected int |
dataRows |
protected int |
deleteRows |
protected int |
deleteRowsTest |
protected LoaderResult<T> |
report |
protected boolean |
stopLoad |
protected boolean |
test |
protected int |
updateRows |
protected int |
updateRowsTest |
| Constructor and Description |
|---|
DataLoader()
Constructs a generic data loader.
|
DataLoader(Iterable<String> urlColumns)
Constructs a generic data loader.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
getColumnLabel(String name)
Returns the column label from header definition currently in use.
|
protected ValidationMessage |
getErrorMessage(String message,
DSRecord record,
Object field) |
protected ValidationMessage |
getErrorMessage(String message,
DSRecord record,
Object field,
String value) |
LoaderResult<T> |
load(InputStream stream)
Loads all the records from the stream and processes them.
|
LoaderResult<T> |
load(InputStream stream,
boolean test)
Loads all the records from the stream and processes them.
|
protected void |
updateRecord(DSRecord record)
Processes the record.
|
protected void |
updateRecordList(Iterable<DSRecord> records)
Processes a number of records.
|
protected void |
validateStringSize(String value,
FieldIntrospection fieldDescriptor,
Class<? extends Persistable> entity)
Checks whether the value string length is not too long for the database definition.
|
protected boolean test
protected boolean stopLoad
protected LoaderResult<T extends Serializable> report
protected int dataRows
protected int createRows
protected int updateRows
protected int deleteRows
protected int createRowsTest
protected int updateRowsTest
protected int deleteRowsTest
protected void updateRecord(DSRecord record)
record - the record to processprotected void updateRecordList(Iterable<DSRecord> records)
records - the records to processpublic LoaderResult<T> load(InputStream stream)
stream - the stream to read data frompublic LoaderResult<T> load(InputStream stream, boolean test)
stream - the stream to read data fromtest - if true, only a test whether the load would succeed is performed, and no data is imported to the
database.protected String getColumnLabel(String name)
name - the name of the columnprotected ValidationMessage getErrorMessage(String message, DSRecord record, Object field, String value)
message - the message stringrecord - the record for which the validation message is createdfield - the field for which the validation message is createdvalue - of the fieldprotected ValidationMessage getErrorMessage(String message, DSRecord record, Object field)
message - the message stringrecord - the record for which the validation message is createdfield - the field for which the validation message is createdprotected void validateStringSize(String value, FieldIntrospection fieldDescriptor, Class<? extends Persistable> entity)
false if the entity has no such field, or if the filed data type is not String.value - the string to storefieldDescriptor - the name of the entity fieldentity - the Class of the entityDbFieldLengthViolationException - if the length of value violates the database restrictions.Copyright © 2025 European Spallation Source. All rights reserved.