public void createDefaultParameters(UserID userID) { userDAO.saveParameter( userID, UserSetting.DEFAULT_PROVIDER, userSettingTranslator.translateSetting( UserSetting.DEFAULT_PROVIDER, DefaultFixDefinitionProvider.DESCRIPTOR)); userDAO.saveParameter( userID, UserSetting.STORE_MESSAGES, userSettingTranslator.translateSetting(UserSetting.STORE_MESSAGES, Boolean.TRUE)); }
public void setParameter(UserID userID, UserSetting userSetting, Object value) { String settingValue = userSettingTranslator.translateSetting(userSetting, value); Map<UserSetting, Object> userSettings = defaultSettings.get(userID); if (userSettings == null) { userSettings = new HashMap<>(); } userSettings.put(userSetting, value); defaultSettings.put(userID, userSettings); userDAO.saveParameter(userID, userSetting, settingValue); }
public void loadParameters(UserID userID) { List<UserSettingHolder> userSettingHolders = userDAO.findParameters(userID); Map<UserSetting, Object> userSettingsActual = defaultSettings.get(userID); if (userSettingsActual == null) { userSettingsActual = new HashMap<>(); } for (UserSettingHolder holder : userSettingHolders) { userSettingsActual.put( holder.getUserSetting(), userSettingTranslator.resolveSetting(holder.getUserSetting(), holder.getSettingValue())); } defaultSettings.put(userID, userSettingsActual); }