Example #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();
 }
Example #2
0
 /**
  * Creates the file upload JSON string for a template
  *
  * @param success
  * @param existingTemplates
  * @return
  */
 public static String createFileSelectJSON(
     boolean success, List<LabelValueBean> existingTemplates, String selectedTemplate) {
   StringBuilder sb = new StringBuilder();
   sb.append("{");
   JSONUtility.appendBooleanValue(sb, JSONUtility.JSON_FIELDS.SUCCESS, success);
   sb.append(JSONUtility.JSON_FIELDS.DATA).append(":{");
   JSONUtility.appendStringValue(sb, "docxTemplateList", selectedTemplate);
   JSONUtility.appendLabelValueBeanList(sb, "existingTemplates", existingTemplates);
   sb.append("}");
   sb.append("}");
   return sb.toString();
 }
Example #3
0
 @Override
 public String encodeJSONExtraDataConfig(
     Map<String, String> parameters, TPersonBean user, Integer entityId, Integer entityType) {
   StringBuilder sb = new StringBuilder();
   JSONUtility.appendStringValue(sb, "tql", parameters.get("tql"));
   return sb.toString();
 }
Example #4
0
 /** No negative numbers are allowed */
 @Override
 public String createJsonData(TFieldBean field, WorkItemContext workItemContext) {
   StringBuilder sb = new StringBuilder();
   sb.append("{");
   JSONUtility.appendIntegerValue(sb, "minValue", 0, true);
   sb.append("}");
   return sb.toString();
 }
Example #5
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();
 }
 /**
  * Gets the JSON string for new a field
  *
  * @param personBean
  * @param locale
  * @param bundleName
  * @return
  */
 @Override
 public String getDefaultSettingsJSON(TPersonBean personBean, Locale locale, String bundleName) {
   StringBuilder stringBuilder = new StringBuilder();
   JSONUtility.appendILabelBeanList(
       stringBuilder,
       FieldConfigJSON.JSON_FIELDS.OPTION_SETTINGS_LISTS,
       getLists(null, locale, null));
   return stringBuilder.append(getLocalizationJSON(locale, bundleName)).toString();
 }
  /**
   * 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.OPTION_SETTINGS_LIST_LABEL,
        getListLabel(locale, bundleName));

    return stringBuilder.toString();
  }
Example #8
0
 /**
  * Adds/removes the current user as consultant/informant to/from the database or to/from the
  * session and then refreshes the consInfShow in the session
  *
  * @return
  */
 private String me() {
   if (create) {
     // add consultant/informant
     if ("a".equals(operation)) {
       if (RaciRole.CONSULTANT.equals(raciRole)) {
         consInfShow.setAmIConsultant(true);
         List<TPersonBean> realConsultantPersons = consInfShow.getRealConsultantPersons();
         if (realConsultantPersons == null) {
           realConsultantPersons = new ArrayList<TPersonBean>();
           consInfShow.setRealConsultantPersons(realConsultantPersons);
         }
         ConsInfBL.meAdd(realConsultantPersons, person);
       }
       if (RaciRole.INFORMANT.equals(raciRole)) {
         consInfShow.setAmIInformant(true);
         List<TPersonBean> realInformantPersons = consInfShow.getRealInformantPersons();
         if (realInformantPersons == null) {
           realInformantPersons = new ArrayList<TPersonBean>();
           consInfShow.setRealInformantGroups(realInformantPersons);
         }
         ConsInfBL.meAdd(realInformantPersons, person);
       }
     }
     // remove consultant/informant
     if ("r".equals(operation)) {
       if (RaciRole.CONSULTANT.equals(raciRole)) {
         consInfShow.setAmIConsultant(false);
         ConsInfBL.meRemove(consInfShow.getRealConsultantPersons(), person);
       }
       if (RaciRole.INFORMANT.equals(raciRole)) {
         consInfShow.setAmIInformant(false);
         ConsInfBL.meRemove(consInfShow.getRealInformantPersons(), person);
       }
     }
   } else {
     // add consultant/informant
     if ("a".equals(operation)) {
       ConsInfBL.insertByWorkItemAndPersonAndRaciRole(workItemID, person, raciRole);
     }
     // remove consultant/informant
     if ("r".equals(operation)) {
       ConsInfBL.deleteByWorkItemAndPersonsAndRaciRole(
           workItemID, new Integer[] {person}, raciRole);
     }
     // reload the consultants/informants in editConsInfForm
     if (consInfShow == null) {
       consInfShow = new ConsInfShow();
     }
     ConsInfBL.loadConsInfFromDb(workItemID, person, consInfShow);
   }
   JSONUtility.encodeJSONSuccess(ServletActionContext.getResponse());
   return null;
 }
 /**
  * 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();
 }
Example #10
0
 /**
  * The main entry point into the action. It will be branched to the specific operation depending
  * on the request parameter called "operation". This extra "operation" parameter should be used
  * (instead of action!method syntax in jsp submit tags) because the buttons which trigger this
  * operations are on the toolbar (outside of the HTML form) The submit resulting in executing this
  * method will be triggered through AJAX
  */
 @Override
 public String execute() {
   if ("d".equals(operation)) {
     // delete selected consultant/informant persons/groups
     delete();
   }
   if ("r".equals(operation) || "a".equals(operation)) {
     // add/remove me
     me();
   }
   // by tab change to cons/inf tab or refresh from add consultant/informant popup
   JSONUtility.encodeJSONSuccess(ServletActionContext.getResponse());
   return null;
 }
Example #11
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();
 }
Example #12
0
  /**
   * Deletes the selected consultants/informants from the database or from the session and then
   * refreshes the consInfShow in the session
   *
   * @return
   */
  private String delete() {
    Integer[] selectedConsultantPersons = consInfShow.getSelectedConsultantPersons();
    Integer[] selectedConsultantGroups = consInfShow.getSelectedConsultantGroups();
    Integer[] selectedInformantPersons = consInfShow.getSelectedInformantPersons();
    Integer[] selectedInformantGroups = consInfShow.getSelectedInformantGroups();
    if ((selectedConsultantPersons == null || selectedConsultantPersons.length == 0)
        && (selectedConsultantGroups == null || selectedConsultantGroups.length == 0)
        && (selectedInformantPersons == null || selectedInformantPersons.length == 0)
        && (selectedInformantGroups == null || selectedInformantGroups.length == 0)) {
      return null;
    }
    if (create) {
      // reset me if present and selected
      if (ConsInfBL.foundMeAsSelected(selectedConsultantPersons, person)) {
        consInfShow.setAmIConsultant(false);
      }
      if (ConsInfBL.foundMeAsSelected(selectedInformantPersons, person)) {
        consInfShow.setAmIInformant(false);
      }
      // remove the selected persons/groups from the session object
      ConsInfBL.deleteSelected(consInfShow.getRealConsultantPersons(), selectedConsultantPersons);
      ConsInfBL.deleteSelected(consInfShow.getRealConsultantGroups(), selectedConsultantGroups);
      ConsInfBL.deleteSelected(consInfShow.getRealInformantPersons(), selectedInformantPersons);
      ConsInfBL.deleteSelected(consInfShow.getRealInformantGroups(), selectedInformantGroups);
    } else {
      // delete selected consultant persons/groups
      ConsInfBL.deleteByWorkItemAndPersonsAndRaciRole(
          workItemID, selectedConsultantPersons, RaciRole.CONSULTANT);
      ConsInfBL.deleteByWorkItemAndPersonsAndRaciRole(
          workItemID, selectedConsultantGroups, RaciRole.CONSULTANT);

      // delete selected informant persons/groups
      ConsInfBL.deleteByWorkItemAndPersonsAndRaciRole(
          workItemID, selectedInformantPersons, RaciRole.INFORMANT);
      ConsInfBL.deleteByWorkItemAndPersonsAndRaciRole(
          workItemID, selectedInformantGroups, RaciRole.INFORMANT);

      // reload the consultants/informants from database
      ConsInfBL.loadConsInfFromDb(workItemID, person, consInfShow);
    }
    consInfShow.setSelectedConsultantPersons(new Integer[0]);
    consInfShow.setSelectedConsultantGroups(new Integer[0]);
    consInfShow.setSelectedInformantPersons(new Integer[0]);
    consInfShow.setSelectedInformantGroups(new Integer[0]);
    JSONUtility.encodeJSONSuccess(ServletActionContext.getResponse());
    return null;
  }