Class sap.ushell.services.PersonalizationModule: sap/ushell/services/Personalization
The Unified Shell's personalization service, which provides a personalizer object that handles all personalization operations.
Since: 1.15.0.
getContainer(.
sap.ushell.Container.getService("Personalization")
.sap.ushell.Container.getService("Personalization")
. Constructs a new instance of the personalization service. {object} | oAdapter | the service adapter for the personalization service, as already provided by the container |
The call always returns an cleared container().
Note that an existing container at the front-end server is not actually deleted or overwritten unless a save operation is executed.
An initial object is returned.
{string} | sContainerKey | identifies the container The string length is restricted to 40 characters |
{Object} | oScope | scope object currently the validity property of the scope object is relevant: E.g. { validity : 30} indicates a validity of the data for 30 minutes.oScope.validity : validity of the container persistence in minutes valid values include 0 ( per FLP Window), Infinity, undefined ( Backend persistence per user ) [Default] nn Minutes ( Backend persistence per user, ignored if older than nn minutes) |
{sap.ui.component} | oComponent | Since 1.27.0. SAPUI5 component which uses the container. This allows to associate the stored data with the application. |
- Since:
- 1.22.0
{object} | Promise object whose done function returns a sap.ushell.services.Personalization.ContextContainer object as parameter. The personalization container provides two different interfaces to synchronously operate on personalization data. In the item mode the container contains items as name value pairs for personalization data. In the variant mode the container contains variant sets which contain variants containing items. |
Note: After invoking this operation, the state of other Containers obtained for the same key is undefined! If you want to use the container after deletion, it is strongly recommended to obtain a new instance of a container for the given key *after* the promise has returned.
Note: Invoking this operation while another save or load operation is under way may result in failure.
{string} | sContainerKey | identifies the container |
- Since:
- 1.22.0
{object} | promise for the deletion operation |
Every getContainer operation returns a new local copy, containing the full data at the point of creation.
Executing load() on the container reloads the data from the persistence, discarding local changes.
Note that the container allows the application to control the round trips to the front-end server persistence. The factory method getContainer is asynchronous and loads the container via the connected adapter from the front-end server. All operations (but for the save operation) are executed synchronously, operating on the local data. This allows the application to control the round trips to the front-end server persistence.
A container can contain a set of items, identified by a key.
You can wrap a container in a VariantSetAdapter to read and write a more complex structure (with multiple keys (variantSet,variant,item)).
Do not mix up the usage of a personalizer and a container for one containerKey. Do not use a PersonalizationContainer and a Container for the same key except for migration scenarios.
scope / validity parameter (@since 1.22.0): An unspecified (undefined validity) or infinite (Infinity) validity indicates that data is persisted in the Personalization data of the front-end server. A round trip is executed on an initial get and at least every save operation. Data is stored per user and retained indefinitely at the front-end server.
The validity parameter allows a designated storage validity for the created container. A 0 validity indicates the data is only persisted within the Fiori Launchpad window. No round trips to the front-end server are executed. Data is lost if the Fiori Launchpad window state is lost (e.g. by navigating to a different page, pressing F5 (reload page) or duplicating the window).
For versions > 1.24 it may happen that for cross-app navigation a reload of the Fiori Launchpad is triggered. In this case a storage of the personalization data in the Fiori lauchpad window would lead to data loss. To overcome this a validity 0 is automatically changed to a validity 1440 (24h; storage on the front-end server). This is only done if a relaod of the Fiori Launchpad is triggered for a cross-app navigation.
Security: It is the responsibility of the application to not persist information relevant to auditing or security using the PersonalizationService with inappropriate validity models. No mechanisms exist to destroy or selectively destroy application-specific data in the front-end server persistence (especially for validity Infinity).
For non-zero validity scopes, data will be transmitted and persisted in the front-end server system.
For limited validity, actual deletion of data on the front-end server is subject to explicit cleanup execution of front-end server jobs and not guaranteed. The data may still be persisted and retrievable. The interface only assures that expired data is no longer exposed to the application code in the Fiori Launchpad.
The ContainerKey uniquely defines the Container, validity is not part of the key (there are no separate namespaces per validity).
In general, mixing different validity models for a given container key is not supported. Fast chaining of different methods may source arbitrary persistence layers. The validity of the resulting object in the done function of a promise is the last get validity.
The validity associated with the last getContainer or createEmptyContainer determines the current validity of the container and the validity used during the next save operation.
Naturally, if a delete or get with validity 0 is issued, it will *not* delete or retrieve a front-end server persistent storage Thus a sequence delete( [validity 0])/wait for promise, getContainer(sKey,{ validity : Infinity}) may return a valid dataset.
{string} | sContainerKey | identifies the container The string length is restricted to 40 characters |
{Object} | oScope | scope object currently the validity property of the scope object is relevant: E.g. { validity : 30} indicates a validity of the data for 30 minutes.oScope.validity : validity of the container persistence in minutes valid values include 0 ( per FLP Window), Infinity, undefined (front-end server persistence per user ) [Default] nn Minutes (front-end server persistence per user, ignored if older than nn minutes) |
{sap.ui.component} | oComponent | Since 1.27.0. SAPUI5 component which uses the container. This allows to associate the stored data with the application. |
- Since:
- 1.22.0
{object} | Promise object whose done function returns a sap.ushell.services.Personalization.ContextContainer object as parameter. The container provides setItemValue / getItemValue methods to synchronously operate on personalization data. By wrapping it in a VariantSetAdapter, an alternate interface to maintain variants can be obtained. |
- Since:
- 1.28.0
{string} | 40 character string consisting of A-Z and 0-9 which can be used as a generated key for personalization container. Every invocation returns a new key. NOTE: Don't use substrings of this key as random keys |
Do not mix the usage of a personalizer and a personalization container for one containerKey.
{object} | oPersId | JSON object consisting of the following parts: container - Identifies the set of personalization data that is loaded/saved as one bundle from the front-end server. item - The name of the object the personalization is applied to. |
{object} | oScope | scope object currently the validity property of the scope object is relevant: oScope.validity : validity of the container persistence in minutes oScope.keyCategory : Type or category of key oScope.writeFrequency : Expected frequency how often users will use this container to store data inside oScope.clientStorageAllowed : Defines if storage on client side should be allowed or not E.g. { validity : 30} indicates a validity of the data for 30 minutes. |
{sap.ui.component} | oComponent | Since 1.27.0. SAPUI5 component which uses the personalizer. This allows to associate the stored data with the application. |
- Since:
- 1.15.0
{object} | sap.ushell.services.Personalizer which provides generic read and write access to the currently logged on user's personalization settings. |
- Since:
- 1.18.0
{object} | sap.ushell.services.TransientPersonalizer which provides asynchronous read and write access to a transient personalization data storage. |
{string} | sContainerKey | identifies the container |
- Deprecated:
- true
- Since:
- 1.18.0
{object} | promise for the deletion operation |
Note: the underlying storage model for Objects stored with getContainer / getPersonalizationContainer is identical.
Thus you can safely migrate your client implementation from the deprecated getContainer to getPersonalizationContainer without loss of data. One may even run mixed set of applications on the same container keys. The sole differences are w.r.t. client side handling of the Context data within one session.
If you want to use the variant interface, use the following pattern getContainer(sContainerKey).done(function(oContainer) { var variantSetAdapter = new sap.ushell.services.Personalization.VariantSetAdapter(oContainer); }
Factory method to obtain a personalization container object which is a client-local buffer for personalization data. The Container data is asynchronously read on creation (if present, otherwise an initial object is created). The Container data can then be *synchronously* modified (read/write/delete). Only on invoking the save() method the data is persisted at the front-end server. This allows the application to perform multiple local modifications and delay the save operation. Note that the personalization container allows the application to control the round trips to the front-end server persistence. The factory method getPersonalizationContainer is asynchronous and loads the container via the connected adapter from the front-end server. All operations (but for the save operation) are executed synchronously, operating on the local data. This allows the application to control the round trips to the front-end server persistence.
A personalization container can contain items as well as variant sets. Variant sets have the following structure: variantSet.variant.item A variant set is enclosing several variants of the same data.
Example: An application has two types of variants. Variant type 1 contains filter values for a query, which are stored in item 1 of the variant, and personalization data for a table, which are stored in item 2 of the variant. Variant type 2 contains a setting (item 3) that is independent of the filtering and the table settings. It might be used for a different screen than the variants of type 1. In this example you would have 2 variant sets, one for each variant type.
Do not mix up the usage of a personalizer and a personalization container for one containerKey.
{string} | sContainerKey | identifies the container |
- Deprecated:
- use getContainer()
- Since:
- 1.18.0
{object} | Promise object whose done function returns a sap.ushell.services.PersonalizationContainer object as parameter. The personalization container provides two different interfaces to synchronously operate on personalization data. In the item mode the container contains items as name-value pairs for personalization data. In the variant mode the container contains variant sets which contain variants containing items. |