Interface EntityDuplicator
- All Known Implementing Classes:
EntityDuplicatorImpl
public interface EntityDuplicator
Creates a production duplicate of an entity. In the case of the enterprise module, the entity to be duplicated may not be a sandbox copy. In the case of the multitenant module, the entity to be duplicated must not be referenced in a derived catalog (apart from a standard site override) and must not be owned by another site.
The feature must first be enabled before use. To enable, add the following property to your Spring property file:admin.entity.duplication.isactive=true
. Furthermore,
for any entity you wish to be able to duplicate, you must implement an
EntityDuplicationHelper
. Consider extending AbstractEntityDuplicationHelper
because it implements EntityDuplicationHelper.getCopyHints()
and
EntityDuplicationHelper.addCopyHint(String, String)
for you.
CopyHints can be added to change the behavior of
MultiTenantCloneable.createOrRetrieveCopyInstance(MultiTenantCopyContext)
for a
specific entity. See org.broadleafcommerce.core.offer.service.OfferDuplicateModifier
and org.broadleafcommerce.core.offer.domain.OfferImpl
for an example.
- Author:
- Jeff Fischer
-
Method Summary
Modifier and TypeMethodDescription<T> T
Create a production duplicate of the entity specified in the params.<T> T
copy
(Class<T> entityClass, Long id, Map<String, String> copyHints, EntityDuplicateModifier... modifiers) Deprecated.<T> T
copy
(MultiTenantCopyContext context, MultiTenantCloneable<T> entity) Create a production duplicate of the entity specified in the params.<T> T
copy
(MultiTenantCopyContext context, MultiTenantCloneable<T> entity, Map<String, String> copyHints, EntityDuplicateModifier... modifiers) Deprecated.boolean
Validate whether or not this feature is enabled and whether the passed entity params are valid for duplication.boolean
Validate whether or not this feature is enabled and whether or not the passed entity params are valid for duplication.
-
Method Details
-
validate
Validate whether or not this feature is enabled and whether the passed entity params are valid for duplication.- Parameters:
entityClass
-id
-- Returns:
-
validate
Validate whether or not this feature is enabled and whether or not the passed entity params are valid for duplication.- Parameters:
entity
-- Returns:
-
copy
@Deprecated <T> T copy(Class<T> entityClass, Long id, Map<String, String> copyHints, EntityDuplicateModifier... modifiers) Deprecated.usecopy(Class, Long)
. Modifiers have been moved to a list bean to allow easier inclusion (seeEntityDuplicationHelpers
) and copy hints can be added to implementations ofEntityDuplicationHelper
s -
copy
@Deprecated <T> T copy(MultiTenantCopyContext context, MultiTenantCloneable<T> entity, Map<String, String> copyHints, EntityDuplicateModifier... modifiers) Deprecated.usecopy(MultiTenantCopyContext, MultiTenantCloneable)
. Modifiers have been moved to a list bean to allow easier inclusion (seeEntityDuplicationHelpers
) and copy hints can be added to implementations ofEntityDuplicationHelper
s -
copy
Create a production duplicate of the entity specified in the params. The is the most oft used copy method.- Type Parameters:
T
- the entity type- Parameters:
entityClass
- the class for the entityid
- the primary key- Returns:
- the duplicated entity
-
copy
Create a production duplicate of the entity specified in the params. The is the least oft used copy method.- Type Parameters:
T
- the entity type- Parameters:
context
- prepopulated copy context that is setup for catalog and/or siteentity
- the instance to duplicate- Returns:
- the duplicated entity
-
copy(Class, Long)
.