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