Search in sources :

Example 1 with UserSetting

use of org.pentaho.platform.repository.usersettings.pojo.UserSetting in project pentaho-platform by pentaho.

the class UserSettingService method createSetting.

private static UserSetting createSetting(String name, String value) {
    UserSetting setting = new UserSetting();
    setting.setSettingName(name);
    setting.setSettingValue(value);
    return setting;
}
Also used : IUserSetting(org.pentaho.platform.api.usersettings.pojo.IUserSetting) UserSetting(org.pentaho.platform.repository.usersettings.pojo.UserSetting)

Example 2 with UserSetting

use of org.pentaho.platform.repository.usersettings.pojo.UserSetting in project pentaho-platform by pentaho.

the class UserSettingService method getUserSettings.

public List<IUserSetting> getUserSettings() {
    // get the global settings and the user settings
    // merge unseen global settings into the user settings list
    List<IUserSetting> userSettings = new ArrayList<IUserSetting>();
    String tentantHomePath = ClientRepositoryPaths.getEtcFolderPath();
    Serializable tenantHomeId = repository.getFile(tentantHomePath).getId();
    Map<String, Serializable> tenantMetadata = repository.getFileMetadata(tenantHomeId);
    for (Map.Entry<String, Serializable> entry : tenantMetadata.entrySet()) {
        String key = entry.getKey();
        if (key.startsWith(SETTING_PREFIX)) {
            UserSetting setting = createSetting(key.substring(SETTING_PREFIX.length()), entry.getValue());
            userSettings.add(setting);
        }
    }
    String homePath = ClientRepositoryPaths.getUserHomeFolderPath(PentahoSessionHolder.getSession().getName());
    Serializable userHomeId = repository.getFile(homePath).getId();
    Map<String, Serializable> userMetadata = repository.getFileMetadata(userHomeId);
    for (Map.Entry<String, Serializable> entry : userMetadata.entrySet()) {
        String key = entry.getKey();
        if (key.startsWith(SETTING_PREFIX)) {
            UserSetting setting = createSetting(key.substring(SETTING_PREFIX.length()), entry.getValue());
            // see if a global setting exists which will be overridden
            if (userSettings.contains(setting)) {
                userSettings.remove(setting);
            }
            userSettings.add(setting);
        }
    }
    return userSettings;
}
Also used : Serializable(java.io.Serializable) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) IUserSetting(org.pentaho.platform.api.usersettings.pojo.IUserSetting) IUserSetting(org.pentaho.platform.api.usersettings.pojo.IUserSetting) UserSetting(org.pentaho.platform.repository.usersettings.pojo.UserSetting)

Aggregations

IUserSetting (org.pentaho.platform.api.usersettings.pojo.IUserSetting)2 UserSetting (org.pentaho.platform.repository.usersettings.pojo.UserSetting)2 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1