Package org.ametys.plugins.odfweb.cart
Class ODFCartUserPreferencesStorage
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.odfweb.cart.ODFCartUserPreferencesStorage
-
- All Implemented Interfaces:
UserPreferencesStorage,LogEnabled,Component,Configurable
public class ODFCartUserPreferencesStorage extends AbstractLogEnabled implements UserPreferencesStorage, Configurable, Component
Specific storage for odf cart user preferences
-
-
Field Summary
Fields Modifier and Type Field Description protected String_contentIdColumnThe content id columnprotected String_contextColumnThe context column, can be null if the database is not context-dependent.protected String_dataSourceIdThe id of the data source used.protected String_loginColumnThe login column, cannot be null.protected String_populationColumnThe population id column, cannot be null.protected Map<String,String>_prefIdToTableMapping from preference id to table name.static StringROLEThe Avalon Role
-
Constructor Summary
Constructors Constructor Description ODFCartUserPreferencesStorage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(Configuration configuration)voidconfigureMappings(Configuration configuration)Configure the mappings from preference ID to table name.Map<String,String>getUnTypedUserPrefs(UserIdentity user, String storageContext, Map<String,String> contextVars)Get a user's preference values (as String) for a given context.BooleangetUserPreferenceAsBoolean(UserIdentity user, String storageContext, Map<String,String> contextVars, String id)Get a single boolean user preference value for a given context.DategetUserPreferenceAsDate(UserIdentity user, String storageContext, Map<String,String> contextVars, String id)Get a single date user preference value for a given context.DoublegetUserPreferenceAsDouble(UserIdentity user, String storageContext, Map<String,String> contextVars, String id)Get a single double user preference value for a given context.LonggetUserPreferenceAsLong(UserIdentity user, String storageContext, Map<String,String> contextVars, String id)Get a single long user preference value for a given context.StringgetUserPreferenceAsString(UserIdentity user, String storageContext, Map<String,String> contextVars, String id)Get a single string user preference value for a given context.voidremoveContentFromUserPreferences(String contentId)Remove content from all user preferencesvoidremoveUserPreferences(Collection<String> prefIds, UserIdentity user, String storageContext, Map<String,String> contextVars)Remove the stored user preferences for a login in a given context.voidremoveUserPreferences(UserIdentity user, String storageContext, Map<String,String> contextVars)Remove the stored user preferences for a login in a given context.voidsetUserPreferences(UserIdentity user, String storageContext, Map<String,String> contextVars, Map<String,String> preferences)Set a user's preferences for a given context.-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_dataSourceId
protected String _dataSourceId
The id of the data source used.
-
_loginColumn
protected String _loginColumn
The login column, cannot be null.
-
_populationColumn
protected String _populationColumn
The population id column, cannot be null.
-
_contextColumn
protected String _contextColumn
The context column, can be null if the database is not context-dependent.
-
_contentIdColumn
protected String _contentIdColumn
The content id column
-
_prefIdToTable
protected Map<String,String> _prefIdToTable
Mapping from preference id to table name.
-
-
Constructor Detail
-
ODFCartUserPreferencesStorage
public ODFCartUserPreferencesStorage()
-
-
Method Detail
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configurein interfaceConfigurable- Throws:
ConfigurationException
-
configureMappings
public void configureMappings(Configuration configuration) throws ConfigurationException
Configure the mappings from preference ID to table name.- Parameters:
configuration- the mapping configuration root.- Throws:
ConfigurationException- if an error occurs.
-
getUnTypedUserPrefs
public Map<String,String> getUnTypedUserPrefs(UserIdentity user, String storageContext, Map<String,String> contextVars) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageGet a user's preference values (as String) for a given context.- Specified by:
getUnTypedUserPrefsin interfaceUserPreferencesStorage- Parameters:
user- the user.storageContext- the preferences storage context.contextVars- The context variables including environment elements- Returns:
- the user preference values as a Map of String indexed by preference ID.
- Throws:
UserPreferencesException- if an error occurs getting the preferences.
-
removeUserPreferences
public void removeUserPreferences(Collection<String> prefIds, UserIdentity user, String storageContext, Map<String,String> contextVars) throws UserPreferencesException
Remove the stored user preferences for a login in a given context.- Parameters:
prefIds- the id of user preferences to removeuser- the user.storageContext- the preferences storage context.contextVars- the context variables.- Throws:
UserPreferencesException- if an error occurred
-
removeUserPreferences
public void removeUserPreferences(UserIdentity user, String storageContext, Map<String,String> contextVars) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageRemove the stored user preferences for a login in a given context.- Specified by:
removeUserPreferencesin interfaceUserPreferencesStorage- Parameters:
user- the user.storageContext- the preferences storage context.contextVars- the context variables.- Throws:
UserPreferencesException- if an error occurred
-
removeContentFromUserPreferences
public void removeContentFromUserPreferences(String contentId) throws UserPreferencesException
Remove content from all user preferences- Parameters:
contentId- the content id to remove- Throws:
UserPreferencesException- if failed to remove user preferences
-
setUserPreferences
public void setUserPreferences(UserIdentity user, String storageContext, Map<String,String> contextVars, Map<String,String> preferences) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageSet a user's preferences for a given context.- Specified by:
setUserPreferencesin interfaceUserPreferencesStorage- Parameters:
user- the user.storageContext- the preferences storage context.contextVars- The context variables including environment elementspreferences- a Map of the preference values indexed by ID.- Throws:
UserPreferencesException- if an error occurred
-
getUserPreferenceAsString
public String getUserPreferenceAsString(UserIdentity user, String storageContext, Map<String,String> contextVars, String id) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageGet a single string user preference value for a given context.- Specified by:
getUserPreferenceAsStringin interfaceUserPreferencesStorage- Parameters:
user- the user.storageContext- the preferences storage context.contextVars- The context variables including environment elementsid- the preference ID.- Returns:
- the user preference value as a String.
- Throws:
UserPreferencesException- if an error occurred
-
getUserPreferenceAsLong
public Long getUserPreferenceAsLong(UserIdentity user, String storageContext, Map<String,String> contextVars, String id) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageGet a single long user preference value for a given context.- Specified by:
getUserPreferenceAsLongin interfaceUserPreferencesStorage- Parameters:
user- the user.storageContext- the preferences storage context.contextVars- The context variables including environment elementsid- the preference ID.- Returns:
- the user preference value as a Long.
- Throws:
UserPreferencesException- if an error occurred
-
getUserPreferenceAsDate
public Date getUserPreferenceAsDate(UserIdentity user, String storageContext, Map<String,String> contextVars, String id) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageGet a single date user preference value for a given context.- Specified by:
getUserPreferenceAsDatein interfaceUserPreferencesStorage- Parameters:
user- the user.storageContext- the preferences storage context.contextVars- The context variables including environment elementsid- the preference ID.- Returns:
- the user preference value as a Date.
- Throws:
UserPreferencesException- if an error occurred
-
getUserPreferenceAsBoolean
public Boolean getUserPreferenceAsBoolean(UserIdentity user, String storageContext, Map<String,String> contextVars, String id) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageGet a single boolean user preference value for a given context.- Specified by:
getUserPreferenceAsBooleanin interfaceUserPreferencesStorage- Parameters:
user- the user.storageContext- the preferences storage context.contextVars- The context variables including environment elementsid- the preference ID.- Returns:
- the user preference value as a Boolean.
- Throws:
UserPreferencesException- if an error occurred
-
getUserPreferenceAsDouble
public Double getUserPreferenceAsDouble(UserIdentity user, String storageContext, Map<String,String> contextVars, String id) throws UserPreferencesException
Description copied from interface:UserPreferencesStorageGet a single double user preference value for a given context.- Specified by:
getUserPreferenceAsDoublein interfaceUserPreferencesStorage- Parameters:
user- the user.storageContext- the preferences storage context.contextVars- The context variables including environment elementsid- the preference ID.- Returns:
- the user preference value as a Double.
- Throws:
UserPreferencesException- if an error occurred
-
-