Exemple #1
0
  /**
   * Derived property.
   *
   * @return ArrayList of model SelectItems
   */
  public ArrayList getPoolSelectList() {

    poolListSelectItems = new ArrayList();

    QuestionPoolService delegate = new QuestionPoolService();
    ArrayList<QuestionPoolFacade> qplist =
        delegate.getBasicInfoOfAllPools(AgentFacade.getAgentString());
    Iterator<QuestionPoolFacade> iter = qplist.iterator();

    try {
      while (iter.hasNext()) {
        QuestionPoolFacade pool = (QuestionPoolFacade) iter.next();

        // SAM-2269 - if the parent pool ID is greater than 0 (question pool IDs start at 1), get
        // the parent pool
        Long parentPoolID = pool.getParentPoolId();
        QuestionPoolFacade parent = null;
        if (parentPoolID > 0) {
          for (QuestionPoolFacade qp : qplist) {
            if (parentPoolID.equals(qp.getQuestionPoolId())) {
              parent = qp;
              break;
            }
          }
        }

        // SAM-2269 - add the appropriate string to the list
        String original =
            pool.getDisplayName() + " (" + delegate.getCountItems(pool.getQuestionPoolId()) + ")";
        if (parent != null) {
          poolListSelectItems.add(
              new SelectItem(
                  pool.getQuestionPoolId().toString(),
                  FormattedText.convertFormattedTextToPlaintext(
                      parent.getDisplayName() + ": " + original)));
        } else {
          poolListSelectItems.add(
              new SelectItem(
                  pool.getQuestionPoolId().toString(),
                  FormattedText.convertFormattedTextToPlaintext(original)));
        }
      }

    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    Collections.sort(poolListSelectItems, new ItemComparator());
    return poolListSelectItems;
  }