Interface TrackableDomainMapperMemberSupport
- All Known Implementing Classes:
DefaultTrackableDomainMapperMemberSupport
public interface TrackableDomainMapperMemberSupport
Exposes the functionality necessary to support maintenance of
Trackable
domain instances.
The intent is for DomainMapperMember
classes to inject this bean in order to benefit from
tracking maintenance during mapping. This separates the ability to track changes from the method
of mapping data between the repository domain and the business domain. DomainMapperMembers who
want to conditionally support Tracking maintenance should gate access to these support methods
based on whether or not the entity being process supports Trackable.- Author:
- Jeff Fischer
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuildChangeDetailAfter
(Object repositoryDomain, List<ChangeDetail> details) Populate the field values after mutation for a changed repository domain instance.buildChangeDetailBefore
(ContextInfo contextInfo, Trackable repositoryDomain, String propertyName, PropertyTypeInfo propertyTypeInfo, String businessPropertyName) Construct aChangeDetail
instance that represents the value of soon-to-be dirty field before the mutating change is applied.<P> void
buildContextState
(Trackable domain, P business, ContextInfo contextInfo, org.modelmapper.ModelMapper fromMeMapper) Add inContextState
information to the business domain that can be inspected for additional metadata around the entity in relation to the context of the requester.void
buildTracking
(ContextInfo contextInfo, Trackable domainInstance, List<ChangeDetail> details) Compile theTracking
information for a new changevoid
buildTracking
(Trackable domainInstance, List<ChangeDetail> details) Compile theTracking
information for a new change.compileDirty
(List<ChangeDetail> originalDetails, boolean optimizeDirtyEmbeddedCollections) Given a list of changes, determine which are actually dirty.getSerializedType
(Type type) Convert aType
to aJavaType
and serialize as a Base64 encoded string for storage.handleDelete
(Trackable repositoryDomain, ContextInfo contextInfo) Perform a mapping operation that will either create a special delete sandbox state for a domain instance, or will archive an instance.boolean
isMappingResetRequired
(Trackable domainInstance, ContextInfo contextInfo) Whether or not the id will be reset during modify or delete mapping.
-
Field Details
-
REFLECTIVE_ERROR
- See Also:
-
SYSTEM
- See Also:
-
-
Method Details
-
handleDelete
Perform a mapping operation that will either create a special delete sandbox state for a domain instance, or will archive an instance. SeeTrackableRepository
for more info on persistence behavior based on context. This generally results in a cloned entity to represent sandbox delete state.- Parameters:
repositoryDomain
- The domain instance to inactivatecontextInfo
- The context information used to make tracking determinations relevant to sandboxing and multitenant concerns.- Returns:
- The domain state resulting from the operation (e.g. archived or sandbox delete state)
-
buildContextState
<P> void buildContextState(Trackable domain, P business, @Nullable ContextInfo contextInfo, @Nullable org.modelmapper.ModelMapper fromMeMapper) Add inContextState
information to the business domain that can be inspected for additional metadata around the entity in relation to the context of the requester. This information can be used to make determination around mutability, as well as details around the nature of field change state (if any).- Type Parameters:
P
- The business domain type- Parameters:
domain
- The Trackable repository domainbusiness
- The business domain mapped from the repository domain. Iff the business domain implementsContextStateAware
, calculated ContextState will be added.contextInfo
- The context information used to determine sandbox and multitenant state in trackingfromMeMapper
- ifdomain
isModelMapperMappable
, this should contain the result ofModelMapperMappable.fromMe()
. This mapper is used to perform any necessary conversion from persisted instances to business instances. Ifdomain
is notModelMapperMappable
, then this should be left null.- Throws:
IllegalContextStateException
- Thrown because of an error detected in the tracking context state that prevents theContextState
from being built. This is usually due to errors detected in the domain'sChangeDetails
or mismatching fields/field types between the tracking and business domains.ContextStateProcessingException
- Thrown when a non-state related error occurs when attempting to build theContextState
. This is usually related to building theContextState
for the business item's embedded collections. For examples,- when invoking (not finding) the correct accessor of a collection field on the businessItem encounters an error.
- when a
ChangeDetail's
before or after values cannot be deserialized once a change for a collection has been detected.
-
compileDirty
List<ChangeDetail> compileDirty(List<ChangeDetail> originalDetails, boolean optimizeDirtyEmbeddedCollections) Given a list of changes, determine which are actually dirty.If we should
optimizeDirtyEmbeddedCollections
, then any details containing collections will be optimized to remove non-dirty elements, and non-dirty fields of elements.- Parameters:
originalDetails
- unfiltered list of changesoptimizeDirtyEmbeddedCollections
- whether to include only dirty elements and element fields of embedded collection details- Returns:
- filtered list of changes containing only dirty changes.
-
buildTracking
Compile theTracking
information for a new change- Parameters:
contextInfo
- The context information used to determine sandbox and multitenant state in trackingdomainInstance
- The repository domain instancedetails
- The details of the current change
-
isMappingResetRequired
Whether or not the id will be reset during modify or delete mapping.- Parameters:
domainInstance
- The repository domain instance for which mapping will occurcontextInfo
- The context information used to determine sandbox and multitenant state in tracking- Returns:
- Whether or not the id will be reset during modify or delete mapping
-
buildTracking
Compile theTracking
information for a new change. This method does not take into account any information harvested from aContextInfo
instance.- Parameters:
domainInstance
- The repository domain instancedetails
- The details of the current change
-
buildChangeDetailAfter
Populate the field values after mutation for a changed repository domain instance.- Parameters:
repositoryDomain
- persistence-based domain instance that is being changeddetails
- list of change details for the fields that were impacted- Returns:
- the updated change details with
ChangeDetail.setAfterValue(String)
modified with the result fromrepositoryDomain
-
buildChangeDetailBefore
ChangeDetail buildChangeDetailBefore(ContextInfo contextInfo, Trackable repositoryDomain, String propertyName, PropertyTypeInfo propertyTypeInfo, String businessPropertyName) Construct aChangeDetail
instance that represents the value of soon-to-be dirty field before the mutating change is applied.- Parameters:
contextInfo
- The context information used to determine sandbox and multitenant state in trackingrepositoryDomain
- The persisted domain instancepropertyName
- The name of the property being changedpropertyTypeInfo
- aPropertyTypeInfo
describing the changed field's typebusinessPropertyName
- The name of the property on the business domain- Returns:
- The resulting change detail for the dirty field
-
getSerializedType
Convert aType
to aJavaType
and serialize as a Base64 encoded string for storage. Used for subsequent resurrection of serialized objects.- Parameters:
type
- The java reflective type- Returns:
- Base64 encoded string result of serializing a
JavaType
instance
-