Пример #1
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;
  }