Class CreateSetupDomainMapperMember

java.lang.Object
com.broadleafcommerce.data.tracking.core.mapping.CreateSetupDomainMapperMember
All Implemented Interfaces:
com.broadleafcommerce.common.extension.data.DataRoutePartitionAware, DomainMapper, DomainMapperMember, IdAware, org.springframework.core.Ordered

@ConfigurationProperties("broadleaf.mapping.create") public class CreateSetupDomainMapperMember extends Object implements DomainMapperMember, IdAware

A special DomainMapperMember which is responsible for performing any required operations on entities prior to their creation in the database.

For request-by-request control of what happens with generating context ids, consider setting ContextInfo.setContextIdOverwriteBehavior(com.broadleafcommerce.data.tracking.core.context.ContextIdOverwriteBehavior)

Author:
Samarth Dhruva (samarthd), Phillip Verheyden (phillipuniverse)
See Also:
  • Constructor Details

    • CreateSetupDomainMapperMember

      public CreateSetupDomainMapperMember()
  • Method Details

    • getDataRoutePartition

      public String getDataRoutePartition()
      Specified by:
      getDataRoutePartition in interface com.broadleafcommerce.common.extension.data.DataRoutePartitionAware
    • fromBusinessDomain

      public <D> D fromBusinessDomain(@Nullable Object businessDomain, @Nullable D repositoryDomain, @Nullable ContextInfo contextInfo)
      Autogenerates a ULID context ID for the repository domain if the context is a create operation.
      Specified by:
      fromBusinessDomain in interface DomainMapperMember
      Type Parameters:
      D - The repository domain type
      Parameters:
      businessDomain - The business instance containing the relevant property information
      repositoryDomain - The repository specific instance to affect and 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.
      See Also:
    • shouldContextIdBeGenerated

      protected boolean shouldContextIdBeGenerated(@Nullable IdAware.Id id, @Nullable String contextId, @Nullable ContextInfo contextInfo)
      Determines whether the context ID should be generated by the system for the given repositoryDomain entity.
      Parameters:
      id - The id of the projection
      contextId - The Trackable repository specific instance contextId
      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:
      Whether a context ID should be generated by the system for repositoryDomain.
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface DomainMapperMember
      Specified by:
      getOrder in interface org.springframework.core.Ordered
    • isAutogenerateContextIdIfUnset

      public boolean isAutogenerateContextIdIfUnset()
      Whether or not the system will generate a contextId for Trackable domain in the case there was no contextId found in the domain to begin with. This setting will apply even if there was no ContextInfo for the current mapping request and the operation could not be determined.
    • setAutogenerateContextIdIfUnset

      public void setAutogenerateContextIdIfUnset(boolean autogenerateContextIdIfUnset)
      Whether or not the system will generate a contextId for Trackable domain in the case there was no contextId found in the domain to begin with. This setting will apply even if there was no ContextInfo for the current mapping request and the operation could not be determined.
    • isOverwriteExistingContextIdOnCreate

      public boolean isOverwriteExistingContextIdOnCreate()
      Whether or not a contextId that might have already been mapped in from a Trackable domain should be overwritten with a generated value. This only has an affect when a ContextInfo of type CREATE. All other scenarios are by default trusted (no generation takes effect) unless the contextId is null (or no context at all) in which case this delegates to broadleaf.mapping.create.autogenerateContextIdIfUnset. This can be overridden on a request-by-request basis from the ContextInfo
    • setOverwriteExistingContextIdOnCreate

      public void setOverwriteExistingContextIdOnCreate(boolean overwriteExistingContextIdOnCreate)
      Whether or not a contextId that might have already been mapped in from a Trackable domain should be overwritten with a generated value. This only has an affect when a ContextInfo of type CREATE. All other scenarios are by default trusted (no generation takes effect) unless the contextId is null (or no context at all) in which case this delegates to broadleaf.mapping.create.autogenerateContextIdIfUnset. This can be overridden on a request-by-request basis from the ContextInfo