Class Preferences


  • public class Preferences
    extends Object
    Handles preferences, resolving priorities in case there are values for a same property at different visibility levels
    • Constructor Detail

      • Preferences

        public Preferences()
    • Method Detail

      • getAllPreferences

        public static List<Preference> getAllPreferences​(String client,
                                                         String org,
                                                         String user,
                                                         String role)
        Obtains a list of all preferences that are applicable at the given visibility level (client, org, user, role).

        In case of different values for a single property at a same visibility level, one of them is taken.

      • setPreferenceValue

        public static Preference setPreferenceValue​(String property,
                                                    String value,
                                                    boolean isListProperty,
                                                    Client client,
                                                    Organization org,
                                                    User user,
                                                    Role role,
                                                    Window window,
                                                    VariablesSecureApp vars)
        Saves the property/value as a preference. If a preference with exactly the same visualization priority already exists, it is overwritten; if not, a new one is created.

        It also saves the new preference in session, in case the vars parameter is not null. If it is null, the preference is not stored in session.

        Parameters:
        property - Name of the property or attribute for the preference.
        value - New value to set.
        isListProperty - Determines whether list of properties or attribute should be used.
        client - Client visibility.
        org - Organization visibility.
        user - User visibility.
        role - Role visibility.
        window - Window visibility.
        vars - VariablesSecureApp to store new property value.
        Returns:
        The preference that has been created or modified
      • getPreferenceValue

        public static String getPreferenceValue​(String property,
                                                boolean isListProperty,
                                                Client client,
                                                Organization org,
                                                User user,
                                                Role role,
                                                Window window)
                                         throws PropertyException
        Obtains the value for a given property with the visibility defined by the parameters. In case of conflict or the property is not defined an exception is thrown.

        This method is used to query in database for the property value, note that when properties are set, they are also saved as session values and it is possible to obtain them using Utility.getPreference.

        Throws:
        PropertyException - if the property cannot be resolved in a single value:
      • existsPreference

        public static boolean existsPreference​(String property,
                                               boolean isListProperty,
                                               String clientId,
                                               String orgId,
                                               String userId,
                                               String roleId,
                                               String windowId)
        Utility method to determine if exists a preference with the same settings passed as parameters
        Parameters:
        property - Name of the property or attribute for the preference.
        isListProperty - Determines whether list of properties or attribute should be used.
        clientId - Client visibility.
        orgId - Organization visibility.
        userId - User visibility.
        roleId - Role visibility.
        windowId - Window visibility.
        Returns:
        true if exists a preference with the same settings passed as parameters, false otherwise
      • existsPreference

        public static boolean existsPreference​(Preference preference)
        Utility method to determine if exists a preference with the same settings as the preference passed as parameter
        Parameters:
        preference - the preference to check
        Returns:
        true if exists a preference with the same settings passed as parameters, false otherwise
      • getPreferences

        public static List<Preference> getPreferences​(String property,
                                                      boolean isListProperty,
                                                      String clientId,
                                                      String orgId,
                                                      String userId,
                                                      String roleId,
                                                      String windowId)
        Utility method which returns a list of preferences with the settings passed as parameters. The resulting list includes the preferences which are not active (if any).
        Parameters:
        property - Name of the property or attribute for the preference.
        isListProperty - Determines whether list of properties or attribute should be used.
        clientId - Client visibility.
        orgId - Organization visibility.
        userId - User visibility.
        roleId - Role visibility.
        windowId - Window visibility.
        Returns:
        a list of preference with the same settings as those passed as parameters
      • savePreferenceInSession

        public static void savePreferenceInSession​(VariablesSecureApp vars,
                                                   Preference preference)
        Stores the preference as a session value
        Parameters:
        vars - VariablesSecureApp of the current session to store preference in
        preference - Preference to save in session