コード例 #1
0
  /**
   * Method to handle the ajax operation getProjectResponsiblePerson.
   *
   * <p>Gets all the responsible person of the project and return as json.
   *
   * @return the result code.
   * @throws Exception if error.
   */
  public String getProjectResponsiblePerson() throws Exception {
    List<Map<String, Object>> result = new LinkedList<Map<String, Object>>();

    try {
      List<ResponsiblePerson> allResponsiblePeople =
          getMilestoneResponsiblePersonService().getAllResponsiblePeople(getDirectProjectId());

      for (ResponsiblePerson p : allResponsiblePeople) {

        Map<String, Object> data = new HashMap<String, Object>();
        data.put("userId", p.getUserId());
        data.put("name", p.getName());
        result.add(data);
      }

      setResult(result);

    } catch (Throwable e) {
      // set the error message into the ajax response
      if (getModel() != null) {
        setResult(e);
      }

      return ERROR;
    }

    return SUCCESS;
  }
コード例 #2
0
  /**
   * Gets the project milestones calendar dat via ajax.
   *
   * @return the result code.
   * @throws Exception if there is any error.
   */
  public String getProjectMilestoneCalendarData() throws Exception {
    List<Map<String, Object>> result = new LinkedList<Map<String, Object>>();

    try {
      final List<Milestone> allMilestones =
          this.getMilestoneService()
              .getAll(getFormData().getProjectId(), ALL_MILESTONE_STATUS, SortOrder.ASCENDING);

      for (Milestone m : allMilestones) {
        Map<String, Object> data = new HashMap<String, Object>();

        data.put("title", m.getName());
        data.put("status", m.getStatus().toString().toLowerCase());
        if (m.isCompleted()) {
          data.put("start", CALENDAR_DATE_FORMAT.format(m.getCompletionDate()));
        } else {
          data.put("start", CALENDAR_DATE_FORMAT.format(m.getDueDate()));
        }

        data.put("description", m.getDescription());

        if (m.getOwners() != null && m.getOwners().size() > 0) {
          ResponsiblePerson rp = m.getOwners().get(0);

          if (rp != null) {
            Map<String, Object> person = new HashMap<String, Object>();
            person.put("name", rp.getName());
            person.put("color", DEFAULT_USER_HANDLE_CLASS);
            person.put("url", DEFAULT_USER_HANDLE_URL);

            data.put("person", person);
          }
        }

        result.add(data);
      }
      setResult(result);

    } catch (Throwable e) {
      // set the error message into the ajax response
      if (getModel() != null) {
        setResult(e);
      }
      return ERROR;
    }
    return SUCCESS;
  }