Пример #1
0
  /**
   * If the onEventUpdate event is called. <br>
   * Handles the resizing or movement of an calendarEvent. Saves the new data to db.
   *
   * @param event
   */
  public void onEventUpdate$cal(CalendarsEvent evt) {

    // SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/d");
    // sdf1.setTimeZone(cal.getDefaultTimeZone());

    int left = evt.getX();
    int top = evt.getY();
    if (top + 100 > evt.getDesktopHeight()) top = evt.getDesktopHeight() - 100;
    if (left + 330 > evt.getDesktopWidth()) left = evt.getDesktopWidth() - 330;

    SimpleCalendarModel m = (SimpleCalendarModel) cal.getModel();
    MySimpleCalendarEvent sce = (MySimpleCalendarEvent) evt.getCalendarEvent();
    sce.setBeginDate(evt.getBeginDate());
    sce.setEndDate(evt.getEndDate());
    // update the model
    // m.update(sce); <-- if activated, later an error occurs

    // prepare the backend Bean
    MyCalendarEvent calEvt = getCalendarEventService().getNewCalendarEvent();
    calEvt.setId(sce.getId());
    calEvt.setSecUser(sce.getUser());
    calEvt.setVersion(sce.getVersion());
    calEvt.setTitle(sce.getTitle());
    calEvt.setContent(sce.getContent());
    calEvt.setBeginDate(sce.getBeginDate());
    calEvt.setEndDate(sce.getEndDate());
    calEvt.setHeaderColor(sce.getHeaderColor());
    calEvt.setContentColor(sce.getContentColor());
    // Save the calendar event to database
    try {
      getCalendarEventService().saveOrUpdate(calEvt);
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      synchronizeModel();
    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  public void onEventEdit(CalendarsEvent event) throws InterruptedException, RemoteException {
    try {
      StorageComponentProxy proxy = SystemDictionary.getSCProxy();
      Session ses = Sessions.getCurrent();
      String userid = (String) ses.getAttribute("userid");
      bookEventWin = (Window) Executions.createComponents("bookEvent.zul", self.getParent(), null);
      bookEventWin.setAttribute("calendars", cal);
      bookEventWin.setAttribute("calevent", event);
      Date setting = event.getCalendarEvent().getBeginDate();
      SimpleCalendarEvent scevent = (SimpleCalendarEvent) event.getCalendarEvent();
      bookEventWin.getFellow("cancelbutton").setVisible(true);
      ((Datebox) bookEventWin.getFellow("datetask")).setValue(setting);
      ((Datebox) bookEventWin.getFellow("datetask")).setReadonly(true);
      ((Datebox) bookEventWin.getFellow("datetask")).setButtonVisible(false);
      ((Timebox) bookEventWin.getFellow("timetask")).setValue(setting);
      ((Timebox) bookEventWin.getFellow("timetask")).setReadonly(true);
      ((Timebox) bookEventWin.getFellow("timetask")).setButtonVisible(false);
      ((Textbox) bookEventWin.getFellow("taskidfield"))
          .setValue((String) scevent.getParams().get("task"));
      ((Textbox) bookEventWin.getFellow("taskstatusfield"))
          .setValue(
              SystemDictionary.getTaskStatusLabel((String) scevent.getParams().get("status")));
      bookEventWin.getFellow("rowtaskstatus").setVisible(true);
      if (scevent.getParams().get("status").equals(SystemDictionary.TASK_STATUS_COMPLETED)) {
        bookEventWin.getFellow("cancelbutton").setVisible(false);
        String tasktype = (String) scevent.getParams().get("type");
        if (tasktype.equals(SystemDictionary.TASK_TYPE_CARERQS)
            || tasktype.equals(SystemDictionary.TASK_TYPE_PATIENTQS)) {
          // TODO retrieve Questionnaire answers and show in the task window
          Questionnaire q = (Questionnaire) scevent.getParams().get("questionnaire");
          QuestionnaireAnswers qa =
              proxy.getQuestionnaireAnswersByTask((String) scevent.getParams().get("task"), userid);
          SystemDictionary.webguiLog(
              "INFO", "task id: " + (String) scevent.getParams().get("task"));
          // SystemDictionary.webguiLog("INFO", "ANSWERS LENGTH: "+ qa.getAnswer().length);
          // SystemDictionary.webguiLog("INFO", "getQuestion: "+ q.getQuestion().length);
          ArrayList<QuestionnaireAnswer> qalist = new ArrayList<QuestionnaireAnswer>();
          if (qa.getAnswer() != null)
            for (int i = 0; i < qa.getAnswer().length; i++) {
              qalist.add(i, qa.getAnswer(i));
            }

          String responses = provideQuestionnaireResponse(toPlainList(q.getQuestion()), qalist);
          SystemDictionary.webguiLog("DEBUG", "RESPONSES: " + responses);
          bookEventWin.getFellow("qsanswersrow").setVisible(true);
          ((Label) bookEventWin.getFellow("qsanswersfield")).setValue(responses);

        } else if (tasktype.equals(SystemDictionary.TASK_TYPE_BLOODPRESSURE_MEASUREMENT)
            || tasktype.equals(SystemDictionary.TASK_TYPE_WEIGHT_MEASUREMENT)
            || tasktype.equals(SystemDictionary.TASK_TYPE_ACTMONITOR)) {
          String resultfieldvalue = "";
          SearchCriteria searchc =
              new SearchCriteria(
                  "task",
                  new SystemParameter(SystemDictionary.COMPARE_EQ, ""),
                  (String) scevent.getParams().get("task"),
                  "");
          Measurement[] results = proxy.getMeasurement(new SearchCriteria[] {searchc}, userid);
          if (results.length <= 0) {
            resultfieldvalue = "No measurement could be retrieved";
          } else {
            resultfieldvalue = "Use 'Monitor Measurements' button for viewing the measurements";
            /*SystemDictionary.webguiLog("DEBUG", "RESULTS LENGHT: "+results.length);
            for(int ii = 0 ; ii < results.length ; ii++){
            	resultfieldvalue += results[ii].getValue()+""+results[ii].getUnits()+"\n";
            }*/
          }
          bookEventWin.getFellow("mresultrow").setVisible(true);
          ((Label) bookEventWin.getFellow("mresultrowfield")).setValue(resultfieldvalue);
        }
      }
      User addressed = proxy.getUser((String) scevent.getParams().get("objid"));
      Patient patient = proxy.getPatient(addressed.getPersonID(), userid);
      ((Textbox) bookEventWin.getFellow("addressedid"))
          .setValue((String) scevent.getParams().get("objid"));
      ((Textbox) bookEventWin.getFellow("addressedstr")).setValue(patient.toString());
      User object = proxy.getUser((String) scevent.getParams().get("exec"));
      Carer executor = proxy.getCarer(object.getPersonID(), userid);
      ((Textbox) bookEventWin.getFellow("objid"))
          .setValue((String) scevent.getParams().get("exec"));
      ((Textbox) bookEventWin.getFellow("objstr")).setValue(executor.toString());
      User assigner = proxy.getUser((String) scevent.getParams().get("assign"));
      Clinician assg = proxy.getClinician(assigner.getPersonID(), userid);
      ((Textbox) bookEventWin.getFellow("userid"))
          .setValue((String) scevent.getParams().get("assign"));
      ((Textbox) bookEventWin.getFellow("userstr")).setValue(assg.toString());
      ((Textbox) bookEventWin.getFellow("tasktypetext")).setValue(scevent.getContent());
      bookEventWin.getFellow("tasktypetext").setVisible(true);
      // ((Combobox)bookEventWin.getFellow("addressedtext")).setVisible(false);
      int tasktype2 = Integer.parseInt((String) scevent.getParams().get("type"));
      this.showCustomFields(tasktype2);
      bookEventWin.getFellow("tasktypesel").setVisible(false);
      @SuppressWarnings("rawtypes")
      List items = ((Listbox) bookEventWin.getFellow("urlfield")).getItems();
      @SuppressWarnings("rawtypes")
      Iterator it = items.iterator();
      while (it.hasNext()) {
        Listitem currentitem = (Listitem) it.next();
        if (currentitem.getValue().equals((String) scevent.getParams().get("url"))) {
          ((Listbox) bookEventWin.getFellow("urlfield")).setSelectedItem(currentitem);
          break;
        }
      }
      ((Listbox) bookEventWin.getFellow("urlfield")).setDisabled(true);
      if (scevent.getParams().get("questionnaire") != null) {
        items = ((Listbox) bookEventWin.getFellow("questnamefield")).getItems();
        it = items.iterator();
        while (it.hasNext()) {
          Listitem currentitem = (Listitem) it.next();
          if (currentitem
              .getValue()
              .equals(((Questionnaire) scevent.getParams().get("questionnaire")).getID())) {
            ((Listbox) bookEventWin.getFellow("questnamefield")).setSelectedItem(currentitem);
            break;
          }
        }
      }
      ((Listbox) bookEventWin.getFellow("questnamefield")).setDisabled(true);
      // ((Textbox)bookEventWin.getFellow("urlfield")).setValue((String)scevent.getParams().get("url"));
      ((Textbox) bookEventWin.getFellow("textfield"))
          .setValue((String) scevent.getParams().get("text"));

      bookEventWin.setTitle("View Task");
      bookEventWin.setVisible(true);
      bookEventWin.doModal();
    } catch (Exception e) {
      e.printStackTrace();
      Executions.sendRedirect("");
    }
  }