protected class RecordBuffer.ValidationHelper
extends java.lang.Object
This class also ensures uncommitted updates to permanent tables are shared across contexts via the dirty share manager.
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.Object> |
cumulativeDirtyProps
Properties made dirty since current record was loaded
|
private boolean |
failed
Has the record failed validation since last touched?
|
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
nonUniqueIndexMap
Map of non-unique index names to ordered lists of property names
|
private boolean |
shared
Has the record's state change yet been shared across sessions?
|
private boolean |
touched
Has the current record been modified since it was loaded?
|
private java.util.Set<java.lang.String> |
uncheckedNonNullables
Non-nullable props requiring validation for a transient record
|
private java.util.Set<java.lang.String> |
uncheckedUniqueIndexes
Unique indexes still requiring validation for a transient record
|
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
uniqueIndexMap
Map of unique index names to ordered lists of property names
|
private DMOValidator |
validator
Object which validates the current record
|
Constructor and Description |
---|
ValidationHelper()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
private ValidationData |
createValidationData(boolean share)
Gather validation parameters, including dirty unique indexes, dirty
non-unique indexes, dirty property names, whether to share updates
via the dirty share manager, and whether a dirty insert is required.
|
(package private) boolean |
isAnyIndexFullyDirty()
Report whether any unique or non-unique index has had all of its component fields
changed.
|
(package private) boolean |
isFailed()
Report whether the current record has failed validation since last touched.
|
protected java.util.List<java.lang.String> |
listDirtyIndexes(boolean unique,
boolean fullMatch,
boolean cumulative)
Cross reference dirty DMO properties with indexes containing them, creating a list of
indexes which have been updated.
|
(package private) boolean |
prevalidate(java.lang.String property,
BaseDataType value)
Prevalidate a property which is about to be stored into a DMO using
the given setter method.
|
(package private) void |
reset(Persistable dmo,
boolean newlyCreated)
Reset the state variables which track whether the given record has
been modified (any property), and which unique indexes and
non-nullable properties remain to be validated.
|
(package private) void |
setTouched()
Change the state of the currently tracked DMO to dirty.
|
private void |
updateSharedFlag(ValidationData vData)
Update the shared flag based on the validation data just used to
validate the current record.
|
private void |
validate(ValidationData vData,
boolean clear)
Validate the record currently stored in this buffer.
|
(package private) void |
validateDirty()
Perform validation of those unique constraints and non-nullable
properties of the buffer's current record, which are dirty due to
updates to the DMO.
|
(package private) void |
validateFull(Persistable dmo,
boolean share)
Perform a full validation (all unique constraints and non-nullable
properties) of the given record.
|
(package private) void |
validateRemaining()
Perform validation of any unique constraints and non-nullable properties of the buffer's
current record, which have not already been validated since this record was loaded or
created.
|
(package private) boolean |
wasShared()
Indicate whether the current record has had its state changes shared
with other sessions via the dirty share manager, since it was first created.
|
(package private) boolean |
wasTouched()
Indicate whether the current record has been been modified since it was loaded.
|
private final java.util.Map<java.lang.String,java.util.List<java.lang.String>> uniqueIndexMap
private final java.util.Map<java.lang.String,java.util.List<java.lang.String>> nonUniqueIndexMap
private final DMOValidator validator
private java.util.Set<java.lang.String> uncheckedUniqueIndexes
private java.util.Set<java.lang.String> uncheckedNonNullables
private java.util.Map<java.lang.String,java.lang.Object> cumulativeDirtyProps
private boolean touched
private boolean shared
private boolean failed
protected java.util.List<java.lang.String> listDirtyIndexes(boolean unique, boolean fullMatch, boolean cumulative)
unique
- If true
, only unique indexes are checked. If false
, only
non-unique indexes are checked.fullMatch
- If true
every property in an index must be dirty for that index to be
considered dirty. If false
, any dirty property in an index is enough
to consider that index dirty.cumulative
- Only in the case of non-unique indexes. If true
, collect all indexes
that were marked dirty since the record was loaded. If false
, only
indexes marked dirty since the last validation/share.boolean isAnyIndexFullyDirty()
true
if any index has been fully updated, else false
.void reset(Persistable dmo, boolean newlyCreated)
dmo
- DMO being tracked for validation. If null
the index and property variables will be set to empty sets.newlyCreated
- true
if the DMO is newly created, otherwise
false
.void setTouched()
boolean wasTouched()
true
if the record has been changed.boolean wasShared()
true
if the record's changes have been shared, else false
.boolean isFailed()
true
if validation has failed since the last modification to the
record, else false
.void validateFull(Persistable dmo, boolean share) throws ValidationException, PersistenceException
dmo
- DMO to be validated.share
- Whether or not to share information about dirty properties
with other contexts via the dirty share manager.ValidationException
- if the DMO state fails any unique or non-nullable constraint
check.PersistenceException
- if there is any error gathering index metadata or a database
error performing validation.void validateRemaining() throws ValidationException, PersistenceException
ValidationException
- if the DMO state fails any unique or non-nullable constraint check.PersistenceException
- if there is a database error performing validation.StopConditionException
- if the size of a index key is found greater than allowable limits.void validateDirty() throws ValidationException, PersistenceException
If validation fails, dirty properties are reverted to their previous state.
ValidationException
- if the DMO state fails any unique or non-nullable constraint
check.PersistenceException
- if there is a database error performing validation.boolean prevalidate(java.lang.String property, BaseDataType value) throws ValidationException, PersistenceException
dirtyProps
map.
If this method returns normally, validation was successful.
property
- DMO property which requires validation. May not be
null
.value
- Value about to be applied to the given property.true
if all unique indexes and non-nullable
properties have been validated once the given property has
been validated, else false
.ValidationException
- if validation on the buffer fails.PersistenceException
- if any error occurs querying the database during validation.private void validate(ValidationData vData, boolean clear) throws ValidationException, PersistenceException
vData
object passed to
this method. Updates which affect any indexes will be shared via the
dirty share manager.vData
- Validation data which determines which properties and
indexes are validated and shared.clear
- Flag indicating whether the RecordBuffer.unreportedChanges
list should be cleared on a validation error.ValidationException
- if validation on the buffer fails.PersistenceException
- if any error occurs querying the database during validation.StopConditionException
- if the size of a index key is found greater than allowable limits.private ValidationData createValidationData(boolean share)
share
- Whether to share updates via the dirty share manager.private void updateSharedFlag(ValidationData vData)
vData
- Validation data which determines which properties and
indexes are validated and shared.