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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.broadleafcommerce.data.tracking.core.mapping.IdAware
IdAware.Id
-
Field Summary
Fields inherited from interface com.broadleafcommerce.common.extension.data.DataRoutePartitionAware
ALL_MATCH
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<D> D
fromBusinessDomain
(Object businessDomain, D repositoryDomain, ContextInfo contextInfo) Autogenerates a ULID context ID for the repository domain if the context is a create operation.int
getOrder()
boolean
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.boolean
Whether or not a contextId that might have already been mapped in from a Trackable domain should be overwritten with a generated value.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.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.protected boolean
shouldContextIdBeGenerated
(IdAware.Id id, String contextId, ContextInfo contextInfo) Determines whether the context ID should be generated by the system for the givenrepositoryDomain
entity.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.DomainMapper
deleteMap, getBusinessDomainType, modifyMap
Methods inherited from interface com.broadleafcommerce.data.tracking.core.mapping.DomainMapperMember
fromRepositoryDomain
-
Constructor Details
-
CreateSetupDomainMapperMember
public CreateSetupDomainMapperMember()
-
-
Method Details
-
getDataRoutePartition
- Specified by:
getDataRoutePartition
in interfacecom.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 interfaceDomainMapperMember
- Type Parameters:
D
- The repository domain type- Parameters:
businessDomain
- 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. SeeTrackableRepository
for more info on persistence behavior based on context.- Returns:
- The populated repository domain instance. Should return null if no action taken.
- See Also:
-
ContextInfo.getContextIdOverwriteBehavior()
overwriteExistingContextIdOnCreate
autogenerateContextIdIfUnset
-
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 givenrepositoryDomain
entity.- Parameters:
id
- The id of the projectioncontextId
- The Trackable repository specific instance contextIdcontextInfo
- 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:
- Whether a context ID should be generated by the system for
repositoryDomain
.
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfaceDomainMapperMember
- Specified by:
getOrder
in interfaceorg.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
-