Class ItemCloneCreator.CopyContext

java.lang.Object
de.hybris.platform.jalo.type.ItemCloneCreator.CopyContext
Enclosing class:
ItemCloneCreator

public static class ItemCloneCreator.CopyContext extends Object
Context for collecting all items copied during ItemCloneCreator.copy(ComposedType, Item, CopyContext). In addition it allows to specify preset values to be used instead of original attributes.
  • Constructor Details

    • CopyContext

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

    • getTargetType

      protected ComposedType getTargetType(Item original)
    • addCopyUntypedPropsFor

      public void addCopyUntypedPropsFor(Item sourceItem)
      Switches on copying of untyped properties for the specified item. While creating a copy of the specified item all untyped properties are copied as well.
      Parameters:
      sourceItem - the original item to copy props from
    • addCopyUntypedPropsFor

      public void addCopyUntypedPropsFor(Collection<Item> sourceItems)
      Switches on copying of untyped properties for the specified items. While creating copies of the specified items all untyped properties are copied as well.
      Parameters:
      sourceItems - the original items to copy props from
    • isCopyUntypedPropsFor

      protected boolean isCopyUntypedPropsFor(ItemCloneCreator.CopyItem item)
    • getCopyUntypedItems

      protected Set<ItemCloneCreator.CopyItem> getCopyUntypedItems()
    • addPreset

      public void addPreset(Item 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(Item src, String qualifier)
    • getPresets

      protected Map<String,Object> getPresets(Item src)
    • getAll

    • add

      protected void add(ItemCloneCreator.CopyItem item)
    • mustBeTranslated

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

      protected ItemCloneCreator.CopyItem getCopyWrapper(Item original)
    • getCopy

      public Item getCopy(Item 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<ItemCloneCreator.CopyItem> getPendingItems()
      Returns all item wrappers which have not been copied or hold attributes which are not copied completely.