Class DefaultDomainMapperManager
- java.lang.Object
-
- com.broadleafcommerce.data.tracking.core.mapping.DefaultDomainMapperManager
-
- All Implemented Interfaces:
DomainMapper
,DomainMapperManager
,PostMapper
public class DefaultDomainMapperManager extends Object implements DomainMapperManager
- Author:
- Jeff Fischer
-
-
Constructor Summary
Constructors Constructor Description DefaultDomainMapperManager(List<DomainMapperMember> members, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.common.extension.data.DataRouteReference reference)
DefaultDomainMapperManager(List<DomainMapperMember> members, List<PostMapperMember> postMembers, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.common.extension.data.DataRouteReference reference)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <P> P
convertFromPersistentDomain(Object domain, ContextInfo contextInfo)
Similar toDomainMapperManager.fromRepositoryDomain(Object, Class, ContextInfo)
, but doesn't require the caller to know the business domain type.<D> D
deleteMap(D repositoryDomain, ContextInfo contextInfo)
In cases where deletion actually results in a modified state to persist (e.g.<D> D
fromBusinessDomain(Object businessDomain, Class<D> repositoryDomainType, ContextInfo contextInfo)
Map and return a populated repository domain class instance, based on information provided in a business domain instance.<P> P
fromRepositoryDomain(BusinessTypeAware repositoryDomain, ContextInfo contextInfo)
Map and return a populated business domain instance, based on information provided in a repository domain instance.<P> P
fromRepositoryDomain(Object repositoryDomain, Class<P> businessDomainType, ContextInfo contextInfo)
Map and return a populated business domain instance, based on information provided in a repository domain instance.<P> P
fromRepositoryDomainByExample(Object repositoryDomain, P example, ContextInfo contextInfo)
Map and return a populated business domain instance, based on information provided in a repository domain instance.<P> Class<P>
getBusinessDomainType(Object repositoryDomain)
Ascertain the correct business domain type based on an instance of the repository domaincom.broadleafcommerce.common.extension.TypeFactory
getTypeFactory()
<D,P>
DmodifyMap(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.<P> P
process(Object repositoryDomain, ContextInfo contextInfo)
Execute both theDomainMapperMember.fromRepositoryDomain(Object, Object, ContextInfo)
pipeline andPostMapper.transform(Object, Object, ContextInfo)
pipeline in a single call.<P> List<P>
process(List<?> repositoryDomain, ContextInfo contextInfo)
Execute both theDomainMapperMember.fromRepositoryDomain(Object, Object, ContextInfo)
pipeline andPostMapper.transform(List, List, ContextInfo)
pipeline in a single call.<P> Stream<P>
process(Stream<?> repositoryDomain, ContextInfo contextInfo)
Execute both theDomainMapperMember.fromRepositoryDomain(Object, Object, ContextInfo)
pipeline andPostMapper.transform(List, List, ContextInfo)
pipeline in a single call.<P> org.springframework.data.domain.Page<P>
process(org.springframework.data.domain.Page<?> repositoryDomain, ContextInfo contextInfo)
Execute both theDomainMapperMember.fromRepositoryDomain(Object, Object, ContextInfo)
pipeline andPostMapper.transform(List, List, ContextInfo)
pipeline in a single call.<P,D>
voidtransform(List<P> projections, List<D> entities, ContextInfo contextInfo)
Perform any required modifications to the list of projections.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.broadleafcommerce.data.tracking.core.mapping.PostMapper
transform
-
-
-
-
Constructor Detail
-
DefaultDomainMapperManager
public DefaultDomainMapperManager(List<DomainMapperMember> members, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.common.extension.data.DataRouteReference reference)
-
DefaultDomainMapperManager
public DefaultDomainMapperManager(List<DomainMapperMember> members, List<PostMapperMember> postMembers, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.common.extension.data.DataRouteReference reference)
-
-
Method Detail
-
fromBusinessDomain
public <D> D fromBusinessDomain(Object businessDomain, Class<D> repositoryDomainType, ContextInfo contextInfo)
Description copied from interface:DomainMapperManager
Map and return a populated repository domain class instance, based on information provided in a business domain instance. Usually delegates toDomainMapperMember.fromBusinessDomain(Object, Object, ContextInfo)
.- Specified by:
fromBusinessDomain
in interfaceDomainMapperManager
- Type Parameters:
D
- The repository domain type- Parameters:
businessDomain
- The business instance containing the relevant property informationrepositoryDomainType
- The class defining the persisted domain type to returncontextInfo
- The context information used to make tracking determinations relevant to sandboxing and multitenant concerns. SeeTrackableRepository
for more info on persistence behavior based on context.- Returns:
- The populated repository domain instance. Should return null if no action taken.
-
fromRepositoryDomain
public <P> P fromRepositoryDomain(Object repositoryDomain, Class<P> businessDomainType, ContextInfo contextInfo)
Description copied from interface:DomainMapperManager
Map and return a populated business domain instance, based on information provided in a repository domain instance. Usually delegates toDomainMapperMember.fromRepositoryDomain(Object, Object, ContextInfo)
.- Specified by:
fromRepositoryDomain
in interfaceDomainMapperManager
- Type Parameters:
P
- The business domain type- Parameters:
repositoryDomain
- The persistence-based domain instance containing the relevant property informationbusinessDomainType
- The class defining the business domain type to returncontextInfo
- The context information used to make tracking determinations relevant to sandboxing and multitenant concerns. SeeTrackableRepository
for more info on persistence behavior based on context.- Returns:
- The populated business domain instance. Should return null if no action taken.
-
process
public <P> org.springframework.data.domain.Page<P> process(org.springframework.data.domain.Page<?> repositoryDomain, ContextInfo contextInfo)
Description copied from interface:DomainMapperManager
Execute both theDomainMapperMember.fromRepositoryDomain(Object, Object, ContextInfo)
pipeline andPostMapper.transform(List, List, ContextInfo)
pipeline in a single call.- Specified by:
process
in interfaceDomainMapperManager
- Type Parameters:
P
- The projection type- Parameters:
repositoryDomain
- The originating repository domain instances in the form of a page of content.contextInfo
- The context information used to make tracking determinations relevant to sandboxing and multitenant concerns. SeeTrackableRepository
for more info on persistence behavior based on context.- Returns:
- The mapped and transformed page of projection instances
-
process
public <P> List<P> process(List<?> repositoryDomain, ContextInfo contextInfo)
Description copied from interface:DomainMapperManager
Execute both theDomainMapperMember.fromRepositoryDomain(Object, Object, ContextInfo)
pipeline andPostMapper.transform(List, List, ContextInfo)
pipeline in a single call.- Specified by:
process
in interfaceDomainMapperManager
- Type Parameters:
P
- The projection type- Parameters:
repositoryDomain
- The originating repository domain instances in the form of a listcontextInfo
- The context information used to make tracking determinations relevant to sandboxing and multitenant concerns. SeeTrackableRepository
for more info on persistence behavior based on context.- Returns:
- The mapped and transformed list of projection instances
-
process
public <P> Stream<P> process(Stream<?> repositoryDomain, ContextInfo contextInfo)
Description copied from interface:DomainMapperManager
Execute both theDomainMapperMember.fromRepositoryDomain(Object, Object, ContextInfo)
pipeline andPostMapper.transform(List, List, ContextInfo)
pipeline in a single call.- Specified by:
process
in interfaceDomainMapperManager
- Type Parameters:
P
- The projection type- Parameters:
repositoryDomain
- The originating repository domain instances in the form of a streamcontextInfo
- The context information used to make tracking determinations relevant to sandboxing and multitenant concerns. SeeTrackableRepository
for more info on persistence behavior based on context.- Returns:
- The mapped and transformed stream of projection instances
-
process
public <P> P process(Object repositoryDomain, ContextInfo contextInfo)
Description copied from interface:DomainMapperManager
Execute both theDomainMapperMember.fromRepositoryDomain(Object, Object, ContextInfo)
pipeline andPostMapper.transform(Object, Object, ContextInfo)
pipeline in a single call.- Specified by:
process
in interfaceDomainMapperManager
- Type Parameters:
P
- The projection type- Parameters:
repositoryDomain
- The originating repository domain instancecontextInfo
- The context information used to make tracking determinations relevant to sandboxing and multitenant concerns. SeeTrackableRepository
for more info on persistence behavior based on context.- Returns:
- The mapped and transformed projection
-
transform
public <P,D> void transform(List<P> projections, @Nullable List<D> entities, @Nullable ContextInfo contextInfo)
Description copied from interface:PostMapper
Perform any required modifications to the list of projections. This represents an opportunity to transform the entire list of projections in bulk, or perform bulk related queries.- Specified by:
transform
in interfacePostMapper
- Type Parameters:
P
- The projection typeD
- The repository instance type- Parameters:
projections
- List of projections to transform.entities
- The original list of repository entities from which the projection list was derived.contextInfo
- The context information used to make tracking determinations relevant to sandboxing and multitenant concerns. SeeTrackableRepository
for more info on persistence behavior based on context.
-
fromRepositoryDomainByExample
public <P> P fromRepositoryDomainByExample(Object repositoryDomain, P example, ContextInfo contextInfo)
Description copied from interface:DomainMapperManager
Map and return a populated business domain instance, based on information provided in a repository domain instance. Usually delegates toDomainMapperMember.fromRepositoryDomain(Object, Object, ContextInfo)
.- Specified by:
fromRepositoryDomainByExample
in interfaceDomainMapperManager
- Type Parameters:
P
- The business domain type- Parameters:
repositoryDomain
- The persistence-based domain instance containing the relevant property informationexample
- The business domain instancecontextInfo
- The context information used to make tracking determinations relevant to sandboxing and multitenant concerns. SeeTrackableRepository
for more info on persistence behavior based on context.- Returns:
- The populated business domain instance. Should return null if no action taken.
-
fromRepositoryDomain
public <P> P fromRepositoryDomain(BusinessTypeAware repositoryDomain, ContextInfo contextInfo)
Description copied from interface:DomainMapperManager
Map and return a populated business domain instance, based on information provided in a repository domain instance. Usually delegates toDomainMapperMember.fromRepositoryDomain(Object, Object, ContextInfo)
.- Specified by:
fromRepositoryDomain
in interfaceDomainMapperManager
- Type Parameters:
P
- The business domain type- Parameters:
repositoryDomain
- The persistence-based domain instance containing the relevant property information. This instance can produce the business domain type.contextInfo
- The context information used to make tracking determinations relevant to sandboxing and multitenant concerns. SeeTrackableRepository
for more info on persistence behavior based on context.- Returns:
- The populated business domain instance. Should return null if no action taken.
-
modifyMap
public <D,P> D modifyMap(D repositoryDomain, P businessDomain, ContextInfo contextInfo, boolean allowNull)
Description copied from interface:DomainMapper
Perform a mapping operation from business domain instance to persistence specific instance, presumably modifying the state of the persistence specific instance.- Specified by:
modifyMap
in interfaceDomainMapper
- Type Parameters:
D
- The repository domain typeP
- The business domain type- Parameters:
repositoryDomain
- 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. SeeTrackableRepository
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.- Returns:
- The modified repository domain instance. Return null if no action taken.
-
deleteMap
public <D> D deleteMap(D repositoryDomain, ContextInfo contextInfo)
Description copied from interface:DomainMapper
In cases where deletion actually results in a modified state to persist (e.g. archived soft delete), this method will modify the state appropriately toward that end.- Specified by:
deleteMap
in interfaceDomainMapper
- Type Parameters:
D
- The repository domain type- Parameters:
repositoryDomain
- The persistence domain instance to inactivatecontextInfo
- The context information used to make tracking determinations relevant to sandboxing and multitenant concerns.- Returns:
- The repository domain state resulting from the delete operation. Return null if no action taken.
-
getBusinessDomainType
public <P> Class<P> getBusinessDomainType(Object repositoryDomain)
Description copied from interface:DomainMapper
Ascertain the correct business domain type based on an instance of the repository domain- Specified by:
getBusinessDomainType
in interfaceDomainMapper
- Parameters:
repositoryDomain
- The persistence domain instance to inspect- Returns:
- The type of the associated business domain. Return null is not supported.
-
getTypeFactory
public com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
- Specified by:
getTypeFactory
in interfaceDomainMapperManager
-
convertFromPersistentDomain
public <P> P convertFromPersistentDomain(Object domain, @Nullable ContextInfo contextInfo)
Description copied from interface:DomainMapperManager
Similar toDomainMapperManager.fromRepositoryDomain(Object, Class, ContextInfo)
, but doesn't require the caller to know the business domain type. In effect, this call combines theDomainMapper.getBusinessDomainType(Object)
andDomainMapperManager.fromRepositoryDomain(Object, Class, ContextInfo)
into a single call.- Specified by:
convertFromPersistentDomain
in interfaceDomainMapperManager
- Parameters:
domain
- The repository domain instancecontextInfo
- Optional context information. Useful if the domain param isTrackable
.- Returns:
- The converted business domain instance
-
-