/**
  * Get the value to be shown from the database and then try to localize
  *
  * @param value
  * @param locale
  * @return
  */
 @Override
 public String getShowValue(Object value, Locale locale) {
   String keySuffix = BooleanFields.FALSE_VALUE;
   if (value == null) {
     value = TWorkItemBean.ACCESS_LEVEL_PUBLIC;
   }
   Integer intValue = null;
   try {
     intValue = (Integer) value;
   } catch (Exception e) {
     LOGGER.warn(
         "Casting the value type "
             + value.getClass().getName()
             + " to Integer failed with "
             + e.getMessage());
     LOGGER.debug(ExceptionUtils.getStackTrace(e));
   }
   if (intValue != null && TWorkItemBean.ACCESS_LEVEL_PRIVATE.equals(intValue)) {
     keySuffix = BooleanFields.TRUE_VALUE;
   }
   String localizedLabel =
       LocalizeUtil.getLocalizedTextFromApplicationResources(
           "common.boolean." + keySuffix, locale);
   if (localizedLabel != null && localizedLabel.length() > 0) {
     return localizedLabel;
   }
   return keySuffix;
 }
Exemple #2
0
 @Override
 public Map<String, String> convertMapFromPageConfig(
     Map<String, String> properties,
     TPersonBean user,
     Locale locale,
     Integer entityId,
     Integer entityType,
     List<LabelValueBean> errors) {
   Map<String, String> map =
       super.convertMapFromPageConfig(properties, user, locale, entityId, entityType, errors);
   String tql = properties.get("tql");
   if (tql == null || tql.length() == 0) {
     String localizedErr =
         LocalizeUtil.getParametrizedString(
             "common.err.required",
             new Object[] {BasePluginDashboardBL.getText("myTqlView.tql", locale)},
             locale);
     errors.add(new LabelValueBean(localizedErr, "params.tql"));
   } else {
     List<ErrorData> criteriaErrors = new ArrayList<ErrorData>();
     TqlBL.luceneQuery(tql, false, locale, null, criteriaErrors);
     if (!criteriaErrors.isEmpty()) {
       StringBuilder sb = new StringBuilder();
       for (int i = 0; i < criteriaErrors.size(); i++) {
         sb.append(ErrorHandlerJSONAdapter.createMessage(criteriaErrors.get(i), locale) + "</BR>");
       }
       errors.add(new LabelValueBean(sb.toString(), "params.tql"));
     }
   }
   return map;
 }
Exemple #3
0
 /**
  * Gets the localized labels used in field specific configuration (are common for
  * getSettingsJSON() and getDefaultSettingsJSON())
  *
  * @param locale
  * @param bundleName
  * @return
  */
 @Override
 public String getLocalizationJSON(Locale locale, String bundleName) {
   StringBuilder stringBuilder = new StringBuilder();
   JSONUtility.appendStringValue(
       stringBuilder,
       FieldConfigJSON.JSON_FIELDS.TEXTBOX_SETTINGS_DEFAULT_DOUBLE_LABEL,
       LocalizeUtil.getLocalizedText(
           "customTextBoxDouble.prompt.defaultDouble", locale, bundleName));
   JSONUtility.appendStringValue(
       stringBuilder,
       FieldConfigJSON.JSON_FIELDS.TEXTBOX_SETTINGS_MIN_DOUBLE_LABEL,
       LocalizeUtil.getLocalizedText("customTextBoxDouble.prompt.minValue", locale, bundleName));
   JSONUtility.appendStringValue(
       stringBuilder,
       FieldConfigJSON.JSON_FIELDS.TEXTBOX_SETTINGS_MAX_DOUBLE_LABEL,
       LocalizeUtil.getLocalizedText("customTextBoxDouble.prompt.maxValue", locale, bundleName));
   return stringBuilder.toString();
 }
Exemple #4
0
 /**
  * Gets the localized options for an entity
  *
  * @param locale
  * @return
  */
 public static List<TSystemStateBean> getStatusOptions(Integer entityFlag, Locale locale) {
   List<TSystemStateBean> statusOptions = LookupContainer.getSystemStateList(entityFlag);
   if (statusOptions != null) {
     for (TSystemStateBean systemStateBean : statusOptions) {
       systemStateBean.setLabel(
           LocalizeUtil.localizeSystemStateEntry(systemStateBean, entityFlag, locale));
     }
   }
   return statusOptions;
 }
 /**
  * Saves a mail template
  *
  * @param copy
  * @param objectID
  * @param templateID
  * @param plain
  * @param theLocale
  * @param mailSubject
  * @param mailBody
  * @param locale
  * @return
  */
 static String saveTemplateDef(
     boolean copy,
     Integer templateID,
     Integer objectID,
     boolean plain,
     String theLocale,
     String mailSubject,
     String mailBody,
     Locale locale) {
   TMailTemplateDefBean mailTemplateDefBean = null;
   if (objectID != null && !copy) {
     LOGGER.info("Load by primary key=" + objectID.toString());
     mailTemplateDefBean = mailTemplateDefDAO.loadByPrimaryKey(objectID);
   }
   List<TMailTemplateDefBean> mailTemplates =
       mailTemplateDefDAO.loadByTemplateTypeAndLocale(templateID, plain, theLocale);
   if (mailTemplates != null && !mailTemplates.isEmpty()) {
     TMailTemplateDefBean existingMailTemplateBean = mailTemplates.get(0);
     LOGGER.info("Existing TemplateBean ID=" + existingMailTemplateBean.getObjectID().toString());
     if (objectID == null || copy || !existingMailTemplateBean.getObjectID().equals(objectID)) {
       return JSONUtility.encodeJSONFailure(
           LocalizeUtil.getLocalizedTextFromApplicationResources(
               "admin.customize.mailTemplate.err.existingTemplate", locale));
     }
   }
   if (mailTemplateDefBean == null) {
     mailTemplateDefBean = new TMailTemplateDefBean();
   }
   LOGGER.debug("setting data");
   mailTemplateDefBean.setMailTemplate(templateID);
   mailTemplateDefBean.setTheLocale(theLocale);
   mailTemplateDefBean.setIsPlainEmailBool(plain);
   mailTemplateDefBean.setMailSubject(mailSubject);
   mailTemplateDefBean.setMailBody(mailBody);
   mailTemplateDefBean.setTemplateChanged(BooleanFields.TRUE_VALUE); // mark it private
   mailTemplateDefDAO.save(mailTemplateDefBean);
   LOGGER.debug("saving data");
   return JSONUtility.encodeJSONSuccess();
 }
 protected String getListLabel(Locale locale, String bundleName) {
   return LocalizeUtil.getLocalizedText("customSelectSimple.prompt.list", locale, bundleName);
 }