Esempio n. 1
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) {
   TTextBoxSettingsBean textBoxSettingsBean = getTTextBoxSettingsBeanByConfig(configID);
   StringBuilder stringBuilder = new StringBuilder();
   if (textBoxSettingsBean != null) {
     JSONUtility.appendDoubleValue(
         stringBuilder,
         FieldConfigJSON.JSON_FIELDS.TEXTBOX_SETTINGS
             + "[0]."
             + FieldConfigJSON.JSON_FIELDS.TEXTBOX_SETTINGS_DEFAULT_DOUBLE,
         textBoxSettingsBean.getDefaultDouble());
     JSONUtility.appendDoubleValue(
         stringBuilder,
         FieldConfigJSON.JSON_FIELDS.TEXTBOX_SETTINGS
             + "[0]."
             + FieldConfigJSON.JSON_FIELDS.TEXTBOX_SETTINGS_MIN_DOUBLE,
         textBoxSettingsBean.getMinDouble());
     JSONUtility.appendDoubleValue(
         stringBuilder,
         FieldConfigJSON.JSON_FIELDS.TEXTBOX_SETTINGS
             + "[0]."
             + FieldConfigJSON.JSON_FIELDS.TEXTBOX_SETTINGS_MAX_DOUBLE,
         textBoxSettingsBean.getMaxDouble());
   }
   return stringBuilder.append(getLocalizationJSON(locale, bundleName)).toString();
 }
Esempio n. 2
0
 @Override
 public void copySettingsSpecific(
     TTextBoxSettingsBean srcTextBoxSettingsBean, TTextBoxSettingsBean destTextBoxSettingsBean) {
   destTextBoxSettingsBean.setDefaultDouble(srcTextBoxSettingsBean.getDefaultDouble());
   destTextBoxSettingsBean.setMaxDecimalDigit(srcTextBoxSettingsBean.getMaxDecimalDigit());
   destTextBoxSettingsBean.setMaxDouble(srcTextBoxSettingsBean.getMaxDouble());
   destTextBoxSettingsBean.setMinDouble(srcTextBoxSettingsBean.getMinDouble());
   destTextBoxSettingsBean.setParameterCode(srcTextBoxSettingsBean.getParameterCode());
   destTextBoxSettingsBean.setRequired(srcTextBoxSettingsBean.getRequired());
 }
Esempio n. 3
0
  @Override
  public List<ErrorData> isValidSettings(Map<Integer, Object> settings) {
    List<ErrorData> errorDataList = new ArrayList<ErrorData>();
    TTextBoxSettingsBean textBoxSettingsBean =
        (TTextBoxSettingsBean) settings.get(mapParameterCode);
    // textBoxSettingsBean can be null when no settings was set (especially by system fields)
    if (textBoxSettingsBean != null) {
      Double defaultDouble = textBoxSettingsBean.getDefaultDouble();
      Double minDouble = textBoxSettingsBean.getMinDouble();
      Double maxDouble = textBoxSettingsBean.getMaxDouble();
      Integer maxDecimalDigits = textBoxSettingsBean.getMaxDecimalDigit();

      if (minDouble != null
          && maxDouble != null
          && minDouble.doubleValue() > maxDouble.doubleValue()) {
        errorDataList.add(new ErrorData("customTextBoxDouble.error.minMax"));
      }
      if (minDouble != null
          && defaultDouble != null
          && minDouble.doubleValue() > defaultDouble.doubleValue()) {
        errorDataList.add(new ErrorData("customTextBoxDouble.error.defaultMin"));
      }
      if (maxDouble != null
          && defaultDouble != null
          && maxDouble.doubleValue() < defaultDouble.doubleValue()) {
        errorDataList.add(new ErrorData("customTextBoxDouble.error.defaultMax"));
      }
      if (maxDecimalDigits != null)
        if (maxDecimalDigits.intValue() < 0 || maxDecimalDigits.intValue() > maximalDecimalDigits) {
          errorDataList.add(
              new ErrorData(
                  "customTextBoxDouble.error.maxDecimalDigits", new Integer(maximalDecimalDigits)));
        } else {
          if (getNumberOfDecimalDigits(defaultDouble) > maxDecimalDigits.intValue()) {
            errorDataList.add(
                createDecimalDigitsMoreThanMaxDecimalDigitsErrorData(
                    "customTextBoxDouble.prompt.defaultDouble", maxDecimalDigits));
          }
          if (getNumberOfDecimalDigits(minDouble) > maxDecimalDigits.intValue()) {
            errorDataList.add(
                createDecimalDigitsMoreThanMaxDecimalDigitsErrorData(
                    "customTextBoxDouble.prompt.minValue", maxDecimalDigits));
          }
          if (getNumberOfDecimalDigits(maxDouble) > maxDecimalDigits.intValue()) {
            errorDataList.add(
                createDecimalDigitsMoreThanMaxDecimalDigitsErrorData(
                    "customTextBoxDouble.prompt.maxValue", maxDecimalDigits));
          }
        }
    }
    return errorDataList;
  }