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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
allow the customizer to specify when it should be executed as part of the insert action.Nested classes/interfaces inherited from interface com.kingsrook.qqq.backend.core.actions.customizers.TableCustomizerInterface
TableCustomizerInterface.NotImplementedHereException
-
Field Summary
FieldsFields inherited from interface com.kingsrook.qqq.backend.core.actions.customizers.TableCustomizerInterface
LOG
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGetter for insertInputboolean
Getter for isPreviewpreInsert
(InsertInput insertInput, List<QRecord> records, boolean isPreview) custom actions before an insert takes place.void
setInsertInput
(InsertInput insertInput) Setter for insertInputvoid
setIsPreview
(boolean isPreview) Setter for isPreviewwhenToRunPreInsert
(InsertInput insertInput, boolean isPreview) withIsPreview
(boolean isPreview) Fluent setter for isPreviewMethods 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, postDelete, postInsert, postInsertOrUpdate, postQuery, postUpdate, preDelete, preInsertOrUpdate, preUpdate
-
Field Details
-
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 interfaceTableCustomizerInterface
- Throws:
QException
-
whenToRunPreInsert
public AbstractPreInsertCustomizer.WhenToRun whenToRunPreInsert(InsertInput insertInput, boolean isPreview) - Specified by:
whenToRunPreInsert
in interfaceTableCustomizerInterface
-
apply
- Throws:
QException
-
getWhenToRun
-
getInsertInput
Getter for insertInput -
setInsertInput
Setter for insertInput -
getIsPreview
public boolean getIsPreview()Getter for isPreview -
setIsPreview
public void setIsPreview(boolean isPreview) Setter for isPreview -
withIsPreview
Fluent setter for isPreview
-