Class ItemModelCloneCreator.CopyContext

java.lang.Object
de.hybris.platform.servicelayer.internal.model.impl.ItemModelCloneCreator.CopyContext
Direct Known Subclasses:
CMSCopyContext, DefaultCloneAbstractOrderStrategy.OrderCopyContext
Enclosing class:
ItemModelCloneCreator

public static class ItemModelCloneCreator.CopyContext extends Object
  • Constructor Details

    • CopyContext

      public CopyContext()
      Creates a new copy context.
    • CopyContext

      public CopyContext(ModelCloningContext cloningContext)
      Creates a new copy context with cloning context
  • Method Details

    • skipAttribute

      protected boolean skipAttribute(Object original, String qualifier)
      tell us if attribute have to be skipped
    • treatAsPartOf

      protected boolean treatAsPartOf(Object original, String qualifier)
      tell us if attribute have to be treated as part of
    • getTargetType

      public ComposedTypeModel getTargetType(ItemModel original)
      Tells which type should be used for creating a copy of the specified original item. Default is simply using its current type.
    • addPreset

      public void addPreset(ItemModel srcItem, String qualifier, Object value)
      Defines a attribute value to be used when creating a copy instead of the original attribute value. Example:
       Media original = ...
       ItemCloneCreator creator = new ItemCloneCreator();
       CopyContext ctx = new CopyContext();
       ctx.addPreset( original, Media.CODE, original.getCode()+"(copy") );
       Media copy = creator.copy( original, ctx );
       

      Since you may specify multiple source items it's possible to add preset values for partOf items as well.

      Parameters:
      srcItem - the source item which is used for copying
      qualifier - the attribute qualifier
      value - the value to use
    • gotPreset

      protected boolean gotPreset(ItemModel src, String qualifier)
      Tells if a attribute got a preset value or not.
    • getPresets

      protected Map<String,Object> getPresets(ItemModel src)
      Returns all preset values of a source item.
    • getPreset

      protected Object getPreset(ItemModel src, String qualifier)
    • getAll

      Returns all item copy wrappers.
    • add

      protected void add(ItemModelCloneCreator.CopyItem item)
      Adds a new (partOf) item copy wrapper to the context.
    • mustBeTranslated

      public boolean mustBeTranslated(ItemModel original)
      Tells whether or not the item has been registered as (partOf) item to be copied.
      Parameters:
      original - the item to check
    • getCopyWrapper

      protected ItemModelCloneCreator.CopyItem getCopyWrapper(ItemModel original)
      Returns associated copy wrapper for a given (partOf) source item
    • getCopy

      public ItemModel getCopy(ItemModel original)
      Returns copy for specified (partOf) source item.
      Parameters:
      original -
      Returns:
      the copy item or null if it hasn't been copied yet
      Throws:
      IllegalArgumentException - if item is not registered as (partOf) item to be copied
    • hasPendingItems

      public boolean hasPendingItems()
      Tells whether or not the context contains (partOf) items witch are not copied yet or have attributes which have not been copied completely.
    • getPendingItems

      public Collection<ItemModelCloneCreator.CopyItem> getPendingItems()
      Returns all item wrappers which have not been copied or hold attributes which are not copied completely.