public static final class ImportWorker.SqlRecordLoader extends RecordLoader
PropertyMapper
objects, in the order the
mapped data is expected to be encountered in the export file for
each record (one per column, or one per subscript value for extent
columns);
QueryHelper
objects used to resolve foreign
key associations, indexed by the name of the "foreign" class;
Method
objects used to set a "foreign" class
as property of the data model object currently being imported.
An instance of this class is created for each table which needs to be
imported. The above properties are set as necessary, using the various
set, put, and add methods. Once the instance is fully configured,
RecordLoader.nextRecord(com.goldencode.p2j.util.Stream)
is called repeatedly, until there are no more
records to process in the input data file.
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,BaseDataType> |
notNullProps
Map of not-null properties to their default values.
|
private java.lang.String |
table
Name of database table
|
Constructor and Description |
---|
SqlRecordLoader(java.lang.Class<? extends Record> dmoClass,
java.lang.String table,
java.io.File dataFile,
boolean checkTypes)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addNotNullProperty(java.lang.String prop,
BaseDataType def)
Add the not-null property with its default value, if any.
|
java.lang.String |
getTable()
Get the name of the database table associated with this loader instance.
|
protected void |
processNextValue(PropertyMapper mapper,
Record record,
BaseDataType value)
Process the data value most recently read from the data export file.
|
getDataFile, getDMOName, getFullDMOName, getPropertyMapperByColumn, nextRecord, overwriteNullProperty
private final java.lang.String table
private final java.util.Map<java.lang.String,BaseDataType> notNullProps
public SqlRecordLoader(java.lang.Class<? extends Record> dmoClass, java.lang.String table, java.io.File dataFile, boolean checkTypes)
Note: the checkTypes
flag should be set to false
for normal operations. It is
expensive and should be enabled for debug purposes only.
dmoClass
- Class which is instantiated for each record imported.table
- Name of the table associated with this loader instance.dataFile
- Data input file.checkTypes
- true
to assert that the data type of each field read matches the expected type.public void addNotNullProperty(java.lang.String prop, BaseDataType def)
prop
- The property name.def
- The default value.public java.lang.String getTable()
protected void processNextValue(PropertyMapper mapper, Record record, BaseDataType value)
nextRecord
method for each data value read from the data export file. If the
current property is not delegated and not dropped,processNextValue
in class RecordLoader
mapper
- Mapping object associated with the current property.record
- Java-bean-like object which holds the contents of the record
currently being loaded.value
- Data value read from the data export file for the current property. It has
not yet been stored in the record
object.