public interface TrackableDomainMapperMemberSupport
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.Modifier and Type | Field and Description |
---|---|
static String |
REFLECTIVE_ERROR |
static String |
SYSTEM |
Modifier and Type | Method and Description |
---|---|
List<ChangeDetail> |
buildChangeDetailAfter(Object repositoryDomain,
List<ChangeDetail> details)
Populate the field values after mutation for a changed repository domain instance.
|
ChangeDetail |
buildChangeDetailBefore(ContextInfo contextInfo,
Trackable repositoryDomain,
String propertyName,
PropertyTypeInfo propertyTypeInfo,
String businessPropertyName)
Construct a
ChangeDetail 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 in
ContextState 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 the
Tracking information for a new change |
void |
buildTracking(Trackable domainInstance,
List<ChangeDetail> details)
Compile the
Tracking information for a new change. |
List<ChangeDetail> |
compileDirty(List<ChangeDetail> originalDetails,
boolean optimizeDirtyEmbeddedCollections)
Given a list of changes, determine which are actually dirty.
|
String |
getSerializedType(Type type)
Convert a
Type to a JavaType and serialize as a Base64 encoded string for
storage. |
Trackable |
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.
|
static final String REFLECTIVE_ERROR
static final String SYSTEM
Trackable handleDelete(Trackable repositoryDomain, ContextInfo contextInfo)
TrackableRepository
for more info
on persistence behavior based on context. This generally results in a cloned entity to
represent sandbox delete state.repositoryDomain
- The domain instance to inactivatecontextInfo
- The context information used to make tracking determinations relevant to
sandboxing and multitenant concerns.<P> void buildContextState(Trackable domain, P business, @Nullable ContextInfo contextInfo, @Nullable org.modelmapper.ModelMapper fromMeMapper)
ContextState
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).P
- The business domain typedomain
- The Trackable repository domainbusiness
- The business domain mapped from the repository domain. Iff the business
domain implements ContextStateAware
, calculated ContextState will be added.contextInfo
- The context information used to determine sandbox and multitenant state in
trackingfromMeMapper
- if domain
is ModelMapperMappable
, this should contain the
result of ModelMapperMappable.fromMe()
. This mapper is used to perform any
necessary conversion from persisted instances to business instances. If domain
is not ModelMapperMappable
, then this should be left null.IllegalContextStateException
- Thrown because of an error detected in the tracking
context state that prevents the ContextState
from being built. This is
usually due to errors detected in the domain's ChangeDetails
or
mismatching fields/field types between the tracking and business domains.ContextStateProcessingException
- Thrown when a non-state related error occurs when
attempting to build the ContextState
. This is usually related to building the
ContextState
for the business item's embedded collections. For examples,
ChangeDetail's
before or after values cannot be
deserialized once a change for a collection has been detected.List<ChangeDetail> compileDirty(List<ChangeDetail> originalDetails, boolean optimizeDirtyEmbeddedCollections)
If we should optimizeDirtyEmbeddedCollections
, then any details containing
collections will be optimized to remove non-dirty elements, and non-dirty fields of elements.
originalDetails
- unfiltered list of changesoptimizeDirtyEmbeddedCollections
- whether to include only dirty elements and element
fields of embedded collection detailsvoid buildTracking(ContextInfo contextInfo, Trackable domainInstance, List<ChangeDetail> details)
Tracking
information for a new changecontextInfo
- The context information used to determine sandbox and multitenant state in
trackingdomainInstance
- The repository domain instancedetails
- The details of the current changevoid buildTracking(Trackable domainInstance, List<ChangeDetail> details)
Tracking
information for a new change. This method does not take into
account any information harvested from a ContextInfo
instance.domainInstance
- The repository domain instancedetails
- The details of the current changeList<ChangeDetail> buildChangeDetailAfter(Object repositoryDomain, List<ChangeDetail> details)
repositoryDomain
- persistence-based domain instance that is being changeddetails
- list of change details for the fields that were impactedChangeDetail.setAfterValue(String)
modified
with the result from repositoryDomain
ChangeDetail buildChangeDetailBefore(ContextInfo contextInfo, Trackable repositoryDomain, String propertyName, PropertyTypeInfo propertyTypeInfo, String businessPropertyName)
ChangeDetail
instance that represents the value of soon-to-be dirty field
before the mutating change is applied.contextInfo
- The context information used to determine sandbox and multitenant state in
trackingrepositoryDomain
- The persisted domain instancepropertyName
- The name of the property being changedpropertyTypeInfo
- a PropertyTypeInfo
describing the changed field's typebusinessPropertyName
- The name of the property on the business domainString getSerializedType(Type type)
Type
to a JavaType
and serialize as a Base64 encoded string for
storage. Used for subsequent resurrection of serialized objects.type
- The java reflective typeJavaType
instanceCopyright © 2021. All rights reserved.