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 Details

    • validate

      boolean validate(Class<?> entityClass, Long id)
      Validate whether or not this feature is enabled and whether the passed entity params are valid for duplication.
      Parameters:
      entityClass -
      id -
      Returns:
    • validate

      boolean validate(Object entity)
      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.
      use copy(Class, Long). Modifiers have been moved to a list bean to allow easier inclusion (see EntityDuplicationHelpers) and copy hints can be added to implementations of EntityDuplicationHelpers
    • copy

      @Deprecated <T> T copy(MultiTenantCopyContext context, MultiTenantCloneable<T> entity, Map<String,String> copyHints, EntityDuplicateModifier... modifiers)
      Deprecated.
      use copy(MultiTenantCopyContext, MultiTenantCloneable). Modifiers have been moved to a list bean to allow easier inclusion (see EntityDuplicationHelpers) and copy hints can be added to implementations of EntityDuplicationHelpers
    • copy

      <T> T copy(Class<T> entityClass, Long id)
      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 entity
      id - the primary key
      Returns:
      the duplicated entity
    • copy

      <T> T copy(MultiTenantCopyContext context, MultiTenantCloneable<T> entity)
      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 site
      entity - the instance to duplicate
      Returns:
      the duplicated entity