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 voidafterCreate(LocaleProvider locProvider, AttributeProvider attrProvider, DynamicAttributesProvider dynProvider, PK pk, long persistenceVersion, java.lang.String typeCode)voidafterReload(long persistenceVersion)voidafterUpdate(long persistenceVersion)voidbeforeAttach(LocaleProvider localeProvider)booleanequals(java.lang.Object obj)booleanexists()Checks if the model is still valid.PKgenerateNewPK()Generate the new PK and assigns it to the current model.AttributeProvidergetAttributeProvider()java.util.Map<java.lang.String,LocMap<java.util.Locale,java.lang.Object>>getCombinedLocalizedValuesMap()protected java.util.LocalegetCurrentLocale()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.DynamicAttributesProvidergetDynamicAttributesProvider()<T> TgetDynamicValue(AbstractItemModel model, java.lang.String attribute)Retrieves the dynamic value of the attribute.protected FetchStrategygetFetchStrategy()java.lang.StringgetItemType()Retrieves the item type of the model.LocaleProvidergetLocaleProvider(boolean required)<T> TgetLocalizedDynamicValue(AbstractItemModel model, java.lang.String attribute, java.util.Locale loc)Retrieves the dynamic value of the attribute with the local.<T> TgetLocalizedRelationValue(java.lang.String key, java.util.Locale locale)Retrieves the current value of the specific attribute with the locale.<T> TgetLocalizedValue(java.lang.String key, java.util.Locale locale)Retrieves the localized value of the key.protected java.lang.ObjectgetLocalizedWithFallback(java.util.Map<java.util.Locale,java.lang.Object> attrLocMap, java.lang.String qualifier, java.util.Locale dataLocale, boolean keepOriginals, boolean isRelationAttribute)PKgetNewPK()Returns the newPK assigned to the current model<T> TgetOriginalValue(java.lang.String key)Retrieves the original loaded value of the attribute.<T> TgetOriginalValue(java.lang.String key, java.util.Locale loc)Retrieves the original loaded value of the localized attribute with the locale.protected <T> TgetOrLoadLocalized(java.util.Map<java.util.Locale,java.lang.Object> locMap, java.lang.String qualifier, java.util.Locale dataLoc, boolean keepAsOriginal)PersistenceObjectgetPersistenceSource()longgetPersistenceVersion()Retrieves the persistence version of the model.PKgetPK()Retrieves the pk of the model.<T> TgetPropertyValue(java.lang.String attribute)Returns a value of a property with given name.java.lang.ObjectgetRawPropertyValue(java.lang.String qualifier)SerializationStrategygetSerializationStrategy()java.lang.ObjectgetSource()Retrieves the item of the model.java.lang.StringgetTenantId()Retrieves the tenant id of the model.<T> TgetValue(java.lang.String key, T currentValue)Retrieves the value of the key.ModelValueHistorygetValueHistory()inthashCode()inthashCode(AbstractItemModel itemModel)Calculates the hash code of the model.booleanisDirty()Checks if the model has been modified.booleanisDirty(java.lang.String attribute)Checks if the specific attribute has been changed.booleanisDirty(java.lang.String attribute, java.util.Locale loc)Checks if the specific localized attribute has been changed with the locale.booleanisDynamicAttribute(java.lang.String attributeName)Returns information whether given attribute is dynamic or notbooleanisLoaded(java.lang.String attribute)Checks if the specific attribute has been loaded from the database.booleanisLoaded(java.lang.String attribute, java.util.Locale loc)Checks if the specific localized attribute has been loaded with the locale from the database.booleanisNew()Checks if the model is a new model.booleanisRemoved()Checks if the model has been removed from the database.booleanisUpToDate()Checks if the model is still up to date with.protected <T> TloadLocalized(java.util.Map<java.util.Locale,java.lang.Object> locMap, java.lang.String qualifier, java.util.Locale dataLoc, boolean keepAsOriginal)protected <T> TloadLocalized(java.util.Map<java.util.Locale,java.lang.Object> locMap, java.lang.String qualifier, java.util.Locale dataLoc, boolean keepAsOriginal, boolean resetDirty)java.lang.ObjectloadOriginalValue(java.lang.String attribute)Returns the original value for the given attributejava.lang.ObjectloadOriginalValue(java.lang.String attribute, java.util.Locale locale)Returns the original localized value for the given attributeprotected java.lang.ObjectloadUnlocalizedAttribute(java.lang.String key, boolean keepAsOriginalValue, boolean resetDirty)protected voidmarkDirty(java.lang.String attribute)protected voidmarkDirty(java.lang.String attribute, java.util.Locale dataLocale)voidsetAttributeProvider(AttributeProvider attributeProvider)voidsetDynamicAttributesProvider(DynamicAttributesProvider attributeProvider)<T> voidsetDynamicValue(AbstractItemModel model, java.lang.String attribute, T value)Sets the dynamic value of the attribute.voidsetFetchStrategy(FetchStrategy fetchStrategy)voidsetLocaleProvider(LocaleProvider localeProvider)<T> voidsetLocalizedDynamicValue(AbstractItemModel model, java.lang.String attribute, java.util.Locale loc, T value)Sets the dynamic value of the attribute under the locale.<T> voidsetLocalizedValue(java.lang.String qualifier, java.util.Locale locale, T value)Sets the new value for the specific attribute with the locale.<T> voidsetPropertyValue(java.lang.String attribute, T value)Allows to set a value of a property with given name.voidsetRawPropertyValue(java.lang.String qualifier, java.lang.Object value)voidsetSerializationStrategy(SerializationStrategy strategy)<T> TsetValue(java.lang.String key, T newValue)Sets the new value for the specific attribute.protected voidthrowLoadingError(java.lang.String qualifier)protected voidthrowLoadingError(java.lang.String qualifier, java.util.Locale dataLocale)protected java.util.LocaletoDataLocale(java.util.Locale locale)java.lang.ObjectwriteReplace(java.lang.Object model)YXX
-
-
-
Method Detail
-
hashCode
public int hashCode(AbstractItemModel itemModel)
Description copied from interface:ItemModelInternalContextCalculates the hash code of the model.- Specified by:
hashCodein interfaceItemModelInternalContext- Returns:
- the hash code value
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getValueHistory
public ModelValueHistory getValueHistory()
-
isDynamicAttribute
public boolean isDynamicAttribute(java.lang.String attributeName)
Description copied from interface:ItemModelInternalContextReturns information whether given attribute is dynamic or not- Specified by:
isDynamicAttributein 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.ObjectStreamExceptionDescription copied from interface:ItemModelInternalContextYXX- Specified by:
writeReplacein interfaceItemModelInternalContext- Throws:
java.io.ObjectStreamException
-
getPK
public PK getPK()
Description copied from interface:ItemModelContextRetrieves the pk of the model.- Specified by:
getPKin interfaceItemModelContext
-
getItemType
public java.lang.String getItemType()
Description copied from interface:ItemModelContextRetrieves the item type of the model.- Specified by:
getItemTypein interfaceItemModelContext
-
getPersistenceVersion
public long getPersistenceVersion()
Description copied from interface:ItemModelContextRetrieves the persistence version of the model.- Specified by:
getPersistenceVersionin interfaceItemModelContext
-
getSource
public java.lang.Object getSource()
Description copied from interface:ItemModelContextRetrieves the item of the model.- Specified by:
getSourcein interfaceItemModelContext- Returns:
- the behind scene jalo item.
-
getPersistenceSource
public PersistenceObject getPersistenceSource()
-
isDirty
public boolean isDirty()
Description copied from interface:ItemModelContextChecks if the model has been modified.- Specified by:
isDirtyin interfaceItemModelContext- Returns:
- true if the model has been modified, false otherwise
-
exists
public boolean exists()
Description copied from interface:ItemModelContextChecks 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:
existsin interfaceItemModelContext- Returns:
- true if it is valid, false otherwise.
-
isRemoved
public boolean isRemoved()
Description copied from interface:ItemModelContextChecks 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:
isRemovedin interfaceItemModelContext- Returns:
- true if removed, false otherwise.
-
isUpToDate
public boolean isUpToDate()
Description copied from interface:ItemModelContextChecks 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:
isUpToDatein interfaceItemModelContext- Returns:
- true if it is up to date, false otherwise.
-
isNew
public boolean isNew()
Description copied from interface:ItemModelContextChecks if the model is a new model. That means it is not persisted in the database.- Specified by:
isNewin 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:
getValuein interfaceItemModelInternalContext- Returns:
- the current value.
-
getPropertyValue
public <T> T getPropertyValue(java.lang.String attribute)
Description copied from interface:ItemModelInternalContextReturns a value of a property with given name.- Specified by:
getPropertyValuein 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:ItemModelInternalContextAllows to set a value of a property with given name.- Specified by:
setPropertyValuein 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:ItemModelInternalContextSets the new value for the specific attribute.- Specified by:
setValuein interfaceItemModelInternalContext- Returns:
- the new value of the attribute.
-
getDirtyAttributes
public java.util.Set<java.lang.String> getDirtyAttributes()
Description copied from interface:ItemModelContextReturns all changed attributes.- Specified by:
getDirtyAttributesin interfaceItemModelContext- Returns:
- the set of all changed attributes.
-
isDirty
public boolean isDirty(java.lang.String attribute)
Description copied from interface:ItemModelContextChecks if the specific attribute has been changed.- Specified by:
isDirtyin interfaceItemModelContext- Returns:
- true if changed, false otherwise.
-
isLoaded
public boolean isLoaded(java.lang.String attribute)
Description copied from interface:ItemModelContextChecks if the specific attribute has been loaded from the database.- Specified by:
isLoadedin interfaceItemModelContext- Returns:
- true if loaded, false otherwise.
-
getOriginalValue
public <T> T getOriginalValue(java.lang.String key)
Description copied from interface:ItemModelContextRetrieves the original loaded value of the attribute.- Specified by:
getOriginalValuein interfaceItemModelContext- Returns:
- the original value.
-
loadOriginalValue
public java.lang.Object loadOriginalValue(java.lang.String attribute)
Description copied from interface:ItemModelInternalContextReturns the original value for the given attribute- Specified by:
loadOriginalValuein 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:ItemModelInternalContextReturns the original localized value for the given attribute- Specified by:
loadOriginalValuein 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:ItemModelInternalContextRetrieves the dynamic value of the attribute.- Specified by:
getDynamicValuein 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:ItemModelInternalContextSets the dynamic value of the attribute.- Specified by:
setDynamicValuein interfaceItemModelInternalContext- Parameters:
model- YTODO
-
getLocalizedDynamicValue
public <T> T getLocalizedDynamicValue(AbstractItemModel model, java.lang.String attribute, java.util.Locale loc)
Description copied from interface:ItemModelInternalContextRetrieves the dynamic value of the attribute with the local.- Specified by:
getLocalizedDynamicValuein 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:ItemModelInternalContextSets the dynamic value of the attribute under the locale.- Specified by:
setLocalizedDynamicValuein 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:
getLocalizedValuein 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:ItemModelInternalContextRetrieves the current value of the specific attribute with the locale.- Specified by:
getLocalizedRelationValuein 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:ItemModelInternalContextSets the new value for the specific attribute with the locale.- Specified by:
setLocalizedValuein interfaceItemModelInternalContext
-
isDirty
public boolean isDirty(java.lang.String attribute, java.util.Locale loc)Description copied from interface:ItemModelContextChecks if the specific localized attribute has been changed with the locale.- Specified by:
isDirtyin interfaceItemModelContext- Returns:
- true if changed, false otherwise.
-
isLoaded
public boolean isLoaded(java.lang.String attribute, java.util.Locale loc)Description copied from interface:ItemModelContextChecks if the specific localized attribute has been loaded with the locale from the database.- Specified by:
isLoadedin interfaceItemModelContext- Returns:
- true if loaded, false otherwise.
-
getOriginalValue
public <T> T getOriginalValue(java.lang.String key, java.util.Locale loc)Description copied from interface:ItemModelContextRetrieves the original loaded value of the localized attribute with the locale.- Specified by:
getOriginalValuein 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:ItemModelContextReturns all changed localized attributes with the locale.- Specified by:
getDirtyLocalizedAttributesin 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:ItemModelContextRetrieves the tenant id of the model.- Specified by:
getTenantIdin 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:ItemModelInternalContextReturns the newPK assigned to the current model- Specified by:
getNewPKin interfaceItemModelInternalContext- Returns:
- new PK for the not saved model
-
generateNewPK
public PK generateNewPK()
Description copied from interface:ItemModelInternalContextGenerate 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:
generateNewPKin interfaceItemModelInternalContext- Returns:
- new generated PK for the not saved model
-
-