Class AbstractTableSyncTransformStep
java.lang.Object
com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.AbstractTransformStep
com.kingsrook.qqq.backend.core.processes.implementations.tablesync.AbstractTableSyncTransformStep
- All Implemented Interfaces:
ProcessSummaryProviderInterface
- Direct Known Subclasses:
AbstractRecordSyncToScheduledJobProcess,ScheduledReportSyncToScheduledJobProcess
This class is for transforming records from a Source table to a Destination table.
The Source table has a (unique/primary) key field: sourceTableKeyField,
Which is matched against the Destination table's foreign-key: destinationTableForeignKeyField
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRecord to store the config for this process - e.g., what fields invalid input: '&' tables are used. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ProcessSummaryLineprotected static final QLoggerprotected static final Stringprotected ProcessSummaryLineprotected ProcessSummaryLineprotected QPossibleValueTranslatorprotected RecordLookupHelperprotected RunBackendStepInputprotected RunBackendStepOutputprotected static final Stringprotected static final Stringprotected ProcessSummaryLineprotected ProcessSummaryLineprotected ProcessSummaryLine -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAuditForExecuteStep(AuditSingleInput auditSingleInput) Let the subclass "easily" add an audit to be inserted on the Execute step.protected Map<Pair<String, Serializable>, QRecord> buildExistingRecordsMap(String destinationTableForeignKeyField, List<QRecord> existingRecordList) Overridable point where you can, for example, keys in the existingRecordsMap with different fieldNames from the destinationTable.protected SerializableextractSourceKeyValueFromRecord(QRecord sourceRecord, String sourceTableKeyField) Given a source record, extract what we'll use as its key from it.protected Collection<String> protected ArrayList<ProcessSummaryLineInterface> getErrorProcessSummaryLines(RunBackendStepOutput runBackendStepOutput, boolean isForResultScreen) protected QRecordgetExistingRecord(Map<Pair<String, Serializable>, QRecord> existingRecordsByForeignKey, QFieldMetaData destinationForeignKeyField, Serializable sourceKeyValue) protected QQueryFiltergetExistingRecordQueryFilter(RunBackendStepInput runBackendStepInput, List<Serializable> sourceKeyList) Define the query filter to find existing records.protected Map<Pair<String, Serializable>, QRecord> getExistingRecordsByForeignKey(RunBackendStepInput runBackendStepInput, String destinationTableForeignKeyField, String destinationTableName, List<Serializable> sourceKeyList) Run the existingRecordQueryFilter - to look in the destinationTable for any records that may need an update (rather than an insert).Specify a list of tableName/keyColumnName pairs to run through the preloadRecords method of the recordLookupHelper.getProcessSummary(RunBackendStepOutput runBackendStepOutput, boolean isForResultScreen) Note - object needs to be serializable, and List isn't... so, use ArrayList?protected abstract AbstractTableSyncTransformStep.SyncProcessConfigDefine the config for this process - e.g., what fields invalid input: '&' tables are used.protected voidinitializeRecordLookupHelper(RunBackendStepInput runBackendStepInput, List<QRecord> sourceRecordList) If needed, init a record lookup helper for this process.protected voidlogResults(RunBackendStepInput runBackendStepInput, AbstractTableSyncTransformStep.SyncProcessConfig syncProcessConfig) Log results of transformationabstract QRecordpopulateRecordToStore(RunBackendStepInput runBackendStepInput, QRecord destinationRecord, QRecord sourceRecord) Map a record from the source table to the destination table.protected voidreinitializeRecordLookupHelper(RunBackendStepInput runBackendStepInput, List<QRecord> sourceRecordList) for pages after the first, possibly load more records in the lookup helper.voidrunOnePage(RunBackendStepInput runBackendStepInput, RunBackendStepOutput runBackendStepOutput) Do the transform logic for one page of recordsMethods inherited from class com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.AbstractTransformStep
getOverrideRecordPipeCapacity, getTransaction, postRun, preRun, setTransactionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.ProcessSummaryProviderInterface
doGetProcessSummary
-
Field Details
-
LOG
-
okToInsert
-
okToUpdate
-
willNotInsert
-
willNotUpdate
-
errorMissingKeyField
-
unspecifiedError
-
runBackendStepInput
-
runBackendStepOutput
-
recordLookupHelper
-
possibleValueTranslator
-
SYNC_TABLE_PERFORM_INSERTS_KEY
- See Also:
-
SYNC_TABLE_PERFORM_UPDATES_KEY
- See Also:
-
LOG_TRANSFORM_RESULTS
- See Also:
-
-
Constructor Details
-
AbstractTableSyncTransformStep
public AbstractTableSyncTransformStep()
-
-
Method Details
-
getProcessSummary
public ArrayList<ProcessSummaryLineInterface> getProcessSummary(RunBackendStepOutput runBackendStepOutput, boolean isForResultScreen) Description copied from interface:ProcessSummaryProviderInterfaceNote - object needs to be serializable, and List isn't... so, use ArrayList? -
getErrorProcessSummaryLines
protected ArrayList<ProcessSummaryLineInterface> getErrorProcessSummaryLines(RunBackendStepOutput runBackendStepOutput, boolean isForResultScreen) -
populateRecordToStore
public abstract QRecord populateRecordToStore(RunBackendStepInput runBackendStepInput, QRecord destinationRecord, QRecord sourceRecord) throws QException Map a record from the source table to the destination table. e.g., put values into the destinationRecord, from the sourceRecord. The destinationRecord will already be constructed, and will actually already be the record being updated, in the case of an update. It'll be empty (newly constructed) for an insert.- Throws:
QException
-
getLookupsToPreLoad
-
getExistingRecordQueryFilter
protected QQueryFilter getExistingRecordQueryFilter(RunBackendStepInput runBackendStepInput, List<Serializable> sourceKeyList) Define the query filter to find existing records. e.g., for determining insert vs. update. Subclasses may override this to customize the behavior, e.g., in case an additional field is needed in the query. -
getSyncProcessConfig
Define the config for this process - e.g., what fields invalid input: '&' tables are used. -
runOnePage
public void runOnePage(RunBackendStepInput runBackendStepInput, RunBackendStepOutput runBackendStepOutput) throws QException Description copied from class:AbstractTransformStepDo the transform logic for one page of records- Specified by:
runOnePagein classAbstractTransformStep- Throws:
QException
-
logResults
protected void logResults(RunBackendStepInput runBackendStepInput, AbstractTableSyncTransformStep.SyncProcessConfig syncProcessConfig) Log results of transformation -
extractSourceKeyValueFromRecord
protected Serializable extractSourceKeyValueFromRecord(QRecord sourceRecord, String sourceTableKeyField) Given a source record, extract what we'll use as its key from it. Normally this is just its sourceTableKeyField value - but - a subclass may do something more interesting, including, returning a java-record. -
getExistingRecord
protected QRecord getExistingRecord(Map<Pair<String, Serializable>, QRecord> existingRecordsByForeignKey, QFieldMetaData destinationForeignKeyField, Serializable sourceKeyValue) -
getExistingRecordsByForeignKey
protected Map<Pair<String,Serializable>, getExistingRecordsByForeignKeyQRecord> (RunBackendStepInput runBackendStepInput, String destinationTableForeignKeyField, String destinationTableName, List<Serializable> sourceKeyList) throws QException Run the existingRecordQueryFilter - to look in the destinationTable for any records that may need an update (rather than an insert). Generally returns a Map, keyed by a Pair of the destinationTableForeignKeyField and the value in that field. But, for more complex use-cases, one can override the buildExistingRecordsMap method, to make different keys (e.g., if there are two possible destinationTableForeignKeyFields).- Throws:
QException
-
buildExistingRecordsMap
protected Map<Pair<String,Serializable>, buildExistingRecordsMapQRecord> (String destinationTableForeignKeyField, List<QRecord> existingRecordList) throws QException Overridable point where you can, for example, keys in the existingRecordsMap with different fieldNames from the destinationTable. Note, if you're overriding this method, you'll likely also want invalid input: '&' need to override getExistingRecord.- Throws:
QException
-
getQueryJoins
-
getAssociationNamesToInclude
-
initializeRecordLookupHelper
protected void initializeRecordLookupHelper(RunBackendStepInput runBackendStepInput, List<QRecord> sourceRecordList) throws QException If needed, init a record lookup helper for this process.- Throws:
QException
-
reinitializeRecordLookupHelper
protected void reinitializeRecordLookupHelper(RunBackendStepInput runBackendStepInput, List<QRecord> sourceRecordList) throws QException for pages after the first, possibly load more records in the lookup helper.- Throws:
QException
-
addAuditForExecuteStep
Let the subclass "easily" add an audit to be inserted on the Execute step.
-