org.ofbiz.common.preferences
Class PreferenceServices

java.lang.Object
  extended by org.ofbiz.common.preferences.PreferenceServices

public class PreferenceServices
extends java.lang.Object

User preference services.

User preferences are stored as key-value pairs.

User preferences can be grouped - so that multiple preference pairs can be handled at once. Preference groups also allow a single userPrefTypeId to be used more than once - with each occurence having a unique userPrefGroupTypeId.

User preference values are stored as Strings, so the easiest and most efficient way to handle user preference values is to keep them as strings. This class handles any data conversion needed.


Field Summary
static java.lang.String module
           
static java.lang.String resource
           
 
Constructor Summary
PreferenceServices()
           
 
Method Summary
static java.util.Map<java.lang.String,java.lang.Object> copyUserPreferenceGroup(DispatchContext ctx, java.util.Map<java.lang.String,?> context)
          Copies a user preference group.
static java.util.Map<java.lang.String,java.lang.Object> getUserPreference(DispatchContext ctx, java.util.Map<java.lang.String,?> context)
          Retrieves a single user preference from persistent storage.
static java.util.Map<java.lang.String,java.lang.Object> getUserPreferenceGroup(DispatchContext ctx, java.util.Map<java.lang.String,?> context)
          Retrieves a group of user preferences from persistent storage.
static java.util.Map<java.lang.String,java.lang.Object> setUserPreference(DispatchContext ctx, java.util.Map<java.lang.String,?> context)
          Stores a single user preference in persistent storage.
static java.util.Map<java.lang.String,java.lang.Object> setUserPreferenceGroup(DispatchContext ctx, java.util.Map<java.lang.String,?> context)
          Stores a user preference group in persistent storage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

module

public static final java.lang.String module

resource

public static final java.lang.String resource
See Also:
Constant Field Values
Constructor Detail

PreferenceServices

public PreferenceServices()
Method Detail

getUserPreference

public static java.util.Map<java.lang.String,java.lang.Object> getUserPreference(DispatchContext ctx,
                                                                                 java.util.Map<java.lang.String,?> context)
Retrieves a single user preference from persistent storage. Call with userPrefTypeId and optional userPrefLoginId. If userPrefLoginId isn't specified, then the currently logged-in user's userLoginId will be used. The retrieved preference is contained in the userPrefMap element.

Parameters:
ctx - The DispatchContext that this service is operating in.
context - Map containing the input arguments.
Returns:
Map with the result of the service, the output parameters.

getUserPreferenceGroup

public static java.util.Map<java.lang.String,java.lang.Object> getUserPreferenceGroup(DispatchContext ctx,
                                                                                      java.util.Map<java.lang.String,?> context)
Retrieves a group of user preferences from persistent storage. Call with userPrefGroupTypeId and optional userPrefLoginId. If userPrefLoginId isn't specified, then the currently logged-in user's userLoginId will be used. The retrieved preferences group is contained in the userPrefMap element.

Parameters:
ctx - The DispatchContext that this service is operating in.
context - Map containing the input arguments.
Returns:
Map with the result of the service, the output parameters.

setUserPreference

public static java.util.Map<java.lang.String,java.lang.Object> setUserPreference(DispatchContext ctx,
                                                                                 java.util.Map<java.lang.String,?> context)
Stores a single user preference in persistent storage. Call with userPrefTypeId, userPrefGroupTypeId, userPrefValue and optional userPrefLoginId. If userPrefLoginId isn't specified, then the currently logged-in user's userLoginId will be used.

Parameters:
ctx - The DispatchContext that this service is operating in.
context - Map containing the input arguments.
Returns:
Map with the result of the service, the output parameters.

setUserPreferenceGroup

public static java.util.Map<java.lang.String,java.lang.Object> setUserPreferenceGroup(DispatchContext ctx,
                                                                                      java.util.Map<java.lang.String,?> context)
Stores a user preference group in persistent storage. Call with userPrefMap, userPrefGroupTypeId and optional userPrefLoginId. If userPrefLoginId isn't specified, then the currently logged-in user's userLoginId will be used.

Parameters:
ctx - The DispatchContext that this service is operating in.
context - Map containing the input arguments.
Returns:
Map with the result of the service, the output parameters.

copyUserPreferenceGroup

public static java.util.Map<java.lang.String,java.lang.Object> copyUserPreferenceGroup(DispatchContext ctx,
                                                                                       java.util.Map<java.lang.String,?> context)
Copies a user preference group. Call with fromUserLoginId, userPrefGroupTypeId and optional userPrefLoginId. If userPrefLoginId isn't specified, then the currently logged-in user's userLoginId will be used.

Parameters:
ctx - The DispatchContext that this service is operating in.
context - Map containing the input arguments.
Returns:
Map with the result of the service, the output parameters.