Class ItemModelContextImpl
java.lang.Object
de.hybris.platform.servicelayer.model.ItemModelContextImpl
- All Implemented Interfaces:
ItemModelContext,ItemModelInternalContext,Serializable
Default implementation for
ItemModelContext.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidafterCreate(LocaleProvider locProvider, AttributeProvider attrProvider, DynamicAttributesProvider dynProvider, PK pk, long persistenceVersion, String typeCode) voidafterReload(long persistenceVersion) voidafterUpdate(long persistenceVersion) voidbeforeAttach(LocaleProvider localeProvider) booleanbooleanexists()Checks if the model is still valid.Generate the new PK and assigns it to the current model.protected LocaleReturns all changed attributes.Returns all changed localized attributes with the locale.<T> TgetDynamicValue(AbstractItemModel model, String attribute) Retrieves the dynamic value of the attribute.protected FetchStrategyRetrieves the item type of the model.getLocaleProvider(boolean required) <T> TgetLocalizedDynamicValue(AbstractItemModel model, String attribute, Locale loc) Retrieves the dynamic value of the attribute with the local.<T> TgetLocalizedRelationValue(String key, Locale locale) Retrieves the current value of the specific attribute with the locale.<T> TgetLocalizedValue(String key, Locale locale) Retrieves the localized value of the key.protected ObjectgetLocalizedWithFallback(Map<Locale, Object> attrLocMap, String qualifier, Locale dataLocale, boolean keepOriginals, boolean isRelationAttribute) getNewPK()Returns the newPK assigned to the current model<T> TgetOriginalValue(String key) Retrieves the original loaded value of the attribute.<T> TgetOriginalValue(String key, Locale loc) Retrieves the original loaded value of the localized attribute with the locale.protected <T> TgetOrLoadLocalized(Map<Locale, Object> locMap, String qualifier, Locale dataLoc, boolean keepAsOriginal) longRetrieves the persistence version of the model.getPK()Retrieves the pk of the model.<T> TgetPropertyValue(String attribute) Returns a value of a property with given name.getRawPropertyValue(String qualifier) Retrieves the item of the model.Retrieves the tenant id of the model.<T> TRetrieves the value of the key.inthashCode()inthashCode(AbstractItemModel itemModel) Calculates the hash code of the model.booleanisDirty()Checks if the model has been modified.booleanChecks if the specific attribute has been changed.booleanChecks if the specific localized attribute has been changed with the locale.booleanisDynamicAttribute(String attributeName) Returns information whether given attribute is dynamic or notbooleanChecks if the specific attribute has been loaded from the database.booleanChecks if the specific localized attribute has been loaded with the locale from the database.booleanisNew()Checks if the model is a new model.booleanChecks if the model has been removed from the database.booleanChecks if the model is still up to date with.protected <T> Tprotected <T> TloadLocalized(Map<Locale, Object> locMap, String qualifier, Locale dataLoc, boolean keepAsOriginal, boolean resetDirty) loadOriginalValue(String attribute) Returns the original value for the given attributeloadOriginalValue(String attribute, Locale locale) Returns the original localized value for the given attributeprotected ObjectloadUnlocalizedAttribute(String key, boolean keepAsOriginalValue, boolean resetDirty) protected voidprotected voidvoidsetAttributeProvider(AttributeProvider attributeProvider) voidsetDynamicAttributesProvider(DynamicAttributesProvider attributeProvider) <T> voidsetDynamicValue(AbstractItemModel model, String attribute, T value) Sets the dynamic value of the attribute.voidsetFetchStrategy(FetchStrategy fetchStrategy) voidsetLocaleProvider(LocaleProvider localeProvider) <T> voidsetLocalizedDynamicValue(AbstractItemModel model, String attribute, Locale loc, T value) Sets the dynamic value of the attribute under the locale.<T> voidsetLocalizedValue(String qualifier, Locale locale, T value) Sets the new value for the specific attribute with the locale.<T> voidsetPropertyValue(String attribute, T value) Allows to set a value of a property with given name.voidsetRawPropertyValue(String qualifier, Object value) void<T> TSets the new value for the specific attribute.protected voidthrowLoadingError(String qualifier) protected voidthrowLoadingError(String qualifier, Locale dataLocale) protected LocaletoDataLocale(Locale locale) voidunloadAttribute(String attribute) Unloads the given attributewriteReplace(Object model) YXX
-
Method Details
-
hashCode
Description copied from interface:ItemModelInternalContextCalculates the hash code of the model.- Specified by:
hashCodein interfaceItemModelInternalContext- Returns:
- the hash code value
-
equals
-
hashCode
public int hashCode() -
getValueHistory
-
isDynamicAttribute
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
Description copied from interface:ItemModelInternalContextYXX- Specified by:
writeReplacein interfaceItemModelInternalContext- Throws:
ObjectStreamException
-
getPK
Description copied from interface:ItemModelContextRetrieves the pk of the model.- Specified by:
getPKin interfaceItemModelContext
-
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
Description copied from interface:ItemModelContextRetrieves the item of the model.- Specified by:
getSourcein interfaceItemModelContext- Returns:
- the behind scene jalo item.
-
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
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
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
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
-
setRawPropertyValue
-
loadUnlocalizedAttribute
-
setValue
Description copied from interface:ItemModelInternalContextSets the new value for the specific attribute.- Specified by:
setValuein interfaceItemModelInternalContext- Returns:
- the new value of the attribute.
-
getDirtyAttributes
Description copied from interface:ItemModelContextReturns all changed attributes.- Specified by:
getDirtyAttributesin interfaceItemModelContext- Returns:
- the set of all changed attributes.
-
isDirty
Description copied from interface:ItemModelContextChecks if the specific attribute has been changed.- Specified by:
isDirtyin interfaceItemModelContext- Returns:
- true if changed, false otherwise.
-
isLoaded
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
Description copied from interface:ItemModelContextRetrieves the original loaded value of the attribute.- Specified by:
getOriginalValuein interfaceItemModelContext- Returns:
- the original value.
-
loadOriginalValue
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
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
Description copied from interface:ItemModelInternalContextRetrieves the dynamic value of the attribute.- Specified by:
getDynamicValuein interfaceItemModelInternalContext- Parameters:
model- YTODO- Returns:
- the dynamic value.
-
setDynamicValue
Description copied from interface:ItemModelInternalContextSets the dynamic value of the attribute.- Specified by:
setDynamicValuein interfaceItemModelInternalContext- Parameters:
model- YTODO
-
getLocalizedDynamicValue
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, String attribute, 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
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
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 Object getLocalizedWithFallback(Map<Locale, Object> attrLocMap, String qualifier, Locale dataLocale, boolean keepOriginals, boolean isRelationAttribute) throws IllegalArgumentException- Throws:
IllegalArgumentException
-
getOrLoadLocalized
-
loadLocalized
-
loadLocalized
-
toDataLocale
- Throws:
IllegalArgumentException
-
setLocalizedValue
Description copied from interface:ItemModelInternalContextSets the new value for the specific attribute with the locale.- Specified by:
setLocalizedValuein interfaceItemModelInternalContext
-
isDirty
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
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
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
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
-
throwLoadingError
-
markDirty
-
markDirty
-
getCurrentLocale
- Throws:
IllegalStateException
-
getSerializationStrategy
-
getLocaleProvider
-
setLocaleProvider
-
getDynamicAttributesProvider
-
getFetchStrategy
-
getTenantId
Description copied from interface:ItemModelContextRetrieves the tenant id of the model.- Specified by:
getTenantIdin interfaceItemModelContext
-
getCombinedLocalizedValuesMap
-
beforeAttach
-
setAttributeProvider
-
getAttributeProvider
-
setDynamicAttributesProvider
-
afterCreate
public void afterCreate(LocaleProvider locProvider, AttributeProvider attrProvider, DynamicAttributesProvider dynProvider, PK pk, long persistenceVersion, String typeCode) -
afterUpdate
public void afterUpdate(long persistenceVersion) -
afterReload
public void afterReload(long persistenceVersion) -
setFetchStrategy
-
setSerializationStrategy
-
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
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
-
unloadAttribute
Description copied from interface:ItemModelInternalContextUnloads the given attribute- Specified by:
unloadAttributein interfaceItemModelInternalContext- Parameters:
attribute- attribute name
-