Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
0
 /**
  * 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();
 }