Class BaseSyncToScheduledJobTableCustomizer
java.lang.Object
com.kingsrook.qqq.backend.core.scheduler.processes.BaseSyncToScheduledJobTableCustomizer
- All Implemented Interfaces:
TableCustomizerInterface
,InitializableViaCodeReference
public class BaseSyncToScheduledJobTableCustomizer
extends Object
implements TableCustomizerInterface, InitializableViaCodeReference
an implementation of a TableCustomizer that runs a subclass of
AbstractRecordSyncToScheduledJobProcess - to manage scheduledJob records that
correspond to records in another table (e.g., a job for each Client)
Easiest way to use is:
- BaseSyncToScheduledJobTableCustomizer.setTableCustomizers(tableMetaData, new YourSyncScheduledJobProcessSubclass());
which adds post-insert, -update, and -delete customizers to your table.
If you need additional table customizer code in those slots, I suppose you could
simply make your customizer create an instance of this class, set its
properties, and run its appropriate postInsertOrUpdate/postDelete methods.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.kingsrook.qqq.backend.core.actions.customizers.TableCustomizerInterface
TableCustomizerInterface.NotImplementedHereException
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteScheduledJobsForRecordList
(List<QRecord> records) Delete scheduled job records for source-table records that have been deleted.Getter for scheduledJobForeignKeyTypeGetter for syncProcessNameGetter for tableNamevoid
initialize
(QCodeReference codeReference) static QCodeReferenceWithProperties
makeCodeReference
(QTableMetaData tableMetaData, AbstractRecordSyncToScheduledJobProcess syncProcess) Create aQCodeReferenceWithProperties
that can be used to add this class to a table.postDelete
(DeleteInput deleteInput, List<QRecord> records) Custom actions after a delete takes place.postInsertOrUpdate
(AbstractActionInput input, List<QRecord> records, Optional<List<QRecord>> oldRecordList) Optional method to override in a customizer that does the same thing for both postInsert invalid input: '&' postUpdate.void
runSyncProcessForRecordList
(List<QRecord> records, QBackendTransaction transaction, String processName) Run the named process over a set of records (e.g., that were inserted or updated).void
setScheduledJobForeignKeyType
(String scheduledJobForeignKeyType) Setter for scheduledJobForeignKeyTypevoid
setSyncProcessName
(String syncProcessName) Setter for syncProcessNamestatic void
setTableCustomizers
(QTableMetaData tableMetaData, AbstractRecordSyncToScheduledJobProcess syncProcess) Add post insert/update/delete customizers to a table, that will run a sync-scheduled-job process.void
setTableName
(String tableName) Setter for tableNamewithScheduledJobForeignKeyType
(String scheduledJobForeignKeyType) Fluent setter for scheduledJobForeignKeyTypewithSyncProcessName
(String syncProcessName) Fluent setter for syncProcessNamewithTableName
(String tableName) Fluent setter for tableNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.kingsrook.qqq.backend.core.actions.customizers.TableCustomizerInterface
oldRecordListToMap, postInsert, postQuery, postUpdate, preDelete, preInsert, preInsertOrUpdate, preUpdate, whenToRunPreInsert
-
Field Details
-
KEY_TABLE_NAME
- See Also:
-
KEY_SYNC_PROCESS_NAME
- See Also:
-
KEY_SCHEDULED_JOB_FOREIGN_KEY_TYPE
- See Also:
-
-
Constructor Details
-
BaseSyncToScheduledJobTableCustomizer
public BaseSyncToScheduledJobTableCustomizer()
-
-
Method Details
-
makeCodeReference
public static QCodeReferenceWithProperties makeCodeReference(QTableMetaData tableMetaData, AbstractRecordSyncToScheduledJobProcess syncProcess) Create aQCodeReferenceWithProperties
that can be used to add this class to a table. If this is the only customizer for the post insert/update/delete events on your table, you can instead call setTableCustomizers. But if you want, for example, a sync-scheduled-job (what this customizer does) plus some other customizers, then you can call this method to get a code reference that you can add, for example, toMultiCustomizer
- Parameters:
tableMetaData
- the table that the customizer will be used on.syncProcess
- instance of the subclass of AbstractRecordSyncToScheduledJobProcess that should run in the table's post insert/update/delete events.- See Also:
-
setTableCustomizers
public static void setTableCustomizers(QTableMetaData tableMetaData, AbstractRecordSyncToScheduledJobProcess syncProcess) Add post insert/update/delete customizers to a table, that will run a sync-scheduled-job process.- Parameters:
tableMetaData
- the table that the customizer will be used on.syncProcess
- instance of the subclass of AbstractRecordSyncToScheduledJobProcess that should run in the table's post insert/update/delete events.
-
initialize
- Specified by:
initialize
in interfaceInitializableViaCodeReference
-
postInsertOrUpdate
public List<QRecord> postInsertOrUpdate(AbstractActionInput input, List<QRecord> records, Optional<List<QRecord>> oldRecordList) throws QException Description copied from interface:TableCustomizerInterface
Optional method to override in a customizer that does the same thing for both postInsert invalid input: '&' postUpdate.- Specified by:
postInsertOrUpdate
in interfaceTableCustomizerInterface
- Throws:
QException
-
postDelete
Description copied from interface:TableCustomizerInterface
Custom actions after a delete takes place. General implementation would be, to iterate over the records (ones which didn't have a delete error), and look at their values: - possibly adding Errors (`addError`) or Warnings (`addWarning`) to the records? - possibly throwing an exception - though doing so won't stop the delete, and instead will just set a warning on all of the deleted records... - doing "whatever else" you may want to do. - returning the list of records (can be the input list) that you want to go back to the caller - this is how errors and warnings are propagated .- Specified by:
postDelete
in interfaceTableCustomizerInterface
- Throws:
QException
-
runSyncProcessForRecordList
public void runSyncProcessForRecordList(List<QRecord> records, QBackendTransaction transaction, String processName) Run the named process over a set of records (e.g., that were inserted or updated). This method is normally called from within this class, in postInsertOrUpdate. Note that if theScheduledJob
table isn't defined in the QInstance, that the process will not be called.- Parameters:
records
- list of records to use as source records in the table-sync to the scheduledJob table.transaction
- that the insert or update is happening on - which the process we run might need to peek in to for seeing the records.processName
- name of the sync-process to run.
-
deleteScheduledJobsForRecordList
Delete scheduled job records for source-table records that have been deleted. This method is normally called from within this class, in postDelete. Note that if theScheduledJob
table isn't defined in the QInstance, that the process will not be called.- Parameters:
records
- list of records to use as foreign-key sources to identify scheduledJob records to delete
-
getTableName
Getter for tableName -
setTableName
Setter for tableName -
withTableName
Fluent setter for tableName -
getSyncProcessName
Getter for syncProcessName -
setSyncProcessName
Setter for syncProcessName -
withSyncProcessName
Fluent setter for syncProcessName -
getScheduledJobForeignKeyType
Getter for scheduledJobForeignKeyType -
setScheduledJobForeignKeyType
Setter for scheduledJobForeignKeyType -
withScheduledJobForeignKeyType
public BaseSyncToScheduledJobTableCustomizer withScheduledJobForeignKeyType(String scheduledJobForeignKeyType) Fluent setter for scheduledJobForeignKeyType
-