Package de.hybris.platform.jalo.type
Class ItemCloneCreator
- java.lang.Object
-
- de.hybris.platform.jalo.type.ItemCloneCreator
-
public class ItemCloneCreator extends java.lang.ObjectGenerically copies a item. It create a new instance of a specified item using all its attribute values. During copy it also creates copies for all items being held in partOf attributes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classItemCloneCreator.CannotCloneExceptionClone error class.protected static classItemCloneCreator.CannotTranslateExceptionstatic classItemCloneCreator.CopyAttributeA wrapper for each item attribute to be stored while creating a copy.static classItemCloneCreator.CopyContextContext for collecting all items copied duringcopy(ComposedType, Item, CopyContext).static classItemCloneCreator.CopyItemWrapper for a single (partOf) item to be copied.
-
Constructor Summary
Constructors Constructor Description ItemCloneCreator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidconsume(java.util.Collection<ItemCloneCreator.CopyAttribute> readyAttributes)Itemcopy(Item original)Creates a copy of the given item.Itemcopy(Item original, ItemCloneCreator.CopyContext ctx)Creates a copy of the given item.Itemcopy(ComposedType targetType, Item original, ItemCloneCreator.CopyContext ctx)Creates a copy of the given item.java.util.List<? extends Item>copyAll(java.util.List<? extends Item> originals, ItemCloneCreator.CopyContext ctx)Creates copies of all specified items using a single copy context.protected voidcopyUntypedProperties(ItemCloneCreator.CopyItem item, ItemCloneCreator.CopyContext ctx)protected voidfindPartOfItems(java.lang.Object originalValue, ItemCloneCreator.CopyContext ctx)protected ItemCloneCreator.CopyItemprepareCopy(ComposedType targetType, Item original, ItemCloneCreator.CopyContext ctx)protected booleanprocess(ItemCloneCreator.CopyItem item, ItemCloneCreator.CopyContext ctx)protected voidreadAttributes(ItemCloneCreator.CopyItem item, ItemCloneCreator.CopyContext ctx)protected java.util.Map<java.lang.String,java.lang.Object>toValueMap(java.util.Collection<ItemCloneCreator.CopyAttribute> readyAttributes)protected java.lang.ObjecttranslateAttributeValue(ItemCloneCreator.CopyAttribute attr, java.lang.Object originalValue, ItemCloneCreator.CopyContext ctx)protected java.util.Collection<ItemCloneCreator.CopyAttribute>translatePendingAttributes(ItemCloneCreator.CopyItem item, ItemCloneCreator.CopyContext ctx)
-
-
-
Method Detail
-
copy
public Item copy(Item original) throws ItemCloneCreator.CannotCloneException, JaloBusinessException
Creates a copy of the given item.- Parameters:
original- the item to copy- Throws:
JaloBusinessExceptionItemCloneCreator.CannotCloneException
-
copy
public Item copy(Item original, ItemCloneCreator.CopyContext ctx) throws ItemCloneCreator.CannotCloneException, JaloBusinessException
Creates a copy of the given item.- Parameters:
original- the item to copyctx- the copy context- Throws:
JaloBusinessExceptionItemCloneCreator.CannotCloneException
-
copy
public Item copy(ComposedType targetType, Item original, ItemCloneCreator.CopyContext ctx) throws ItemCloneCreator.CannotCloneException, JaloBusinessException
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:
JaloBusinessExceptionItemCloneCreator.CannotCloneException
-
copyAll
public java.util.List<? extends Item> copyAll(java.util.List<? extends Item> originals, ItemCloneCreator.CopyContext ctx) throws ItemCloneCreator.CannotCloneException, JaloBusinessException
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:
ItemCloneCreator.CannotCloneException- in case not all items could be copied completely, e.g. due to cyclic dependenciesJaloBusinessException
-
copyUntypedProperties
protected void copyUntypedProperties(ItemCloneCreator.CopyItem item, ItemCloneCreator.CopyContext ctx)
-
readAttributes
protected void readAttributes(ItemCloneCreator.CopyItem item, ItemCloneCreator.CopyContext ctx)
-
prepareCopy
protected ItemCloneCreator.CopyItem prepareCopy(ComposedType targetType, Item original, ItemCloneCreator.CopyContext ctx)
-
findPartOfItems
protected void findPartOfItems(java.lang.Object originalValue, ItemCloneCreator.CopyContext ctx)
-
process
protected boolean process(ItemCloneCreator.CopyItem item, ItemCloneCreator.CopyContext ctx) throws JaloBusinessException
- Throws:
JaloBusinessException
-
consume
protected void consume(java.util.Collection<ItemCloneCreator.CopyAttribute> readyAttributes)
-
toValueMap
protected java.util.Map<java.lang.String,java.lang.Object> toValueMap(java.util.Collection<ItemCloneCreator.CopyAttribute> readyAttributes)
-
translatePendingAttributes
protected java.util.Collection<ItemCloneCreator.CopyAttribute> translatePendingAttributes(ItemCloneCreator.CopyItem item, ItemCloneCreator.CopyContext ctx)
-
translateAttributeValue
protected java.lang.Object translateAttributeValue(ItemCloneCreator.CopyAttribute attr, java.lang.Object originalValue, ItemCloneCreator.CopyContext ctx) throws ItemCloneCreator.CannotTranslateException
-
-