public abstract class RecordLoader
extends java.lang.Object
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, nextRecord(Stream)
should be called repeatedly, until
there are no more records to process in the input data file.
Modifier and Type | Field and Description |
---|---|
private boolean |
checkTypes
Flag to enable assertions of type match for each data field
|
private java.io.File |
dataFile
Input data file - a Progress export (*.d) file
|
private java.util.Map<java.lang.String,PropertyMapper> |
mappersByCol
Property mappers which define column data, by column name
|
private java.util.Map<java.lang.String,java.lang.Integer> |
mappersByIndex
Property mappers which define column native index, by property name
|
private java.util.Map<java.lang.String,PropertyMapper> |
mappersByProp
Property mappers which define column data, by property name
|
private PropertyMapper[] |
properties
Property mappers which define column data
|
private java.lang.Class<? extends Record> |
recordClass
Class which is instantiated for each import record
|
Constructor and Description |
---|
RecordLoader(java.lang.Class<? extends Record> recordClass,
java.io.File dataFile,
boolean checkTypes)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
(package private) java.io.File |
getDataFile()
Retrieve the file containing the export data for the current table.
|
protected java.lang.String |
getDMOName()
Get the unqualified name of the DMO class associated with this record loader.
|
protected java.lang.String |
getFullDMOName()
Get the full name of the DMO class associated with this record loader.
|
PropertyMapper |
getPropertyMapperByColumn(java.lang.String name)
Get PropertyMapper by column name.
|
(package private) Record |
nextRecord(Stream input)
Read a single record from the current location in a Progress export file and store its data
in a bean-like object.
|
(package private) void |
overwriteNullProperty(java.lang.String propertyName,
Record dmo,
BaseDataType val)
Overwrites the
null / unknown values of a specified property and updates it
to a specified value (if the property is an extent, all indexes are checked and updated). |
protected void |
processNextValue(PropertyMapper mapper,
Record record,
BaseDataType value)
Process the data value most recently read from the data export file.
|
private final PropertyMapper[] properties
private final java.util.Map<java.lang.String,PropertyMapper> mappersByProp
private final java.util.Map<java.lang.String,PropertyMapper> mappersByCol
private final java.util.Map<java.lang.String,java.lang.Integer> mappersByIndex
private java.lang.Class<? extends Record> recordClass
private java.io.File dataFile
private final boolean checkTypes
public RecordLoader(java.lang.Class<? extends Record> recordClass, 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.
recordClass
- Class which is instantiated for each record imported.dataFile
- Data input file.checkTypes
- true
to assert that the data type of each field read matches the expected
type.public PropertyMapper getPropertyMapperByColumn(java.lang.String name)
name
- column namevoid overwriteNullProperty(java.lang.String propertyName, Record dmo, BaseDataType val)
null
/ unknown
values of a specified property and updates it
to a specified value (if the property is an extent, all indexes are checked and updated).
This happens for mandatory fields because they were declared as not-null.propertyName
- The name of the property.dmo
- The record to be updated.val
- The default value to be used instead.Record nextRecord(Stream input) throws java.lang.InstantiationException, java.lang.IllegalAccessException
PropertyMapper
objects stored
in this loader instance.
The checkTypes
functionality is not honored here although this would be the
correct location to add that feature.
input
- The export file to be read.null
if no more records are available.java.lang.InstantiationException
- if any error occurs creating a new instance of the DMO class.java.lang.IllegalAccessException
- if the record class, its default constructor, or a setter method which we invoke is
not accessible.protected void processNextValue(PropertyMapper mapper, Record record, BaseDataType value)
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.protected java.lang.String getFullDMOName()
protected java.lang.String getDMOName()
java.io.File getDataFile()