Package de.hybris.platform.jalo.type
Class ItemCloneCreator.CopyContext
- java.lang.Object
-
- de.hybris.platform.jalo.type.ItemCloneCreator.CopyContext
-
- Enclosing class:
- ItemCloneCreator
public static class ItemCloneCreator.CopyContext extends java.lang.ObjectContext for collecting all items copied duringItemCloneCreator.copy(ComposedType, Item, CopyContext). In addition it allows to specify preset values to be used instead of original attributes.
-
-
Constructor Summary
Constructors Constructor Description CopyContext()Creates a new copy context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidadd(ItemCloneCreator.CopyItem item)voidaddCopyUntypedPropsFor(Item sourceItem)Switches on copying of untyped properties for the specified item.voidaddCopyUntypedPropsFor(java.util.Collection<Item> sourceItems)Switches on copying of untyped properties for the specified items.voidaddPreset(Item srcItem, java.lang.String qualifier, java.lang.Object value)Defines a attribute value to be used when creating a copy instead of the original attribute value.protected java.util.Collection<ItemCloneCreator.CopyItem>getAll()ItemgetCopy(Item original)Returns copy for specified (partOf) source item.protected java.util.Set<ItemCloneCreator.CopyItem>getCopyUntypedItems()protected ItemCloneCreator.CopyItemgetCopyWrapper(Item original)java.util.Collection<ItemCloneCreator.CopyItem>getPendingItems()Returns all item wrappers which have not been copied or hold attributes which are not copied completely.protected java.util.Map<java.lang.String,java.lang.Object>getPresets(Item src)protected ComposedTypegetTargetType(Item original)protected booleangotPreset(Item src, java.lang.String qualifier)booleanhasPendingItems()Tells whether or not the context contains (partOf) items witch are not copied yet or have attributes which have not been copied completely.protected booleanisCopyUntypedPropsFor(ItemCloneCreator.CopyItem item)booleanmustBeTranslated(Item original)Tells whether or not the item has been registered as (partOf) item to be copied.
-
-
-
Method Detail
-
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(java.util.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 java.util.Set<ItemCloneCreator.CopyItem> getCopyUntypedItems()
-
addPreset
public void addPreset(Item srcItem, java.lang.String qualifier, java.lang.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 copyingqualifier- the attribute qualifiervalue- the value to use
-
gotPreset
protected boolean gotPreset(Item src, java.lang.String qualifier)
-
getPresets
protected java.util.Map<java.lang.String,java.lang.Object> getPresets(Item src)
-
getAll
protected java.util.Collection<ItemCloneCreator.CopyItem> 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
nullif it hasn't been copied yet - Throws:
java.lang.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 java.util.Collection<ItemCloneCreator.CopyItem> getPendingItems()
Returns all item wrappers which have not been copied or hold attributes which are not copied completely.
-
-