Class AbstractPreUpdateCustomizer

java.lang.Object
com.kingsrook.qqq.backend.core.actions.customizers.AbstractPreUpdateCustomizer
All Implemented Interfaces:
TableCustomizerInterface
Direct Known Subclasses:
HelpContentPreUpdateCustomizer

public abstract class AbstractPreUpdateCustomizer extends Object implements TableCustomizerInterface
Abstract class that a table can specify an implementation of, to provide custom actions before an update 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 update 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 update 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 updateInput is available as a field in this class, and the "old records" (e.g., with values freshly fetched from the backend) will be available (if the backend supports it) - both as a list (`getOldRecordList`) and as a memoized (by this class) map of primaryKey to record (`getOldRecordMap`).
  • Field Details

    • updateInput

      protected UpdateInput updateInput
    • oldRecordList

      protected List<QRecord> oldRecordList
    • isPreview

      protected boolean isPreview
  • Constructor Details

    • AbstractPreUpdateCustomizer

      public AbstractPreUpdateCustomizer()
  • Method Details

    • preUpdate

      public List<QRecord> preUpdate(UpdateInput updateInput, List<QRecord> records, boolean isPreview, Optional<List<QRecord>> oldRecordList) throws QException
      Description copied from interface: TableCustomizerInterface
      custom actions before an update 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 update 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 update 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, "old records" (e.g., with values freshly fetched from the backend) will be available (if the backend supports it)
      Specified by:
      preUpdate in interface TableCustomizerInterface
      Throws:
      QException
    • apply

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

      public UpdateInput getUpdateInput()
      Getter for updateInput
    • setUpdateInput

      public void setUpdateInput(UpdateInput updateInput)
      Setter for updateInput
    • setOldRecordList

      public void setOldRecordList(List<QRecord> oldRecordList)
    • getOldRecordList

      public List<QRecord> getOldRecordList()
    • getOldRecordMap

      protected Map<Serializable,QRecord> getOldRecordMap()
    • getIsPreview

      public boolean getIsPreview()
      Getter for isPreview
    • setIsPreview

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

      public AbstractPreUpdateCustomizer withIsPreview(boolean isPreview)
      Fluent setter for isPreview