Class AbstractPreDeleteCustomizer

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

public abstract class AbstractPreDeleteCustomizer extends Object implements TableCustomizerInterface
Abstract class that a table can specify an implementation of, to provide custom actions before a delete 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 (which the DeleteAction would look up based on the inputs to the delete action), and look at their values: - possibly adding Errors (`addError`) or Warnings (`addWarning`) to the records - possibly throwing an exception - if you really don't want the delete operation to continue. - doing "whatever else" you may want to do. - returning the list of records (can be the input list) - this is how errors and warnings are propagated to the DeleteAction. Note that any records with an error will NOT proceed to the backend's delete interface - but those with warnings will. Note that the full deleteInput is available as a field in this class.
  • Field Details

    • deleteInput

      protected DeleteInput deleteInput
    • isPreview

      protected boolean isPreview
  • Constructor Details

    • AbstractPreDeleteCustomizer

      public AbstractPreDeleteCustomizer()
  • Method Details

    • preDelete

      public List<QRecord> preDelete(DeleteInput deleteInput, List<QRecord> records, boolean isPreview) throws QException
      Description copied from interface: TableCustomizerInterface
      Custom actions before a delete takes place. It's important for implementations to be aware of the isPreview param, 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 (which the DeleteAction would look up based on the inputs to the delete action), and look at their values: - possibly adding Errors (`addError`) or Warnings (`addWarning`) to the records - possibly throwing an exception - if you really don't want the delete operation to continue. - doing "whatever else" you may want to do. - returning the list of records (can be the input list) - this is how errors and warnings are propagated to the DeleteAction. Note that any records with an error will NOT proceed to the backend's delete interface - but those with warnings will.
      Specified by:
      preDelete in interface TableCustomizerInterface
      Throws:
      QException
    • apply

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

      public DeleteInput getDeleteInput()
      Getter for deleteInput
    • setDeleteInput

      public void setDeleteInput(DeleteInput deleteInput)
      Setter for deleteInput
    • getIsPreview

      public boolean getIsPreview()
      Getter for isPreview
    • setIsPreview

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

      public AbstractPreDeleteCustomizer withIsPreview(boolean isPreview)
      Fluent setter for isPreview