Class MultiTenantCopier
java.lang.Object
org.broadleafcommerce.common.copy.MultiTenantCopier
- All Implemented Interfaces:
org.springframework.core.Ordered
- Direct Known Subclasses:
EntityDuplicatorImpl
Abstract class for copying entities to a new catalog as required during derived catalog propagation. Subclasses generally
call
copyEntitiesOfType(Class, org.broadleafcommerce.common.site.domain.Site, org.broadleafcommerce.common.site.domain.Catalog, MultiTenantCopyContext)
one or more times inside of their copyEntities(MultiTenantCopyContext) implementation to clone and persist
an entity object tree.- Author:
- Andre Azzolini (apazzolini), Jeff Fischer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanTo add elements useaddPattern(Pattern)protected MultiTenantCopierExtensionManagerprotected GenericEntityServiceprotected static final org.apache.commons.logging.Logprotected intprotected StreamingTransactionCapableUtilFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddPattern(Pattern pattern) Checks for similar items before adding to avoid duplicationabstract voidcopyEntities(MultiTenantCopyContext context) Main method that should be implemented by eachMultiTenantCopierto drive the logic of copying that particular entity to the new derived catalog.protected <T extends MultiTenantCloneable>
voidcopyEntitiesOfType(Class<T> clazz, Site fromSite, Catalog fromCatalog, MultiTenantCopyContext context) Subclasses will generally call this method in theircopyEntities(MultiTenantCopyContext)implementation.protected booleandontTraversThroughEntityFromTheDB(Object copy, MultiTenantCopyContext context) protected BooleanintgetOrder()protected booleanprotected <T,G extends Exception>
voidpersistCopyObjectTree(CopyOperation<T, G> copyOperation, Class<T> clazz, T original, MultiTenantCopyContext context) protected voidpersistCopyObjectTreeInternal(Object copy, Set<Integer> library, MultiTenantCopyContext context) protected voidpersistNode(Object copy, MultiTenantCopyContext context) protected <T> List<T>Returns a list of all entities in the system for the given class, site, and catalog.protected <T> List<T>readAllIds(Class<?> clazz, Site site, Catalog catalog) Returns the primary key values for all entities of the specified type in the site or catalog.protected <T> LongReturns the count of the given entity class for the specified site and catalogprotected <T> Tsave(MultiTenantCopyContext context, T object) Saves the specified object in the toSite and toCatalog of the given context.voidsetOrder(int order)
-
Field Details
-
LOG
protected static final org.apache.commons.logging.Log LOG -
genericEntityService
-
extensionManager
-
transUtil
-
catalogCopierOptimizationEnabled
@Value("${catalog.copier.optimization.enabled:false}") protected boolean catalogCopierOptimizationEnabled -
order
protected int order -
classExcludeRegexPatternList
To add elements useaddPattern(Pattern)
-
-
Constructor Details
-
MultiTenantCopier
public MultiTenantCopier()
-
-
Method Details
-
copyEntities
Main method that should be implemented by eachMultiTenantCopierto drive the logic of copying that particular entity to the new derived catalog.- Parameters:
context-- Throws:
Exception
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered- Returns:
- the order of this
MultiTenantCopier
-
setOrder
public void setOrder(int order) -
persistCopyObjectTree
protected <T,G extends Exception> void persistCopyObjectTree(CopyOperation<T, G> copyOperation, Class<T> clazz, T original, MultiTenantCopyContext context) throws G- Throws:
G extends Exception
-
persistCopyObjectTreeInternal
protected void persistCopyObjectTreeInternal(Object copy, Set<Integer> library, MultiTenantCopyContext context) -
dontTraversThroughEntityFromTheDB
-
excludeFromCopyRegexPattern
- Parameters:
copy- Copy object- Returns:
- excluded or not in patterns
-
persistNode
-
copyEntitiesOfType
protected <T extends MultiTenantCloneable> void copyEntitiesOfType(Class<T> clazz, Site fromSite, Catalog fromCatalog, MultiTenantCopyContext context) throws ServiceException, CloneNotSupportedException Subclasses will generally call this method in theircopyEntities(MultiTenantCopyContext)implementation.- Type Parameters:
T-- Parameters:
clazz-fromSite-fromCatalog-context-- Throws:
ServiceExceptionCloneNotSupportedException
-
save
Saves the specified object in the toSite and toCatalog of the given context.- Parameters:
context-object-- Returns:
- the saved entity
- Throws:
ServiceException
-
readCount
Returns the count of the given entity class for the specified site and catalog- Parameters:
clazz-site-catalog-- Returns:
- the count
- Throws:
ServiceException
-
readAll
- Parameters:
clazz-site-catalog-- Returns:
- the list of entities for the specified parameters
- Throws:
ServiceException- See Also:
-
readAllIds
Returns the primary key values for all entities of the specified type in the site or catalog.- Parameters:
clazz-site-catalog-- Returns:
- Throws:
ServiceException
-
readAll
protected <T> List<T> readAll(Class<T> clazz, int limit, int offset, Site site, Catalog catalog) throws ServiceException Returns a list of all entities in the system for the given class, site, and catalog. Additionally, this method supports pagination.- Parameters:
clazz-limit-offset-site-catalog-- Returns:
- the list of entities for the specified parameters
- Throws:
ServiceException
-
addPattern
Checks for similar items before adding to avoid duplication- Parameters:
pattern- input pattern
-
needToAdd
-