Package de.hybris.platform.jalo.type
Class ItemCloneCreator
- java.lang.Object
-
- de.hybris.platform.jalo.type.ItemCloneCreator
-
public class ItemCloneCreator extends java.lang.Object
Generically 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 class
ItemCloneCreator.CannotCloneException
Clone error class.protected static class
ItemCloneCreator.CannotTranslateException
static class
ItemCloneCreator.CopyAttribute
A wrapper for each item attribute to be stored while creating a copy.static class
ItemCloneCreator.CopyContext
Context for collecting all items copied duringcopy(ComposedType, Item, CopyContext)
.static class
ItemCloneCreator.CopyItem
Wrapper 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 void
consume(java.util.Collection<ItemCloneCreator.CopyAttribute> readyAttributes)
Item
copy(Item original)
Creates a copy of the given item.Item
copy(Item original, ItemCloneCreator.CopyContext ctx)
Creates a copy of the given item.Item
copy(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 void
copyUntypedProperties(ItemCloneCreator.CopyItem item, ItemCloneCreator.CopyContext ctx)
protected void
findPartOfItems(java.lang.Object originalValue, ItemCloneCreator.CopyContext ctx)
protected ItemCloneCreator.CopyItem
prepareCopy(ComposedType targetType, Item original, ItemCloneCreator.CopyContext ctx)
protected boolean
process(ItemCloneCreator.CopyItem item, ItemCloneCreator.CopyContext ctx)
protected void
readAttributes(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.Object
translateAttributeValue(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:
JaloBusinessException
ItemCloneCreator.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:
JaloBusinessException
ItemCloneCreator.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:
JaloBusinessException
ItemCloneCreator.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
-
-