public class ModelMapperDomainMapperMember extends Object implements DomainMapperMember
DomainMapperMember
implementation utilizes the ModelMapper
library as the
method of mapping between repository domain and business domain. The approach for informing the
mapping is taken from ModelMapperMappable
implementing entities. As such,
repositoryDomain instances that do not implement ModelMapperMappable will not be transformed by
this class. The expectation would be that another DomainMapperMember instance would be registered
and responsible for transformation. Additionally, this class will also maintain tracking
information for repository domain implementing the Trackable
interface. In the absence of
the Trackable interface, no maintenance of tracking information will be performed.Constructor and Description |
---|
ModelMapperDomainMapperMember(TrackableDomainMapperMemberSupport trackableSupport,
TrackableBehaviorUtil trackableBehaviorUtil) |
Modifier and Type | Method and Description |
---|---|
protected <D extends Trackable> |
buildDetailsBefore(D repositoryDomain,
ContextInfo contextInfo,
org.modelmapper.TypeMap<?,?> repositoryTypeMap) |
protected void |
buildNameToTypeMap(Map<org.springframework.data.util.Pair<String,String>,PropertyTypeInfo> repositoryNameToType,
Map.Entry<String,?> entry)
Build up the repositoryNameToType structure mapping destination and source property name,
combined with the destination property type.
|
<D> D |
deleteMap(D repositoryDomain,
ContextInfo contextInfo)
In cases where deletion actually results in a modified state to persist (e.g.
|
org.modelmapper.ModelMapper |
fabricateFromMe(Object projection,
Object entity)
Derive a
ModelMapper based on the starting entity and target projection instances. |
org.modelmapper.ModelMapper |
fabricateToMe(Object projection,
Object entity,
boolean allowNull)
Derive a
ModelMapper based on the starting projection and target entity instances. |
<D> D |
fromBusinessDomain(Object businessDomain,
D repositoryDomain,
ContextInfo contextInfo)
Map and return a populated repository domain instance, based on information provided in a
business domain.
|
<P> P |
fromRepositoryDomain(Object repositoryDomain,
P businessDomain,
ContextInfo contextInfo)
Map and return a populated business domain instance, based on information provided in a
repository domain instance.
|
String |
getDataRoutePartition() |
Map<String,org.modelmapper.ModelMapper> |
getMappers() |
protected <D extends Trackable> |
isCatalogOrSandboxTrackable(D repositoryDomain) |
protected boolean |
isCollectionType(Class<?> fieldType)
Determines whether the given
fieldType from a PropertyMapping is a
known type of collection field. |
protected boolean |
isModelMapperAutoConfigurationDisabled(Object repositoryDomain) |
protected <D,P> D |
mapToRepositoryDomain(D repositoryDomain,
P businessDomain,
ContextInfo contextInfo,
org.modelmapper.ModelMapper mapper) |
protected <D extends Trackable,P> |
mapWithTracking(D repositoryDomain,
P modifications,
ContextInfo contextInfo,
org.modelmapper.ModelMapper mapper)
During the mapping operation for properties between the payload and the domain, this will
examine the before and after state and compile
ChangeDetail instances to include in
the Tracking state. |
<D,P> D |
modifyMap(D repositoryDomain,
P businessDomain,
ContextInfo contextInfo,
boolean allowNull)
Perform a mapping operation from business domain instance to persistence specific instance,
presumably modifying the state of the persistence specific instance.
|
protected <D extends Trackable> |
shouldBuildChangeDetails(D repositoryDomain,
ContextInfo contextInfo)
Determine if dirty change details should be built for this domain.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getOrder
getBusinessDomainType
public ModelMapperDomainMapperMember(TrackableDomainMapperMemberSupport trackableSupport, TrackableBehaviorUtil trackableBehaviorUtil)
public String getDataRoutePartition()
getDataRoutePartition
in interface com.broadleafcommerce.common.extension.data.DataRoutePartitionAware
public <D> D fromBusinessDomain(Object businessDomain, D repositoryDomain, ContextInfo contextInfo)
DomainMapperMember
fromBusinessDomain
in interface DomainMapperMember
D
- The repository domain typebusinessDomain
- The business instance containing the relevant property informationrepositoryDomain
- The repository specific instance to affect and returncontextInfo
- The context information used to make tracking determinations relevant to
sandboxing and multitenant concerns. See TrackableRepository
for more info on
persistence behavior based on context.public <P> P fromRepositoryDomain(Object repositoryDomain, P businessDomain, ContextInfo contextInfo)
DomainMapperMember
fromRepositoryDomain
in interface DomainMapperMember
P
- The business domain typerepositoryDomain
- The repository domain instance containing the relevant property
informationbusinessDomain
- The business domain instance to affect and returncontextInfo
- The context information used to make tracking determinations relevant to
sandboxing and multitenant concerns. See TrackableRepository
for more info on
persistence behavior based on context.public <D,P> D modifyMap(D repositoryDomain, P businessDomain, ContextInfo contextInfo, boolean allowNull)
DomainMapper
modifyMap
in interface DomainMapper
D
- The repository domain typeP
- The business domain typerepositoryDomain
- The persistence domain instance to modifybusinessDomain
- The business instance containing changes to map to the repository
domaincontextInfo
- The context information used to make tracking determinations relevant to
sandboxing and multitenant concerns. See TrackableRepository
for more info on
persistence behavior based on context.allowNull
- Whether or not null values in properties in the payload instance should be
ignored during the mapping operation.public <D> D deleteMap(D repositoryDomain, ContextInfo contextInfo)
DomainMapper
deleteMap
in interface DomainMapper
D
- The repository domain typerepositoryDomain
- The persistence domain instance to inactivatecontextInfo
- The context information used to make tracking determinations relevant to
sandboxing and multitenant concerns.protected boolean isModelMapperAutoConfigurationDisabled(Object repositoryDomain)
protected <D,P> D mapToRepositoryDomain(D repositoryDomain, P businessDomain, ContextInfo contextInfo, org.modelmapper.ModelMapper mapper)
public org.modelmapper.ModelMapper fabricateToMe(Object projection, Object entity, boolean allowNull)
ModelMapper
based on the starting projection and target entity instances.
Take into account entity extensions that do not implement ModelMapperMappable
with
calculated mapping.projection
- The projection instance from which to pull informationentity
- The starting entity instance to map toallowNull
- Whether or not to allow null mappingpublic org.modelmapper.ModelMapper fabricateFromMe(Object projection, Object entity)
ModelMapper
based on the starting entity and target projection instances.
Take into account entity extensions that do not implement ModelMapperMappable
with
calculated mapping.projection
- The projection instance to map toentity
- The starting entity instance from which to pull informationprotected <D extends Trackable,P> boolean mapWithTracking(D repositoryDomain, P modifications, ContextInfo contextInfo, org.modelmapper.ModelMapper mapper)
ChangeDetail
instances to include in
the Tracking
state.D
- The domain typeP
- The payload typerepositoryDomain
- The persistence-based domain instance that is being changedmodifications
- The payload instancecontextInfo
- The context information used to determine sandbox and multitenant state in
trackingmapper
- The mapping engine used to transfer values between payload and domainrepositoryDomain
was modifiedprotected <D extends Trackable> boolean shouldBuildChangeDetails(D repositoryDomain, ContextInfo contextInfo)
This must be performed after mapping, since information to determine the trackable behavior of the domain may not be available prior to mapping.
D
- the type of the domainrepositoryDomain
- the domain to possibly build dirty change details forcontextInfo
- The context information used to determine sandbox and multitenant state in
trackingprotected <D extends Trackable> boolean isCatalogOrSandboxTrackable(D repositoryDomain)
protected <D extends Trackable> List<ChangeDetail> buildDetailsBefore(D repositoryDomain, ContextInfo contextInfo, org.modelmapper.TypeMap<?,?> repositoryTypeMap) throws IllegalAccessException
IllegalAccessException
protected void buildNameToTypeMap(Map<org.springframework.data.util.Pair<String,String>,PropertyTypeInfo> repositoryNameToType, Map.Entry<String,?> entry)
repositoryNameToType
- The structure to build up. The key consists of a Pair, whose
first value is the destination property name and whose second value is the source
property name. The value of the map is the destination property type.entry
- The mapping information harvested from the TypeMap
.protected boolean isCollectionType(Class<?> fieldType)
fieldType
from a PropertyMapping
is a
known type of collection field. The default known types are array, Iterable
, and
Map
.fieldType
- The Class
of a field specified by a PropertyMapping
Copyright © 2021. All rights reserved.