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`).
-
Nested Class Summary
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 TypeMethodDescriptionboolean
Getter for isPreviewprotected Map
<Serializable, QRecord> Getter for updateInputpreUpdate
(UpdateInput updateInput, List<QRecord> records, boolean isPreview, Optional<List<QRecord>> oldRecordList) custom actions before an update takes place.void
setIsPreview
(boolean isPreview) Setter for isPreviewvoid
setOldRecordList
(List<QRecord> oldRecordList) void
setUpdateInput
(UpdateInput updateInput) Setter for updateInputwithIsPreview
(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, preInsert, preInsertOrUpdate, whenToRunPreInsert
-
Field Details
-
updateInput
-
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 interfaceTableCustomizerInterface
- Throws:
QException
-
apply
- Throws:
QException
-
getUpdateInput
Getter for updateInput -
setUpdateInput
Setter for updateInput -
setOldRecordList
-
getOldRecordList
-
getOldRecordMap
-
getIsPreview
public boolean getIsPreview()Getter for isPreview -
setIsPreview
public void setIsPreview(boolean isPreview) Setter for isPreview -
withIsPreview
Fluent setter for isPreview
-