Class ItemModelCloneCreator
java.lang.Object
de.hybris.platform.servicelayer.internal.model.impl.ItemModelCloneCreator
- Direct Known Subclasses:
CMSItemModelCloneCreator
This class creates a deep copy of the given original model by creating a new model instance of the same type, reading
all attributes values and stores them into the new instance.
The only exception are part-of attribute values which consists of other models - these are cloned themselves and then used as attribute value in the new model instance.
By providing a ItemModelCloneCreator.CopyContext the
caller may even add some preset values or define which types are being used when creating copied of part-of models.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClone error class.protected static classThrown when copy could not be donestatic classA wrapper for each item attribute to be stored while creating a copy.static classstatic classWrapper for a single (partOf) item to be copied. -
Constructor Summary
ConstructorsConstructorDescriptionItemModelCloneCreator(ModelService modelService, I18NService i18nService, TypeService typeService) Creates and initialize ItemModelCloneCreator -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconsume(Collection<ItemModelCloneCreator.CopyAttribute> readyAttributes) Creates a copy of the given item.copy(ItemModel original, ItemModelCloneCreator.CopyContext ctx) Creates a copy of the given item.copy(ItemModel original, ModelCloningContext cloningContext) Creates a copy of the given item.copy(ComposedTypeModel targetType, ItemModel original, ItemModelCloneCreator.CopyContext ctx) Creates a copy of the given item.copy(ComposedTypeModel targetType, ItemModel original, ModelCloningContext ctx) Creates a copy of the given item.copy(ComposedType targetType, ItemModel original, ItemModelCloneCreator.CopyContext ctx) Deprecated, for removal: This API element is subject to removal in a future version.copyAll(ComposedTypeModel targetType, List<ItemModel> originals, ItemModelCloneCreator.CopyContext ctx) Creates copies of all specified items using a single copy context.copyAll(List<ItemModel> originals, ItemModelCloneCreator.CopyContext ctx) Creates copies of all specified items using a single copy context.voidcopyAttributes(ItemModel source, ItemModel target, Set<String> attributes) Copies only given set ofattributesfrom thesourceto thetargetmodel.protected voidfindPartOfItems(Object originalValue, ItemModelCloneCreator.CopyContext ctx) makes copy of partof itemsprotected booleanReturn true if value is null or value is empty collection/map.protected ItemModelCloneCreator.CopyItemprepareCopy(ComposedTypeModel targetType, ItemModel original, ItemModelCloneCreator.CopyContext ctx) prepare copy of original.protected ItemModelCloneCreator.CopyItemprepareCopy(ComposedType targetType, ItemModel original, ItemModelCloneCreator.CopyContext ctx) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useprepareCopy(ComposedTypeModel, ItemModel, CopyContext)protected booleanprotected voidprotected voidsetAllAttributes(ItemModel copy, Collection<ItemModelCloneCreator.CopyAttribute> attributes) protected ObjecttranslateAttributeValue(ItemModelCloneCreator.CopyAttribute attr, Object originalValue, ItemModelCloneCreator.CopyContext ctx) protected Collection<ItemModelCloneCreator.CopyAttribute>translatePendingAttributes(ItemModelCloneCreator.CopyItem item, ItemModelCloneCreator.CopyContext ctx)
-
Constructor Details
-
ItemModelCloneCreator
public ItemModelCloneCreator(ModelService modelService, I18NService i18nService, TypeService typeService) Creates and initialize ItemModelCloneCreator
-
-
Method Details
-
copy
Creates a copy of the given item.- Parameters:
original- the item to copy- Throws:
ItemModelCloneCreator.CannotCloneException
-
copy
public ItemModel copy(ItemModel original, ModelCloningContext cloningContext) throws ItemModelCloneCreator.CannotCloneException Creates a copy of the given item. Optionally cloning process can be influenced by providing a cloning context instance.- Parameters:
original- the item to copycloningContext- the cloning context to manage cloning process- Throws:
ItemModelCloneCreator.CannotCloneException
-
copy
public ItemModel copy(ItemModel original, ItemModelCloneCreator.CopyContext ctx) throws ItemModelCloneCreator.CannotCloneException Creates a copy of the given item.- Parameters:
original- the item to copyctx- the copy context- Throws:
ItemModelCloneCreator.CannotCloneException
-
copy
@Deprecated(since="ages", forRemoval=true) public ItemModel copy(ComposedType targetType, ItemModel original, ItemModelCloneCreator.CopyContext ctx) throws ItemModelCloneCreator.CannotCloneException Deprecated, for removal: This API element is subject to removal in a future version.since ages - usecopy(ComposedTypeModel, ItemModel, CopyContext) -
copy
public ItemModel copy(ComposedTypeModel targetType, ItemModel original, ModelCloningContext ctx) throws ItemModelCloneCreator.CannotCloneException Creates a copy of the given item. Allows to specify a type for the new copy to be created.- Parameters:
targetType- the type of copy to create (optional)original- the item to copyctx- the copy context- Throws:
ItemModelCloneCreator.CannotCloneException
-
copy
public ItemModel copy(ComposedTypeModel targetType, ItemModel original, ItemModelCloneCreator.CopyContext ctx) throws ItemModelCloneCreator.CannotCloneException Creates a copy of the given item. Allows to specify a type for the new copy to be created.- Parameters:
targetType- the type of copy to create (optional)original- the item to copyctx- the copy context- Throws:
ItemModelCloneCreator.CannotCloneException
-
copyAll
public List<ItemModel> copyAll(List<ItemModel> originals, ItemModelCloneCreator.CopyContext ctx) throws ItemModelCloneCreator.CannotCloneException Creates copies of all specified items using a single copy context. Therefore cross references between source items are replaces by references to the newly created copies.- Parameters:
originals- the items to copyctx- the copy context- Returns:
- the list of copies created
- Throws:
ItemModelCloneCreator.CannotCloneException- in case not all items could be copied completely, e.g. due to cyclic dependencies
-
copyAll
public List<ItemModel> copyAll(ComposedTypeModel targetType, List<ItemModel> originals, ItemModelCloneCreator.CopyContext ctx) throws ItemModelCloneCreator.CannotCloneException Creates copies of all specified items using a single copy context. Therefore cross references between source items are replaces by references to the newly created copies.- Parameters:
originals- the items to copyctx- the copy contexttargetType-ComposedTypeModelof the clones- Returns:
- the list of copies created
- Throws:
ItemModelCloneCreator.CannotCloneException- in case not all items could be copied completely, e.g. due to cyclic dependencies
-
copyAttributes
Copies only given set ofattributesfrom thesourceto thetargetmodel.- Parameters:
source- model from which attribute values are to be copiedtarget- model to copy attribute values to
-
readAttributes
protected void readAttributes(ItemModelCloneCreator.CopyItem item, ItemModelCloneCreator.CopyContext ctx) -
isEmpty
Return true if value is null or value is empty collection/map. -
prepareCopy
@Deprecated(since="ages", forRemoval=true) protected ItemModelCloneCreator.CopyItem prepareCopy(ComposedType targetType, ItemModel original, ItemModelCloneCreator.CopyContext ctx) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useprepareCopy(ComposedTypeModel, ItemModel, CopyContext) -
prepareCopy
protected ItemModelCloneCreator.CopyItem prepareCopy(ComposedTypeModel targetType, ItemModel original, ItemModelCloneCreator.CopyContext ctx) prepare copy of original. -
findPartOfItems
makes copy of partof items -
process
protected boolean process(ItemModelCloneCreator.CopyItem item, ItemModelCloneCreator.CopyContext ctx) -
setAllAttributes
protected void setAllAttributes(ItemModel copy, Collection<ItemModelCloneCreator.CopyAttribute> attributes) -
consume
-
translatePendingAttributes
protected Collection<ItemModelCloneCreator.CopyAttribute> translatePendingAttributes(ItemModelCloneCreator.CopyItem item, ItemModelCloneCreator.CopyContext ctx) -
translateAttributeValue
protected Object translateAttributeValue(ItemModelCloneCreator.CopyAttribute attr, Object originalValue, ItemModelCloneCreator.CopyContext ctx) throws ItemModelCloneCreator.CannotTranslateException
-
copy(ComposedTypeModel, ItemModel, CopyContext)