コード例 #1
0
 protected Map<String, Object> parseDatasourceSettings(
     Set<SettingDefinition<?, ?>> defs, HttpServletRequest req) {
   Map<String, String> parameters = new HashMap<String, String>(req.getParameterMap().size());
   Enumeration<?> e = req.getParameterNames();
   while (e.hasMoreElements()) {
     String key = (String) e.nextElement();
     parameters.put(key, req.getParameter(key));
   }
   Map<String, Object> parsedSettings = new HashMap<String, Object>(parameters.size());
   for (SettingDefinition<?, ?> def : defs) {
     SettingValue<?> newValue =
         getSettingsManager()
             .getSettingFactory()
             .newSettingValue(def, parameters.get(def.getKey()));
     parsedSettings.put(def.getKey(), newValue.getValue());
   }
   return parsedSettings;
 }
コード例 #2
0
 private JsonNode encodeSettings(Map<String, Object> p) throws JSONException {
   SettingDefinitionEncoder enc = new SettingDefinitionEncoder();
   Set<SettingDefinition<?, ?>> defs =
       getDatasource()
           .getChangableSettingDefinitions(
               getDatasource().getDatasourceProperties(getSettings(), p));
   for (SettingDefinition<?, ?> def : defs) {
     setDefaultValue(def, p.get(def.getKey()));
   }
   JsonNode settings = enc.encode(enc.sortByGroup(defs));
   ObjectNode node = JSONUtils.nodeFactory().objectNode();
   node.put(SETTINGS, settings);
   return node;
 }