Class ItemModelCloneCreator.CopyContext
- java.lang.Object
-
- de.hybris.platform.servicelayer.internal.model.impl.ItemModelCloneCreator.CopyContext
-
- Direct Known Subclasses:
CMSCopyContext
- Enclosing class:
- ItemModelCloneCreator
public static class ItemModelCloneCreator.CopyContext extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description CopyContext()Creates a new copy context.CopyContext(ModelCloningContext cloningContext)Creates a new copy context with cloning context
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidadd(ItemModelCloneCreator.CopyItem item)Adds a new (partOf) item copy wrapper to the context.voidaddPreset(ItemModel 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<ItemModelCloneCreator.CopyItem>getAll()Returns all item copy wrappers.ItemModelgetCopy(ItemModel original)Returns copy for specified (partOf) source item.protected ItemModelCloneCreator.CopyItemgetCopyWrapper(ItemModel original)Returns associated copy wrapper for a given (partOf) source itemjava.util.Collection<ItemModelCloneCreator.CopyItem>getPendingItems()Returns all item wrappers which have not been copied or hold attributes which are not copied completely.protected java.lang.ObjectgetPreset(ItemModel src, java.lang.String qualifier)protected java.util.Map<java.lang.String,java.lang.Object>getPresets(ItemModel src)Returns all preset values of a source item.ComposedTypeModelgetTargetType(ItemModel original)Tells which type should be used for creating a copy of the specified original item.protected booleangotPreset(ItemModel src, java.lang.String qualifier)Tells if a attribute got a preset value or not.booleanhasPendingItems()Tells whether or not the context contains (partOf) items witch are not copied yet or have attributes which have not been copied completely.booleanmustBeTranslated(ItemModel original)Tells whether or not the item has been registered as (partOf) item to be copied.protected booleanskipAttribute(java.lang.Object original, java.lang.String qualifier)tell us if attribute have to be skippedprotected booleantreatAsPartOf(java.lang.Object original, java.lang.String qualifier)tell us if attribute have to be treated as part of
-
-
-
Constructor Detail
-
CopyContext
public CopyContext()
Creates a new copy context.
-
CopyContext
public CopyContext(ModelCloningContext cloningContext)
Creates a new copy context with cloning context
-
-
Method Detail
-
skipAttribute
protected boolean skipAttribute(java.lang.Object original, java.lang.String qualifier)tell us if attribute have to be skipped
-
treatAsPartOf
protected boolean treatAsPartOf(java.lang.Object original, java.lang.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, 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(ItemModel src, java.lang.String qualifier)
Tells if a attribute got a preset value or not.
-
getPresets
protected java.util.Map<java.lang.String,java.lang.Object> getPresets(ItemModel src)
Returns all preset values of a source item.
-
getPreset
protected java.lang.Object getPreset(ItemModel src, java.lang.String qualifier)
-
getAll
protected java.util.Collection<ItemModelCloneCreator.CopyItem> 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
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<ItemModelCloneCreator.CopyItem> getPendingItems()
Returns all item wrappers which have not been copied or hold attributes which are not copied completely.
-
-