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.
  • Field Details

  • Constructor Details

    • BaseSyncToScheduledJobTableCustomizer

      public BaseSyncToScheduledJobTableCustomizer()
  • Method Details

    • makeCodeReference

      public static QCodeReferenceWithProperties makeCodeReference(QTableMetaData tableMetaData, AbstractRecordSyncToScheduledJobProcess syncProcess)
      Create a QCodeReferenceWithProperties 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, to MultiCustomizer
      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

      public void initialize(QCodeReference codeReference)
      Specified by:
      initialize in interface InitializableViaCodeReference
    • 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 interface TableCustomizerInterface
      Throws:
      QException
    • postDelete

      public List<QRecord> postDelete(DeleteInput deleteInput, List<QRecord> records) throws QException
      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 interface TableCustomizerInterface
      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 the ScheduledJob 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

      public void deleteScheduledJobsForRecordList(List<QRecord> records)
      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 the ScheduledJob 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

      public String getTableName()
      Getter for tableName
    • setTableName

      public void setTableName(String tableName)
      Setter for tableName
    • withTableName

      public BaseSyncToScheduledJobTableCustomizer withTableName(String tableName)
      Fluent setter for tableName
    • getSyncProcessName

      public String getSyncProcessName()
      Getter for syncProcessName
    • setSyncProcessName

      public void setSyncProcessName(String syncProcessName)
      Setter for syncProcessName
    • withSyncProcessName

      public BaseSyncToScheduledJobTableCustomizer withSyncProcessName(String syncProcessName)
      Fluent setter for syncProcessName
    • getScheduledJobForeignKeyType

      public String getScheduledJobForeignKeyType()
      Getter for scheduledJobForeignKeyType
    • setScheduledJobForeignKeyType

      public void setScheduledJobForeignKeyType(String scheduledJobForeignKeyType)
      Setter for scheduledJobForeignKeyType
    • withScheduledJobForeignKeyType

      public BaseSyncToScheduledJobTableCustomizer withScheduledJobForeignKeyType(String scheduledJobForeignKeyType)
      Fluent setter for scheduledJobForeignKeyType