Class AbstractItemCopyContext
- java.lang.Object
-
- de.hybris.platform.catalog.jalo.synchronization.AbstractItemCopyContext
-
- Direct Known Subclasses:
GenericCatalogCopyContext
public abstract class AbstractItemCopyContext extends java.lang.Object
- Since:
- 3.1-u6
-
-
Field Summary
Fields Modifier and Type Field Description protected SessionContext
ctx
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractItemCopyContext(SessionContext ctx, org.apache.log4j.Level logLevel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Collection<Item>
allItems(AttributeCopyCreator acc, java.lang.Object value)
Returns (recursively) all items which were found in the given value.void
cleanup()
protected TypeCopyDescriptor
createCopyDescriptor(ComposedType composedType)
Creates a new type copy descriptor instance.protected JaloSession
createSession()
void
debug(java.lang.String message)
void
debug(java.lang.String message, java.lang.Throwable e)
void
error(java.lang.String message)
void
error(java.lang.String message, java.lang.Throwable e)
protected CatalogManager
getCatalogManager()
SessionContext
getCtx()
protected FlexibleSearch
getFlexibleSearch()
protected JaloSession
getSession()
TypeCopyDescriptor
getTypeCopyDescriptor(ComposedType type)
Returns a (cached) type copy descriptor for a given composed type.protected boolean
ignoreAttribute(AttributeDescriptor attributeDescriptor, java.lang.String qualifier)
Used bysplitDescriptors(TypeCopyDescriptor, ComposedType)
to determine whether an attribute may be ignored or not.void
info(java.lang.String message)
void
info(java.lang.String message, java.lang.Throwable e)
protected boolean
isAtomic(AttributeDescriptor attributeDescriptor)
Used bysplitDescriptors(TypeCopyDescriptor, ComposedType)
to determine whether an attribute holds just atomic values.protected boolean
isAtomic(Type attributeType, boolean localized)
Traverses collection and map types to find any non-atomic type within.protected boolean
isCopyOnDemand(AttributeDescriptor attributeDescriptor)
boolean
isDebugEnabled()
boolean
isErrorEnabled()
boolean
isInfoEnabled()
protected boolean
isPartOf(AttributeDescriptor attributeDescriptor)
Used bysplitDescriptors(TypeCopyDescriptor, ComposedType)
to determine whether an attribute holds partOf values.protected boolean
isRequiredForCreation(AttributeDescriptor attributeDescriptor)
Determines whether or not a attribute is required for the creation of a item copy.boolean
isWarnEnabled()
protected void
log(java.lang.String message, org.apache.log4j.Level level)
Default log implementation using a Log4J appender.protected void
log(java.lang.String message, org.apache.log4j.Level level, java.lang.Throwable e)
protected java.lang.String
safeToString(java.lang.Object attributeValue)
protected java.util.Set<AttributeCopyDescriptor>[]
splitDescriptors(TypeCopyDescriptor tcd, ComposedType composedType)
Called during the creation of aTypeCopyDescriptor
.protected Item
toItem(PK pk)
protected java.util.Collection<? extends Item>
toItems(java.util.Collection<PK> pks)
protected java.lang.String
toString(AttributeDescriptor attributeDescriptor)
protected java.lang.String
valuesToString(java.util.Map attributeValues)
void
warn(java.lang.String message)
void
warn(java.lang.String message, java.lang.Throwable e)
-
-
-
Field Detail
-
ctx
protected SessionContext ctx
-
-
Constructor Detail
-
AbstractItemCopyContext
protected AbstractItemCopyContext(SessionContext ctx, org.apache.log4j.Level logLevel)
-
-
Method Detail
-
createSession
protected JaloSession createSession()
- Returns:
- current JaloSession
-
log
protected void log(java.lang.String message, org.apache.log4j.Level level, java.lang.Throwable e)
-
log
protected void log(java.lang.String message, org.apache.log4j.Level level)
Default log implementation using a Log4J appender.
-
debug
public void debug(java.lang.String message, java.lang.Throwable e)
-
info
public void info(java.lang.String message, java.lang.Throwable e)
-
warn
public void warn(java.lang.String message, java.lang.Throwable e)
-
error
public void error(java.lang.String message, java.lang.Throwable e)
-
debug
public void debug(java.lang.String message)
-
info
public void info(java.lang.String message)
-
warn
public void warn(java.lang.String message)
-
error
public void error(java.lang.String message)
-
isDebugEnabled
public boolean isDebugEnabled()
-
isInfoEnabled
public boolean isInfoEnabled()
-
isWarnEnabled
public boolean isWarnEnabled()
-
isErrorEnabled
public boolean isErrorEnabled()
-
getCtx
public final SessionContext getCtx()
-
getSession
protected final JaloSession getSession()
- Returns:
- JaloSession which is bound to this CopyContext
-
allItems
protected java.util.Collection<Item> allItems(AttributeCopyCreator acc, java.lang.Object value)
Returns (recursively) all items which were found in the given value. If the value is- an Item: this item is returned
- a Collection: the containing Items are returned
- a Map for a localized attribute: the map values (which are items) are returned
- a Map for a non-localized attribute: the map keys and values (which are items) are returned
- Returns:
- an empty set if nothing (no item) was found at all.
-
getTypeCopyDescriptor
public TypeCopyDescriptor getTypeCopyDescriptor(ComposedType type)
Returns a (cached) type copy descriptor for a given composed type.
-
createCopyDescriptor
protected TypeCopyDescriptor createCopyDescriptor(ComposedType composedType)
Creates a new type copy descriptor instance. By default this will create aTypeCopyDescriptor
. Called bygetTypeCopyDescriptor(ComposedType)
.- Parameters:
composedType
-
-
splitDescriptors
protected java.util.Set<AttributeCopyDescriptor>[] splitDescriptors(TypeCopyDescriptor tcd, ComposedType composedType)
Called during the creation of aTypeCopyDescriptor
. It must split all attribute descriptors into 4 different sets:- initial writable only
- initial
- partOf attributes
- other (mostly reference) attributes
- Parameters:
tcd
- the newly created type copy descriptorcomposedType
- the actual composed type- Returns:
- an array of 4 sets holding
AttributeCopyDescriptors
.
-
isAtomic
protected boolean isAtomic(AttributeDescriptor attributeDescriptor)
Used bysplitDescriptors(TypeCopyDescriptor, ComposedType)
to determine whether an attribute holds just atomic values. This will callisAtomic(Type, boolean)
for analyzing the real attribute type.
-
isAtomic
protected boolean isAtomic(Type attributeType, boolean localized)
Traverses collection and map types to find any non-atomic type within. If localized is true and the attribute type is a map type it ignores the argument type - however nested map types are fully searched subsequently.- Parameters:
attributeType
- the argument type to checklocalized
- whether or not the attribute is localized- Returns:
- true if the argument type is a atomic type or a collection or map type containing atomic types only
-
isPartOf
protected boolean isPartOf(AttributeDescriptor attributeDescriptor)
Used bysplitDescriptors(TypeCopyDescriptor, ComposedType)
to determine whether an attribute holds partOf values. These values are always copied (created or translated if already existing) when the original item is being copied.
-
isCopyOnDemand
protected boolean isCopyOnDemand(AttributeDescriptor attributeDescriptor)
-
isRequiredForCreation
protected boolean isRequiredForCreation(AttributeDescriptor attributeDescriptor)
Determines whether or not a attribute is required for the creation of a item copy. These attributes cannot be delayed, which requires that all values must be translatable or preset.If no item is actually created but an existing copy is updated these attributes are set alltogether before all partOf references and other attributes. Delaying is neither allowed here.
- Parameters:
attributeDescriptor
- the attribute descriptor to determine creation status for- Returns:
- true if the attribute is required for item creation
-
ignoreAttribute
protected boolean ignoreAttribute(AttributeDescriptor attributeDescriptor, java.lang.String qualifier)
Used bysplitDescriptors(TypeCopyDescriptor, ComposedType)
to determine whether an attribute may be ignored or not. By default this will apply toItem.TYPE
only. Override to define own ignored attributes.- Parameters:
attributeDescriptor
-qualifier
-- Returns:
- true if the attribute should not be included in type copy informations (so it cannot be copied)
-
toString
protected java.lang.String toString(AttributeDescriptor attributeDescriptor)
-
safeToString
protected java.lang.String safeToString(java.lang.Object attributeValue)
-
valuesToString
protected java.lang.String valuesToString(java.util.Map attributeValues)
-
cleanup
public void cleanup()
-
getCatalogManager
protected CatalogManager getCatalogManager()
-
getFlexibleSearch
protected FlexibleSearch getFlexibleSearch()
-
-