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 Details

    • 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 Details

    • 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 to DomainMapperMember.fromBusinessDomain(Object, Object, ContextInfo).
      Specified by:
      fromBusinessDomain in interface DomainMapperManager
      Type Parameters:
      D - The repository domain type
      Parameters:
      businessDomain - The business instance containing the relevant property information
      repositoryDomainType - The class defining the persisted domain type to return
      contextInfo - 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.
      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 to DomainMapperMember.fromRepositoryDomain(Object, Object, ContextInfo).
      Specified by:
      fromRepositoryDomain in interface DomainMapperManager
      Type Parameters:
      P - The business domain type
      Parameters:
      repositoryDomain - The persistence-based domain instance containing the relevant property information
      businessDomainType - The class defining the business domain type to return
      contextInfo - 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.
      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
      Specified by:
      process in interface DomainMapperManager
      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. See TrackableRepository 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
      Specified by:
      process in interface DomainMapperManager
      Type Parameters:
      P - The projection type
      Parameters:
      repositoryDomain - The originating repository domain instances in the form of a list
      contextInfo - 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.
      Returns:
      The mapped and transformed list of projection instances
    • process

      public <P> Stream<P> process(Stream<?> repositoryDomain, ContextInfo contextInfo)
      Description copied from interface: DomainMapperManager
      Specified by:
      process in interface DomainMapperManager
      Type Parameters:
      P - The projection type
      Parameters:
      repositoryDomain - The originating repository domain instances in the form of a stream
      contextInfo - 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.
      Returns:
      The mapped and transformed stream of projection instances
    • process

      public <P> P process(Object repositoryDomain, ContextInfo contextInfo)
      Description copied from interface: DomainMapperManager
      Specified by:
      process in interface DomainMapperManager
      Type Parameters:
      P - The projection type
      Parameters:
      repositoryDomain - The originating repository domain instance
      contextInfo - 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.
      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 interface PostMapper
      Type Parameters:
      P - The projection type
      D - 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. See TrackableRepository 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 to DomainMapperMember.fromRepositoryDomain(Object, Object, ContextInfo).
      Specified by:
      fromRepositoryDomainByExample in interface DomainMapperManager
      Type Parameters:
      P - The business domain type
      Parameters:
      repositoryDomain - The persistence-based domain instance containing the relevant property information
      example - The business domain instance
      contextInfo - 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.
      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 to DomainMapperMember.fromRepositoryDomain(Object, Object, ContextInfo).
      Specified by:
      fromRepositoryDomain in interface DomainMapperManager
      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. See TrackableRepository 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 interface DomainMapper
      Type Parameters:
      D - The repository domain type
      P - The business domain type
      Parameters:
      repositoryDomain - The persistence domain instance to modify
      businessDomain - The business instance containing changes to map to the repository domain
      contextInfo - 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.
      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 interface DomainMapper
      Type Parameters:
      D - The repository domain type
      Parameters:
      repositoryDomain - The persistence domain instance to inactivate
      contextInfo - 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 interface DomainMapper
      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 interface DomainMapperManager
    • convertFromPersistentDomain

      public <P> P convertFromPersistentDomain(Object domain, @Nullable ContextInfo contextInfo)
      Description copied from interface: DomainMapperManager
      Similar to DomainMapperManager.fromRepositoryDomain(Object, Class, ContextInfo), but doesn't require the caller to know the business domain type. In effect, this call combines the DomainMapper.getBusinessDomainType(Object) and DomainMapperManager.fromRepositoryDomain(Object, Class, ContextInfo) into a single call.
      Specified by:
      convertFromPersistentDomain in interface DomainMapperManager
      Parameters:
      domain - The repository domain instance
      contextInfo - Optional context information. Useful if the domain param is Trackable.
      Returns:
      The converted business domain instance