Class ItemModelContextImpl
- java.lang.Object
-
- de.hybris.platform.servicelayer.model.ItemModelContextImpl
-
- All Implemented Interfaces:
ItemModelContext
,ItemModelInternalContext
,java.io.Serializable
public class ItemModelContextImpl extends java.lang.Object implements ItemModelInternalContext, java.io.Serializable
Default implementation forItemModelContext
.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterCreate(LocaleProvider locProvider, AttributeProvider attrProvider, DynamicAttributesProvider dynProvider, PK pk, long persistenceVersion, java.lang.String typeCode)
void
afterReload(long persistenceVersion)
void
afterUpdate(long persistenceVersion)
void
beforeAttach(LocaleProvider localeProvider)
boolean
equals(java.lang.Object obj)
boolean
exists()
Checks if the model is still valid.PK
generateNewPK()
Generate the new PK and assigns it to the current model.AttributeProvider
getAttributeProvider()
java.util.Map<java.lang.String,LocMap<java.util.Locale,java.lang.Object>>
getCombinedLocalizedValuesMap()
protected java.util.Locale
getCurrentLocale()
java.util.Set<java.lang.String>
getDirtyAttributes()
Returns all changed attributes.java.util.Map<java.util.Locale,java.util.Set<java.lang.String>>
getDirtyLocalizedAttributes()
Returns all changed localized attributes with the locale.DynamicAttributesProvider
getDynamicAttributesProvider()
<T> T
getDynamicValue(AbstractItemModel model, java.lang.String attribute)
Retrieves the dynamic value of the attribute.protected FetchStrategy
getFetchStrategy()
java.lang.String
getItemType()
Retrieves the item type of the model.LocaleProvider
getLocaleProvider(boolean required)
<T> T
getLocalizedDynamicValue(AbstractItemModel model, java.lang.String attribute, java.util.Locale loc)
Retrieves the dynamic value of the attribute with the local.<T> T
getLocalizedRelationValue(java.lang.String key, java.util.Locale locale)
Retrieves the current value of the specific attribute with the locale.<T> T
getLocalizedValue(java.lang.String key, java.util.Locale locale)
Retrieves the localized value of the key.protected java.lang.Object
getLocalizedWithFallback(java.util.Map<java.util.Locale,java.lang.Object> attrLocMap, java.lang.String qualifier, java.util.Locale dataLocale, boolean keepOriginals, boolean isRelationAttribute)
PK
getNewPK()
Returns the newPK assigned to the current model<T> T
getOriginalValue(java.lang.String key)
Retrieves the original loaded value of the attribute.<T> T
getOriginalValue(java.lang.String key, java.util.Locale loc)
Retrieves the original loaded value of the localized attribute with the locale.protected <T> T
getOrLoadLocalized(java.util.Map<java.util.Locale,java.lang.Object> locMap, java.lang.String qualifier, java.util.Locale dataLoc, boolean keepAsOriginal)
PersistenceObject
getPersistenceSource()
long
getPersistenceVersion()
Retrieves the persistence version of the model.PK
getPK()
Retrieves the pk of the model.<T> T
getPropertyValue(java.lang.String attribute)
Returns a value of a property with given name.java.lang.Object
getRawPropertyValue(java.lang.String qualifier)
SerializationStrategy
getSerializationStrategy()
java.lang.Object
getSource()
Retrieves the item of the model.java.lang.String
getTenantId()
Retrieves the tenant id of the model.<T> T
getValue(java.lang.String key, T currentValue)
Retrieves the value of the key.ModelValueHistory
getValueHistory()
int
hashCode()
int
hashCode(AbstractItemModel itemModel)
Calculates the hash code of the model.boolean
isDirty()
Checks if the model has been modified.boolean
isDirty(java.lang.String attribute)
Checks if the specific attribute has been changed.boolean
isDirty(java.lang.String attribute, java.util.Locale loc)
Checks if the specific localized attribute has been changed with the locale.boolean
isDynamicAttribute(java.lang.String attributeName)
Returns information whether given attribute is dynamic or notboolean
isLoaded(java.lang.String attribute)
Checks if the specific attribute has been loaded from the database.boolean
isLoaded(java.lang.String attribute, java.util.Locale loc)
Checks if the specific localized attribute has been loaded with the locale from the database.boolean
isNew()
Checks if the model is a new model.boolean
isRemoved()
Checks if the model has been removed from the database.boolean
isUpToDate()
Checks if the model is still up to date with.protected <T> T
loadLocalized(java.util.Map<java.util.Locale,java.lang.Object> locMap, java.lang.String qualifier, java.util.Locale dataLoc, boolean keepAsOriginal)
protected <T> T
loadLocalized(java.util.Map<java.util.Locale,java.lang.Object> locMap, java.lang.String qualifier, java.util.Locale dataLoc, boolean keepAsOriginal, boolean resetDirty)
java.lang.Object
loadOriginalValue(java.lang.String attribute)
Returns the original value for the given attributejava.lang.Object
loadOriginalValue(java.lang.String attribute, java.util.Locale locale)
Returns the original localized value for the given attributeprotected java.lang.Object
loadUnlocalizedAttribute(java.lang.String key, boolean keepAsOriginalValue, boolean resetDirty)
protected void
markDirty(java.lang.String attribute)
protected void
markDirty(java.lang.String attribute, java.util.Locale dataLocale)
void
setAttributeProvider(AttributeProvider attributeProvider)
void
setDynamicAttributesProvider(DynamicAttributesProvider attributeProvider)
<T> void
setDynamicValue(AbstractItemModel model, java.lang.String attribute, T value)
Sets the dynamic value of the attribute.void
setFetchStrategy(FetchStrategy fetchStrategy)
void
setLocaleProvider(LocaleProvider localeProvider)
<T> void
setLocalizedDynamicValue(AbstractItemModel model, java.lang.String attribute, java.util.Locale loc, T value)
Sets the dynamic value of the attribute under the locale.<T> void
setLocalizedValue(java.lang.String qualifier, java.util.Locale locale, T value)
Sets the new value for the specific attribute with the locale.<T> void
setPropertyValue(java.lang.String attribute, T value)
Allows to set a value of a property with given name.void
setRawPropertyValue(java.lang.String qualifier, java.lang.Object value)
void
setSerializationStrategy(SerializationStrategy strategy)
<T> T
setValue(java.lang.String key, T newValue)
Sets the new value for the specific attribute.protected void
throwLoadingError(java.lang.String qualifier)
protected void
throwLoadingError(java.lang.String qualifier, java.util.Locale dataLocale)
protected java.util.Locale
toDataLocale(java.util.Locale locale)
java.lang.Object
writeReplace(java.lang.Object model)
YXX
-
-
-
Method Detail
-
hashCode
public int hashCode(AbstractItemModel itemModel)
Description copied from interface:ItemModelInternalContext
Calculates the hash code of the model.- Specified by:
hashCode
in interfaceItemModelInternalContext
- Returns:
- the hash code value
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getValueHistory
public ModelValueHistory getValueHistory()
-
isDynamicAttribute
public boolean isDynamicAttribute(java.lang.String attributeName)
Description copied from interface:ItemModelInternalContext
Returns information whether given attribute is dynamic or not- Specified by:
isDynamicAttribute
in interfaceItemModelInternalContext
- Parameters:
attributeName
- attribute name- Returns:
- true if attribute is dynamic, false otherwise
-
writeReplace
public java.lang.Object writeReplace(java.lang.Object model) throws java.io.ObjectStreamException
Description copied from interface:ItemModelInternalContext
YXX- Specified by:
writeReplace
in interfaceItemModelInternalContext
- Throws:
java.io.ObjectStreamException
-
getPK
public PK getPK()
Description copied from interface:ItemModelContext
Retrieves the pk of the model.- Specified by:
getPK
in interfaceItemModelContext
-
getItemType
public java.lang.String getItemType()
Description copied from interface:ItemModelContext
Retrieves the item type of the model.- Specified by:
getItemType
in interfaceItemModelContext
-
getPersistenceVersion
public long getPersistenceVersion()
Description copied from interface:ItemModelContext
Retrieves the persistence version of the model.- Specified by:
getPersistenceVersion
in interfaceItemModelContext
-
getSource
public java.lang.Object getSource()
Description copied from interface:ItemModelContext
Retrieves the item of the model.- Specified by:
getSource
in interfaceItemModelContext
- Returns:
- the behind scene jalo item.
-
getPersistenceSource
public PersistenceObject getPersistenceSource()
-
isDirty
public boolean isDirty()
Description copied from interface:ItemModelContext
Checks if the model has been modified.- Specified by:
isDirty
in interfaceItemModelContext
- Returns:
- true if the model has been modified, false otherwise
-
exists
public boolean exists()
Description copied from interface:ItemModelContext
Checks if the model is still valid. NOTE: if the model is a new one, this method must return false, because it is not persisted in the database yet.- Specified by:
exists
in interfaceItemModelContext
- Returns:
- true if it is valid, false otherwise.
-
isRemoved
public boolean isRemoved()
Description copied from interface:ItemModelContext
Checks if the model has been removed from the database. NOTE: if the model is a new one, this method must return false, because a new model cannot be removed.- Specified by:
isRemoved
in interfaceItemModelContext
- Returns:
- true if removed, false otherwise.
-
isUpToDate
public boolean isUpToDate()
Description copied from interface:ItemModelContext
Checks if the model is still up to date with.-
This method must return false under one of these situations:
- the model is new,
- the model has been removed,
- the model has been modified, or
- there is newer version persisted in the database.
- Specified by:
isUpToDate
in interfaceItemModelContext
- Returns:
- true if it is up to date, false otherwise.
-
isNew
public boolean isNew()
Description copied from interface:ItemModelContext
Checks if the model is a new model. That means it is not persisted in the database.- Specified by:
isNew
in interfaceItemModelContext
- Returns:
- true if it is new, false otherwise.
-
getValue
public <T> T getValue(java.lang.String key, T currentValue)
Retrieves the value of the key. NOTE: the value will be fetched only if it is neither set nor loaded. For example, the method getCode() won't fetch the "code" attribute from the database if the setCode() has been called before.- Specified by:
getValue
in interfaceItemModelInternalContext
- Returns:
- the current value.
-
getPropertyValue
public <T> T getPropertyValue(java.lang.String attribute)
Description copied from interface:ItemModelInternalContext
Returns a value of a property with given name.- Specified by:
getPropertyValue
in interfaceItemModelInternalContext
- Parameters:
attribute
- name- Returns:
- value of property with given name
-
setPropertyValue
public <T> void setPropertyValue(java.lang.String attribute, T value)
Description copied from interface:ItemModelInternalContext
Allows to set a value of a property with given name.- Specified by:
setPropertyValue
in interfaceItemModelInternalContext
- Parameters:
attribute
- namevalue
- value to set
-
getRawPropertyValue
public java.lang.Object getRawPropertyValue(java.lang.String qualifier)
-
setRawPropertyValue
public void setRawPropertyValue(java.lang.String qualifier, java.lang.Object value)
-
loadUnlocalizedAttribute
protected java.lang.Object loadUnlocalizedAttribute(java.lang.String key, boolean keepAsOriginalValue, boolean resetDirty)
-
setValue
public <T> T setValue(java.lang.String key, T newValue)
Description copied from interface:ItemModelInternalContext
Sets the new value for the specific attribute.- Specified by:
setValue
in interfaceItemModelInternalContext
- Returns:
- the new value of the attribute.
-
getDirtyAttributes
public java.util.Set<java.lang.String> getDirtyAttributes()
Description copied from interface:ItemModelContext
Returns all changed attributes.- Specified by:
getDirtyAttributes
in interfaceItemModelContext
- Returns:
- the set of all changed attributes.
-
isDirty
public boolean isDirty(java.lang.String attribute)
Description copied from interface:ItemModelContext
Checks if the specific attribute has been changed.- Specified by:
isDirty
in interfaceItemModelContext
- Returns:
- true if changed, false otherwise.
-
isLoaded
public boolean isLoaded(java.lang.String attribute)
Description copied from interface:ItemModelContext
Checks if the specific attribute has been loaded from the database.- Specified by:
isLoaded
in interfaceItemModelContext
- Returns:
- true if loaded, false otherwise.
-
getOriginalValue
public <T> T getOriginalValue(java.lang.String key)
Description copied from interface:ItemModelContext
Retrieves the original loaded value of the attribute.- Specified by:
getOriginalValue
in interfaceItemModelContext
- Returns:
- the original value.
-
loadOriginalValue
public java.lang.Object loadOriginalValue(java.lang.String attribute)
Description copied from interface:ItemModelInternalContext
Returns the original value for the given attribute- Specified by:
loadOriginalValue
in interfaceItemModelInternalContext
- Parameters:
attribute
- attribute name- Returns:
- original value of the given attribute
-
loadOriginalValue
public java.lang.Object loadOriginalValue(java.lang.String attribute, java.util.Locale locale)
Description copied from interface:ItemModelInternalContext
Returns the original localized value for the given attribute- Specified by:
loadOriginalValue
in interfaceItemModelInternalContext
- Parameters:
attribute
- attribute namelocale
- locale name- Returns:
- original value of the given attribute
-
getDynamicValue
public <T> T getDynamicValue(AbstractItemModel model, java.lang.String attribute)
Description copied from interface:ItemModelInternalContext
Retrieves the dynamic value of the attribute.- Specified by:
getDynamicValue
in interfaceItemModelInternalContext
- Parameters:
model
- YTODO- Returns:
- the dynamic value.
-
setDynamicValue
public <T> void setDynamicValue(AbstractItemModel model, java.lang.String attribute, T value)
Description copied from interface:ItemModelInternalContext
Sets the dynamic value of the attribute.- Specified by:
setDynamicValue
in interfaceItemModelInternalContext
- Parameters:
model
- YTODO
-
getLocalizedDynamicValue
public <T> T getLocalizedDynamicValue(AbstractItemModel model, java.lang.String attribute, java.util.Locale loc)
Description copied from interface:ItemModelInternalContext
Retrieves the dynamic value of the attribute with the local.- Specified by:
getLocalizedDynamicValue
in interfaceItemModelInternalContext
- Parameters:
model
- YTODO- Returns:
- the dynamic value.
-
setLocalizedDynamicValue
public <T> void setLocalizedDynamicValue(AbstractItemModel model, java.lang.String attribute, java.util.Locale loc, T value)
Description copied from interface:ItemModelInternalContext
Sets the dynamic value of the attribute under the locale.- Specified by:
setLocalizedDynamicValue
in interfaceItemModelInternalContext
- Parameters:
model
- YTODO
-
getLocalizedValue
public <T> T getLocalizedValue(java.lang.String key, java.util.Locale locale)
Retrieves the localized value of the key. NOTE: the value will be fetched only if it is neither set nor loaded. For example, the method getName(Locale.GERMANY) won't fetch the German "name" attribute from the database if the setName("German_name", Locale.GERMANY) has been called before.- Specified by:
getLocalizedValue
in interfaceItemModelInternalContext
- Returns:
- the current value with the locale.
-
getLocalizedRelationValue
public <T> T getLocalizedRelationValue(java.lang.String key, java.util.Locale locale)
Description copied from interface:ItemModelInternalContext
Retrieves the current value of the specific attribute with the locale.- Specified by:
getLocalizedRelationValue
in interfaceItemModelInternalContext
- Returns:
- the current value with the locale.
-
getLocalizedWithFallback
protected java.lang.Object getLocalizedWithFallback(java.util.Map<java.util.Locale,java.lang.Object> attrLocMap, java.lang.String qualifier, java.util.Locale dataLocale, boolean keepOriginals, boolean isRelationAttribute) throws java.lang.IllegalArgumentException
- Throws:
java.lang.IllegalArgumentException
-
getOrLoadLocalized
protected <T> T getOrLoadLocalized(java.util.Map<java.util.Locale,java.lang.Object> locMap, java.lang.String qualifier, java.util.Locale dataLoc, boolean keepAsOriginal)
-
loadLocalized
protected <T> T loadLocalized(java.util.Map<java.util.Locale,java.lang.Object> locMap, java.lang.String qualifier, java.util.Locale dataLoc, boolean keepAsOriginal)
-
loadLocalized
protected <T> T loadLocalized(java.util.Map<java.util.Locale,java.lang.Object> locMap, java.lang.String qualifier, java.util.Locale dataLoc, boolean keepAsOriginal, boolean resetDirty)
-
toDataLocale
protected java.util.Locale toDataLocale(java.util.Locale locale) throws java.lang.IllegalArgumentException
- Throws:
java.lang.IllegalArgumentException
-
setLocalizedValue
public <T> void setLocalizedValue(java.lang.String qualifier, java.util.Locale locale, T value)
Description copied from interface:ItemModelInternalContext
Sets the new value for the specific attribute with the locale.- Specified by:
setLocalizedValue
in interfaceItemModelInternalContext
-
isDirty
public boolean isDirty(java.lang.String attribute, java.util.Locale loc)
Description copied from interface:ItemModelContext
Checks if the specific localized attribute has been changed with the locale.- Specified by:
isDirty
in interfaceItemModelContext
- Returns:
- true if changed, false otherwise.
-
isLoaded
public boolean isLoaded(java.lang.String attribute, java.util.Locale loc)
Description copied from interface:ItemModelContext
Checks if the specific localized attribute has been loaded with the locale from the database.- Specified by:
isLoaded
in interfaceItemModelContext
- Returns:
- true if loaded, false otherwise.
-
getOriginalValue
public <T> T getOriginalValue(java.lang.String key, java.util.Locale loc)
Description copied from interface:ItemModelContext
Retrieves the original loaded value of the localized attribute with the locale.- Specified by:
getOriginalValue
in interfaceItemModelContext
- Returns:
- the original localized value with the locale.
-
getDirtyLocalizedAttributes
public java.util.Map<java.util.Locale,java.util.Set<java.lang.String>> getDirtyLocalizedAttributes()
Description copied from interface:ItemModelContext
Returns all changed localized attributes with the locale.- Specified by:
getDirtyLocalizedAttributes
in interfaceItemModelContext
- Returns:
- the set of all changed localized attributes with the locale.
-
throwLoadingError
protected void throwLoadingError(java.lang.String qualifier)
-
throwLoadingError
protected void throwLoadingError(java.lang.String qualifier, java.util.Locale dataLocale)
-
markDirty
protected void markDirty(java.lang.String attribute)
-
markDirty
protected void markDirty(java.lang.String attribute, java.util.Locale dataLocale)
-
getCurrentLocale
protected java.util.Locale getCurrentLocale() throws java.lang.IllegalStateException
- Throws:
java.lang.IllegalStateException
-
getSerializationStrategy
public SerializationStrategy getSerializationStrategy()
-
getLocaleProvider
public LocaleProvider getLocaleProvider(boolean required)
-
setLocaleProvider
public void setLocaleProvider(LocaleProvider localeProvider)
-
getDynamicAttributesProvider
public DynamicAttributesProvider getDynamicAttributesProvider()
-
getFetchStrategy
protected FetchStrategy getFetchStrategy()
-
getTenantId
public java.lang.String getTenantId()
Description copied from interface:ItemModelContext
Retrieves the tenant id of the model.- Specified by:
getTenantId
in interfaceItemModelContext
-
getCombinedLocalizedValuesMap
public java.util.Map<java.lang.String,LocMap<java.util.Locale,java.lang.Object>> getCombinedLocalizedValuesMap()
-
beforeAttach
public void beforeAttach(LocaleProvider localeProvider)
-
setAttributeProvider
public void setAttributeProvider(AttributeProvider attributeProvider)
-
getAttributeProvider
public AttributeProvider getAttributeProvider()
-
setDynamicAttributesProvider
public void setDynamicAttributesProvider(DynamicAttributesProvider attributeProvider)
-
afterCreate
public void afterCreate(LocaleProvider locProvider, AttributeProvider attrProvider, DynamicAttributesProvider dynProvider, PK pk, long persistenceVersion, java.lang.String typeCode)
-
afterUpdate
public void afterUpdate(long persistenceVersion)
-
afterReload
public void afterReload(long persistenceVersion)
-
setFetchStrategy
public void setFetchStrategy(FetchStrategy fetchStrategy)
-
setSerializationStrategy
public void setSerializationStrategy(SerializationStrategy strategy)
-
getNewPK
public PK getNewPK()
Description copied from interface:ItemModelInternalContext
Returns the newPK assigned to the current model- Specified by:
getNewPK
in interfaceItemModelInternalContext
- Returns:
- new PK for the not saved model
-
generateNewPK
public PK generateNewPK()
Description copied from interface:ItemModelInternalContext
Generate the new PK and assigns it to the current model. Will be generated only for new models if the new PK has not been generated yet- Specified by:
generateNewPK
in interfaceItemModelInternalContext
- Returns:
- new generated PK for the not saved model
-
-