Beispiel #1
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;
 }
Beispiel #2
0
 /**
  * Reloads the consInfShow after "add" operation from the popup
  *
  * @return
  */
 public String load() {
   if (create) {
     List<TPersonBean> consultantPersons = consInfShow.getRealConsultantPersons();
     List<TPersonBean> informantPersons = consInfShow.getRealInformantPersons();
     consInfShow.setAmIConsultant(ConsInfBL.foundMeInRole(consultantPersons, person));
     consInfShow.setAmIInformant(ConsInfBL.foundMeInRole(informantPersons, person));
   } else {
     ConsInfBL.loadConsInfFromDb(workItemID, person, consInfShow);
   }
   return INPUT;
 }
Beispiel #3
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;
  }