public abstract class Importer
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
protected static interface |
Importer.FieldMaker
Functional interface for adding imposed field to temp-table.
|
protected static class |
Importer.ImportContext
Import context holder
|
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.String,java.lang.String> |
b4tables
Mapping of tables with before-table names.
|
protected BufferManager |
bufMan
The
BufferManager instance. |
protected java.util.Map<java.lang.String,org.apache.commons.lang3.tuple.Pair<java.lang.String[],java.lang.String[]>> |
childFieldsByChild
Child fields for NESTED relations with FOREIGN-KEY-HIDDEN = true per child table name
|
protected Importer.ImportContext |
ctx
Import context
|
protected DataSet |
ds
Current dataset, if one is being processed.
|
protected java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.String>> |
inferredRelations
Inferred DATA-RELATIONs data
|
protected java.util.function.BiConsumer<RecordBuffer,Record> |
loader
Helper for setting a
Record into a buffer, avoiding direct access to private method. |
private static CentralLogger |
LOG
Logger.
|
protected java.util.Map<java.lang.String,rowid> |
peerMapping
Associates the
prod:id to their record's rowid. |
protected boolean |
readingBefore
true when reading a before-table image. |
protected SerializeOptions.Read |
readMode
Read mode to determine how records are stored and how non-unique records are handled
|
protected java.util.Stack<Importer.ImportContext> |
savedCtx
Import context
|
protected SourceData |
source
Data source which normalizes access of various media to an input stream.
|
protected java.util.Map<java.lang.String,AbstractTempTable> |
tables
The set of temp-table builders for a dataset.
|
| Constructor and Description |
|---|
Importer(SourceData source,
java.lang.String readMode)
C'tor
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
fillFromParent()
Populate fields from the parent table (for FOREIGN-KEY-HIDDEN support).
|
protected TempTableSchema.Column |
getColumn(java.lang.String name)
Get schema information for the column associated with the given name.
|
protected Importer.ImportContext |
peekContext()
Peek the top of the import context data stack.
|
protected boolean |
persist(Importer.FieldMaker maker,
java.util.Map<java.lang.String,java.lang.Object> readValues,
boolean addLinkToParent)
Persist the read values as a new record.
|
protected void |
popContext()
Pop import context data.
|
protected boolean |
populateRecord(java.util.Map<java.lang.String,java.lang.Object> readValues)
Populate record with values from JSON/XML.
|
protected void |
processHiddenFk(DataSet ds)
Collect relations with FOREIGN-KEY-HIDDEN =
true> |
protected void |
processId(RecordBuffer recBuffer,
java.lang.String value)
Process record id: creates the link between the before and after-image based on the rowid value.
|
protected void |
processRowState(RecordBuffer recBuffer,
java.lang.String value)
Process record row state: assign it to the record stored in the
recBuffer. |
protected void |
pushContext()
Push import context data.
|
protected void |
setField(TempTableSchema.Column column,
java.lang.String name,
java.lang.String value)
Set the value of a single field in the temp-table record currently being read from the JSON/XML
content.
|
protected void |
setField(TempTableSchema.Column column,
java.lang.String name,
java.lang.String value,
boolean extent)
Set the value of a single field in the temp-table record currently being read from the JSON/XML content.
|
protected void |
setField(TempTableSchema.Column column,
java.lang.String name,
java.lang.String value,
int index)
Set the value of a single field in the temp-table record currently being read from the JSON/XML content.
|
protected boolean |
setParentValues(java.lang.String name)
Initialize values of the fields to be taken from the parent (for FOREIGN-KEY-HIDDEN support).
|
protected void |
setupDataset(java.lang.String name)
Final setup of the inferred dataset.
|
protected abstract ParmType |
typeOf(java.lang.Object val)
Get an inferred type of the value.
|
private static final CentralLogger LOG
protected Importer.ImportContext ctx
protected final java.util.Stack<Importer.ImportContext> savedCtx
protected final SourceData source
protected final SerializeOptions.Read readMode
protected DataSet ds
protected java.util.Map<java.lang.String,org.apache.commons.lang3.tuple.Pair<java.lang.String[],java.lang.String[]>> childFieldsByChild
protected boolean readingBefore
true when reading a before-table image.protected java.util.Map<java.lang.String,rowid> peerMapping
prod:id to their record's rowid.protected java.util.function.BiConsumer<RecordBuffer,Record> loader
Record into a buffer, avoiding direct access to private method.protected final java.util.Map<java.lang.String,AbstractTempTable> tables
protected final java.util.Map<java.lang.String,java.lang.String> b4tables
protected final java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.String>> inferredRelations
protected final BufferManager bufMan
BufferManager instance.public Importer(SourceData source, java.lang.String readMode)
source - XML data source which normalizes access of various media to an input stream.readMode - Read mode to determine how records are stored and how non-unique records are
handled. Not currently honored, except temp-table records are deleted if mode
is EMPTY.protected abstract ParmType typeOf(java.lang.Object val) throws PersistenceException
val - The value to be analyzed.PersistenceException - on invalid value typeprotected void processHiddenFk(DataSet ds)
true>ds - DATASET to be analyzedprotected boolean setParentValues(java.lang.String name)
name - The name of the child table.true on success.protected void fillFromParent()
throws PersistenceException
PersistenceException - on database error.protected boolean persist(Importer.FieldMaker maker, java.util.Map<java.lang.String,java.lang.Object> readValues, boolean addLinkToParent) throws PersistenceException
readValues - The map containing the values of the fields mapped by their name.addLinkToParent - Flag indicating that a link to the parent must be added.true on success.PersistenceException - in the event of a persistebnce error.protected boolean populateRecord(java.util.Map<java.lang.String,java.lang.Object> readValues)
throws PersistenceException
readValues - The values read from JSON/XML mapped by their field name.true on success.PersistenceException - in the event of a persistebnce error.protected void setField(TempTableSchema.Column column, java.lang.String name, java.lang.String value) throws PersistenceException
column - Schema information for the associated column.name - Element or attribute name associated with serialized JSON/XML data for a temp-table
column.value - Data value read from JSON/XML content. Set to null to represent unknown value.PersistenceException - if there is an error storing data in the temp-table.protected void setField(TempTableSchema.Column column, java.lang.String name, java.lang.String value, boolean extent) throws PersistenceException
column - Schema information for the associated column.name - Element or attribute name associated with serialized JSON/XML data for a temp-table column.value - Data value read from JSON content. Set to null to represent unknown value.extent - true to indicate an extent field; false if scalar.PersistenceException - if there is an error storing data in the temp-table.protected void setField(TempTableSchema.Column column, java.lang.String name, java.lang.String value, int index) throws PersistenceException
column - Schema information for the associated column.name - Element or attribute name associated with serialized JSON/XML data for a temp-table column.value - Data value read from JSON content. Set to null to represent unknown value.index - The offset value in case of an extent field. -1 to be ignored.PersistenceException - if there is an error storing data in the temp-table.protected TempTableSchema.Column getColumn(java.lang.String name)
name - Element or attribute name associated with serialized JSON/XML data for a temp-table column.ErrorConditionException - if name is not associated with a column.protected void processRowState(RecordBuffer recBuffer, java.lang.String value)
recBuffer.recBuffer - The record buffer which will receive the provided row state.value - The row state value.protected void processId(RecordBuffer recBuffer, java.lang.String value) throws PersistenceException
recBuffer - The record buffer containing the before image.value - id valuePersistenceExceptionprotected void pushContext()
protected void popContext()
protected Importer.ImportContext peekContext()
protected void setupDataset(java.lang.String name)
throws PersistenceException
name - The dataset name.PersistenceException - on error