Class AbstractPreInsertCustomizer

java.lang.Object
com.kingsrook.qqq.backend.core.actions.customizers.AbstractPreInsertCustomizer
All Implemented Interfaces:
TableCustomizerInterface

public abstract class AbstractPreInsertCustomizer extends Object implements TableCustomizerInterface
Abstract class that a table can specify an implementation of, to provide custom actions before an insert takes place. It's important for implementations to be aware of the isPreview field, which is set to true when the code is running to give users advice, e.g., on a review screen - vs. being false when the action is ACTUALLY happening. So, if you're doing things like storing data, you don't want to do that if isPreview is true!! General implementation would be, to iterate over the records (the inputs to the insert action), and look at their values: - possibly adding Errors (`addError`) or Warnings (`addWarning`) to the records - possibly manipulating values (`setValue`) - possibly throwing an exception - if you really don't want the insert operation to continue. - doing "whatever else" you may want to do. - returning the list of records (can be the input list) that you want to go on to the backend implementation class. Note that the full insertInput is available as a field in this class.
  • Field Details

    • insertInput

      protected InsertInput insertInput
    • isPreview

      protected boolean isPreview
  • Constructor Details

    • AbstractPreInsertCustomizer

      public AbstractPreInsertCustomizer()
  • Method Details

    • preInsert

      public List<QRecord> preInsert(InsertInput insertInput, List<QRecord> records, boolean isPreview) throws QException
      Description copied from interface: TableCustomizerInterface
      custom actions before an insert takes place. It's important for implementations to be aware of the isPreview field, which is set to true when the code is running to give users advice, e.g., on a review screen - vs. being false when the action is ACTUALLY happening. So, if you're doing things like storing data, you don't want to do that if isPreview is true!! General implementation would be, to iterate over the records (the inputs to the insert action), and look at their values: - possibly adding Errors (`addError`) or Warnings (`addWarning`) to the records - possibly manipulating values (`setValue`) - possibly throwing an exception - if you really don't want the insert operation to continue. - doing "whatever else" you may want to do. - returning the list of records (can be the input list) that you want to go on to the backend implementation class.
      Specified by:
      preInsert in interface TableCustomizerInterface
      Throws:
      QException
    • whenToRunPreInsert

      public AbstractPreInsertCustomizer.WhenToRun whenToRunPreInsert(InsertInput insertInput, boolean isPreview)
      Specified by:
      whenToRunPreInsert in interface TableCustomizerInterface
    • apply

      public abstract List<QRecord> apply(List<QRecord> records) throws QException
      Throws:
      QException
    • getWhenToRun

    • getInsertInput

      public InsertInput getInsertInput()
      Getter for insertInput
    • setInsertInput

      public void setInsertInput(InsertInput insertInput)
      Setter for insertInput
    • getIsPreview

      public boolean getIsPreview()
      Getter for isPreview
    • setIsPreview

      public void setIsPreview(boolean isPreview)
      Setter for isPreview
    • withIsPreview

      public AbstractPreInsertCustomizer withIsPreview(boolean isPreview)
      Fluent setter for isPreview