Esempio n. 1
0
 @Override
 public List<ErrorData> isValidSettings(Map<Integer, Object> settings) {
   List<ErrorData> errorDataList = new ArrayList<ErrorData>();
   TOptionSettingsBean optionSettingsBean = (TOptionSettingsBean) settings.get(mapParameterCode);
   if (optionSettingsBean == null || optionSettingsBean.getList() == null) {
     errorDataList.add(new ErrorData("customSelectSimple.error.noList"));
   }
   return errorDataList;
 }
Esempio n. 2
0
 /**
  * Gets the data specific to configuring the field Specifically useful when select lists should be
  * present at configuration time
  *
  * @param projectID
  * @param locale
  * @param fieldConfigID
  * @return
  */
 protected List<ILabelBean> getLists(Integer projectID, Locale locale, Integer fieldConfigID) {
   Integer currentValue = null;
   if (fieldConfigID != null) {
     TOptionSettingsBean optionSettingsBean =
         OptionSettingsBL.loadByConfigAndParameter(fieldConfigID, null);
     if (optionSettingsBean != null) {
       currentValue = optionSettingsBean.getList();
     }
   }
   return (List)
       ListBL.getSelectsOfType(projectID, TListBean.LIST_TYPE.SIMPLE, null, currentValue);
 }
Esempio n. 3
0
 /**
  * Gets the specific JSON string for a field
  *
  * @param configID ID of the direct or nearest fallback configuration
  * @param treeConfigIDTokens a decoded node
  * @param personBean
  * @param locale
  * @param bundleName
  * @return
  */
 @Override
 public String getSettingsJSON(
     Integer configID,
     TreeConfigIDTokens treeConfigIDTokens,
     TPersonBean personBean,
     Locale locale,
     String bundleName) {
   TOptionSettingsBean optionSettingsBean =
       OptionSettingsBL.loadByConfigAndParameter(configID, parameterCode);
   StringBuilder stringBuilder = new StringBuilder();
   if (optionSettingsBean != null) {
     JSONUtility.appendIntegerValue(
         stringBuilder,
         FieldConfigJSON.JSON_FIELDS.OPTION_SETTINGS_LIST_PREFIX
             + "[0]."
             + FieldConfigJSON.JSON_FIELDS.OPTION_SETTINGS_LIST,
         optionSettingsBean.getList());
   }
   JSONUtility.appendILabelBeanList(
       stringBuilder,
       FieldConfigJSON.JSON_FIELDS.OPTION_SETTINGS_LISTS,
       getLists(treeConfigIDTokens.getProjectID(), locale, configID));
   return stringBuilder.append(getLocalizationJSON(locale, bundleName)).toString();
 }
Esempio n. 4
0
 /**
  * Copy all the settings regarding a field configuration to an other field configuration Used only
  * by override (for rendering the settings to the user the getSettingsJSON() is used)
  *
  * @param srcSettings
  * @param destSettings
  * @param destConfigID
  */
 @Override
 public void copySettings(
     Map<Integer, Object> srcSettings, Map<Integer, Object> destSettings, Integer destConfigID) {
   TOptionSettingsBean srcOptionSettingsBean =
       (TOptionSettingsBean) srcSettings.get(mapParameterCode);
   TOptionSettingsBean destOptionSettingsBean =
       (TOptionSettingsBean) destSettings.get(mapParameterCode);
   if (destOptionSettingsBean == null) {
     destOptionSettingsBean = new TOptionSettingsBean();
     destOptionSettingsBean.setConfig(destConfigID);
     destSettings.put(mapParameterCode, destOptionSettingsBean);
   }
   // only if there are specific source settings
   if (srcOptionSettingsBean != null) {
     destOptionSettingsBean.setList(srcOptionSettingsBean.getList());
     destOptionSettingsBean.setParameterCode(srcOptionSettingsBean.getParameterCode());
   }
 }
Esempio n. 5
0
 /**
  * Saves the configuration settings for a field
  *
  * @param settings
  * @param configID
  */
 @Override
 public void saveSettings(Map<Integer, Object> settings, Integer configID) {
   TOptionSettingsBean optionSettingsBean = (TOptionSettingsBean) settings.get(mapParameterCode);
   optionSettingsBean.setConfig(configID);
   OptionSettingsBL.save(optionSettingsBean);
 }