Class LocalizableItem
- java.lang.Object
-
- de.hybris.platform.util.BridgeAbstraction
-
- de.hybris.platform.jalo.Item
-
- de.hybris.platform.jalo.ExtensibleItem
-
- de.hybris.platform.jalo.c2l.LocalizableItem
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable
- Direct Known Subclasses:
EnumerationValue
,GenericItem
,TestItem
,TypeManagerManaged
public abstract class LocalizableItem extends ExtensibleItem
The superclass of all items which can have localized properties. Please not that despite of the name the properties are loclized but not the item itself.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
LocalizableItem.LocalizableItemImpl
interface to persistence layer-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.ExtensibleItem
ExtensibleItem.ExtensibleItemImpl
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.Item
Item.AttributeFilter, Item.AttributeMode, Item.CachedGetter, Item.CachedSetter, Item.ItemAttributeMap, Item.ItemConstraint, Item.ItemImpl, Item.JaloCachedComputationException
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
LANGUAGE_FALLBACK_ENABLED
Session context parameter which enables language fallback for for all localized property read operations.-
Fields inherited from class de.hybris.platform.jalo.Item
_CREATION_TIME_INTERNAL, _MODIFIED_TIME_INTERNAL, accessorLog, CREATION_TIME, DISABLE_ATTRIBUTE_CHECK, DISABLE_ITEMCHECK_BEFORE_REMOVABLE, EVEN, FEATURE_ACCESSMAP_QUALIFIER, HJMPTS, INITIAL_CREATION_FLAG, isJaloOnly, MODIFIED_TIME, NEGATIVE, NOT_FOUND, OWNER, PK, POSITIVE, SAVE_FROM_SERVICE_LAYER, staticTransientObjects, TYPE
-
Fields inherited from class de.hybris.platform.util.BridgeAbstraction
impl, tenant
-
-
Constructor Summary
Constructors Constructor Description LocalizableItem()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map
getAllLocalizedProperties()
Returns all localized properties in the current session language as as Map of key/value mappings.java.util.Map
getAllLocalizedProperties(SessionContext ctx)
Returns all localized properties in given SessionContext language as as Map of key/value mappings.java.util.Map<Language,?>
getAllLocalizedProperties(SessionContext ctx, java.lang.String name, java.util.Set<Language> languages)
Returns all values of a localized property according to a specified set of languages.java.util.Map<Language,?>
getAllLocalizedProperties(java.lang.String name, java.util.Set<Language> languages)
Returns all values of a localized property according to a specified set of languages.protected SessionContext
getAllValuesSessionContext(SessionContext ctx)
creates a session context instance for getting all localized property values usinggetLocalizedProperty(SessionContext, String)
.java.lang.Object
getLocalizedProperty(SessionContext ctx, java.lang.String name)
Returns the value of a localized property.java.lang.Object
getLocalizedProperty(java.lang.String name)
Returns the value of a localized property.protected java.lang.Object
getLocalizedPropertyInternal(SessionContext ctx, java.lang.String name)
Non-language-fallback implementation forgetLocalizedProperty(SessionContext, String)
.java.util.Set
getLocalizedPropertyNames()
Returns the qualifiers of all localized properties of this item.java.util.Set
getLocalizedPropertyNames(SessionContext ctx)
Returns the qualifiers of all localized properties of this item.protected boolean
hasLanguage(SessionContext ctx)
protected boolean
isEmptyValue(SessionContext ctx, java.lang.String name, java.lang.Object value)
Override this method to implement different language fallback behaviour.protected boolean
isFallbackEnabled(SessionContext ctx)
java.lang.Object
removeLocalizedProperty(SessionContext ctx, java.lang.String name)
Removes a localized property from this item.java.lang.Object
removeLocalizedProperty(java.lang.String name)
Removes a localized property from this item.java.util.Map<Language,?>
setAllLocalizedProperties(SessionContext ctx, java.lang.String name, java.util.Map<Language,?> values)
Changes multiple localized values of one property at once.java.util.Map<Language,?>
setAllLocalizedProperties(java.lang.String name, java.util.Map<Language,?> values)
Changes multiple localized values of one property at once.java.lang.Object
setLocalizedProperty(SessionContext ctx, java.lang.String name, java.lang.Object value)
Sets the value of a localized property.java.lang.Object
setLocalizedProperty(java.lang.String name, java.lang.Object value)
Sets the value of a localized property.-
Methods inherited from class de.hybris.platform.jalo.ExtensibleItem
createNonClassAccessor, getAllProperties, getAllProperties, getImplementation, getProperty, getProperty, getPropertyNames, getPropertyNames, removeProperty, removeProperty, setAllProperties, setAllProperties, setProperty, setProperty
-
Methods inherited from class de.hybris.platform.jalo.Item
addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addNegativePermission, addPermission, addPositivePermission, assureExtensionsLoaded, changeTypeAfterCreation, checkConstraint, checkItemPermission, checkMandatoryAttribute, checkMandatoryAttribute, checkPermission, checkPermission, checkRemovable, clearPermission, compareTo, createItem, ctx, doAfterRemove, doBeforeRemove, equals, getAccessorFor, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributesInternal, getAllLinkedItems, getAndCheckCacheBoundItem, getAttribute, getAttribute, getCacheBoundItem, getComposedType, getComposedTypePK, getCreationTime, getCurrentlyRemovingCount, getDefaultAttributeModes, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItemsCount, getLinkedItemsCount, getLinkedItemsCount, getModificationTime, getNegativePermissions, getNonInitialAttributes, getOwner, getPermissionMap, getPermissions, getPersistenceVersion, getPK, getPositivePermissions, getRelatedItems, getRestrictedPrincipals, getSession, getSyncObject, getTenant, getTransientObject, getTransientObjectMap, hashCode, hasRegisteredClassAccessorFor, internal_registerClassAccessorFor, internal_registerNonClassAccessorFor, invalidateLocalCaches, isAlive, isCacheBound, isCurrentlyRemoving, isCurrentlyRemoving, isEmptyRelationValue, isInCreate, isInstanceOf, isItemCheckBeforeRemoveableDisabled, isMarkModifiedDisabled, isRelationLocalizationFallbackEnabled, newInstance, notifyExtensionsAfterItemCreation, notifyExtensionsBeforeItemCreation, notifyItemRemoval, notifyManagerAboutItemRemoval, readResolve, registerAccessFor, registerAccessFor, registerJaloInvalidationListeners, remove, remove, removeItemCollection, removeItemCollection, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinks, removePartOfItems, removePartOfItems, setAllAttributes, setAllAttributes, setAllAttributesInternal, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAttribute, setAttribute, setAttributeFromString, setAttributeFromString, setCacheBound, setComposedType, setCreationTime, setImplementation, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setModificationTime, setNonInitialAttributes, setOwner, setPermissionsByMap, setRelatedItems, setTransientObject, setUseTA, toString, useTA, writeReplace
-
Methods inherited from class de.hybris.platform.util.BridgeAbstraction
setTenant
-
-
-
-
Field Detail
-
LANGUAGE_FALLBACK_ENABLED
public static final java.lang.String LANGUAGE_FALLBACK_ENABLED
Session context parameter which enables language fallback for for all localized property read operations. This means that each single property value which is NULL for the requested language is re-read using the (optional) fallback languages of the requested language.- Since:
- 2.20
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAllValuesSessionContext
protected SessionContext getAllValuesSessionContext(SessionContext ctx)
creates a session context instance for getting all localized property values usinggetLocalizedProperty(SessionContext, String)
. the return value will be a map{ Language -> Object } the created session context simply doesnt have a language.
use it as follows:
public Map myMethod(SessionContext ctx) { return (Map) getLocalizedProperty(getAllValuesSessionContext(ctx), "theKey"); }
- Parameters:
ctx
- the original session contex- Returns:
- a session context instance without a language set
-
hasLanguage
protected boolean hasLanguage(SessionContext ctx)
-
isFallbackEnabled
protected boolean isFallbackEnabled(SessionContext ctx)
- Since:
- 2.20
-
getAllLocalizedProperties
public java.util.Map getAllLocalizedProperties()
Returns all localized properties in the current session language as as Map of key/value mappings.This method calls
getAllLocalizedProperties(SessionContext)
with the current session's SessionContext object. See this method for more details.- Returns:
- the Map of key/value mappings.
-
getAllLocalizedProperties
public java.util.Map getAllLocalizedProperties(SessionContext ctx)
Returns all localized properties in given SessionContext language as as Map of key/value mappings.This method is using the following attributes of the given SessionContext:
CacheUsage Language StagingMethod yes yes yes if called on a StageableItem, no otherwise
- Parameters:
ctx
- A SessionContext object- Returns:
- the Map of key/value mappings.
-
getLocalizedPropertyNames
public java.util.Set getLocalizedPropertyNames()
Returns the qualifiers of all localized properties of this item.This method calls
getLocalizedPropertyNames(SessionContext)
with the current session's SessionContext object. See this method for more details.- Returns:
- the set containing the property names (Strings)
-
getLocalizedPropertyNames
public java.util.Set getLocalizedPropertyNames(SessionContext ctx)
Returns the qualifiers of all localized properties of this item.This method is using the following attributes of the given SessionContext:
CacheUsage Language StagingMethod yes yes yes if called on a StageableItem, no otherwise
- Parameters:
ctx
- a SessionContext object- Returns:
- the set containing the property names (Strings)
-
getLocalizedProperty
public java.lang.Object getLocalizedProperty(java.lang.String name)
Returns the value of a localized property.This method calls
getLocalizedProperty(SessionContext, String)
with the current session's SessionContext object. See this method for more details.- Parameters:
name
- the name of the property- Returns:
- the property that is mapped to the name
-
getLocalizedProperty
public java.lang.Object getLocalizedProperty(SessionContext ctx, java.lang.String name)
Returns the value of a localized property.This method is using the following attributes of the given SessionContext:
CacheUsage Language StagingMethod yes yes yes if called on a StageableItem, no otherwise
- Parameters:
ctx
- a SessionContext objectname
- the name of the property- Returns:
- the localized property that is mapped to the name
-
isEmptyValue
protected boolean isEmptyValue(SessionContext ctx, java.lang.String name, java.lang.Object value)
Override this method to implement different language fallback behaviour. As default onlynull
values are considered as empty. Example:@Override protected boolean isEmptyValue(SessionContext ctx, String name, Object value) { return super.isEmptyValue(ctx, name, value) || ("myAttr".equals(name) && ((String) value).trim().length() == 0); }
- Parameters:
ctx
- the session context while getting the propertyname
- the property namevalue
- the actual stored value- Returns:
- true if the value should be treated as empty - in this case values for fallback languages are fetched
-
getLocalizedPropertyInternal
protected java.lang.Object getLocalizedPropertyInternal(SessionContext ctx, java.lang.String name)
Non-language-fallback implementation forgetLocalizedProperty(SessionContext, String)
.- Since:
- 2.20
-
setLocalizedProperty
public java.lang.Object setLocalizedProperty(java.lang.String name, java.lang.Object value)
Sets the value of a localized property. The value is set for the current session language.jaloSession.getSessionContext().setLanguage(jaloSession.getC2LManager().getLanguageByIsoCode("DE")); myLocItem.setLocalizedProperty("de-value");
- Parameters:
name
- the name of the propertyvalue
- the new value of this property- Returns:
- the localized property that was mapped to the name before setting the new property.
-
setLocalizedProperty
public java.lang.Object setLocalizedProperty(SessionContext ctx, java.lang.String name, java.lang.Object value)
Sets the value of a localized property. Normally the value is set for the language spcified by the given session context.SessionContext ctx = jaloSession.createSessionContext(); ctx.setLanguage(jaloSession.getC2LManager().getLanguageByIsoCode("DE")); myLocItem.setLocalizedProperty(ctx, "de-value");
if the session context doesnt hold a language it is expected that all values are meant to be set at once - the given value has to be a map
{ Language -> Serializable }
in that case !
Map allValues = new HashMap(); allValues.put(jaloSession.getC2LManager().getLanguageByIsoCode("DE"), "de-value"); allValues.put(jaloSession.getC2LManager().getLanguageByIsoCode("EN"), "en-value"); SessionContext ctx = jaloSession.createSessionContext(); ctx.setLanguage(null); myLocItem.setLocalizedProperty(ctx, allValues);
- Parameters:
name
- the name of the propertyvalue
- the new value of this propertyctx
- the session context defining the language to set the value for- Returns:
- the localized property that was mapped to the name before setting the new property.
-
setAllLocalizedProperties
public java.util.Map<Language,?> setAllLocalizedProperties(SessionContext ctx, java.lang.String name, java.util.Map<Language,?> values)
Changes multiple localized values of one property at once. The values map specifies which values should be set for their mapped languages.Please note that this method will not clear any existing value for languages which are missing in the values map!
- Parameters:
ctx
- the session contextname
- the property namevalues
-- Returns:
- the previous value for the mapped languages
-
setAllLocalizedProperties
public java.util.Map<Language,?> setAllLocalizedProperties(java.lang.String name, java.util.Map<Language,?> values)
Changes multiple localized values of one property at once. The values map specifies which values should be set for their mapped languages.Please note that this method will not clear any existing value for languages which are missing in the values map!
- Parameters:
name
- the property namevalues
-- Returns:
- the previous value for the mapped languages
-
getAllLocalizedProperties
public java.util.Map<Language,?> getAllLocalizedProperties(SessionContext ctx, java.lang.String name, java.util.Set<Language> languages)
Returns all values of a localized property according to a specified set of languages. Values mapped to other languages are not returned.- Parameters:
ctx
- the session contextname
- the property namelanguages
- the languages to get values for
-
getAllLocalizedProperties
public java.util.Map<Language,?> getAllLocalizedProperties(java.lang.String name, java.util.Set<Language> languages)
Returns all values of a localized property according to a specified set of languages. Values mapped to other languages are not returned.- Parameters:
name
- the property namelanguages
- the languages to get values for
-
removeLocalizedProperty
public java.lang.Object removeLocalizedProperty(java.lang.String name)
Removes a localized property from this item.This method calls
removeLocalizedProperty(SessionContext, String)
with the current session's SessionContext object. See this method for more details.- Parameters:
name
- the name of the property- Returns:
- the localized property value which was removed
- See Also:
removeLocalizedProperty(SessionContext, String)
-
removeLocalizedProperty
public java.lang.Object removeLocalizedProperty(SessionContext ctx, java.lang.String name)
Removes a localized property from this item.Please note that only the property in the SessionContext language is removed. Its other values will remain unchanged.
- Parameters:
name
- the name of the propertyctx
- a SessionContext object defining the language to remove value for- Returns:
- the localized property value which was removed
-
-