/**
   * Get the recently submitted items for the given collection.
   *
   * @param collection The collection.
   */
  @SuppressWarnings(
      "unchecked") // The cast from getLastSubmitted is correct, it dose infact return a list of
                   // Items.
  private java.util.List<BrowseItem> getRecientlySubmittedIems(Collection collection)
      throws SQLException {
    if (recentSubmissionItems != null) return recentSubmissionItems;

    String source = ConfigurationManager.getProperty("recent.submissions.sort-option");
    BrowserScope scope = new BrowserScope(context);
    scope.setCollection(collection);
    scope.setResultsPerPage(RECENT_SUBMISISONS);

    // FIXME Exception Handling
    try {
      scope.setBrowseIndex(BrowseIndex.getItemBrowseIndex());
      for (SortOption so : SortOption.getSortOptions()) {
        if (so.getName().equals(source)) scope.setSortBy(so.getNumber());
      }

      BrowseEngine be = new BrowseEngine(context);
      this.recentSubmissionItems = be.browse(scope).getResults();
    } catch (BrowseException bex) {
      log.error("Caught BrowseException", bex);
    }

    return this.recentSubmissionItems;
  }
  /**
   * Add the controls to changing sorting and display options.
   *
   * @param div
   * @param info
   * @param params
   * @throws WingException
   */
  private void addBrowseControls(Division div, BrowseInfo info, BrowseParams params)
      throws WingException {
    // Prepare a Map of query parameters required for all links
    Map<String, String> queryParams = new HashMap<String, String>();

    queryParams.putAll(params.getCommonParameters());

    Division controls =
        div.addInteractiveDivision(
            "browse-controls", BROWSE_URL_BASE, Division.METHOD_POST, "browse controls");

    // Add all the query parameters as hidden fields on the form
    for (String key : queryParams.keySet()) controls.addHidden(key).setValue(queryParams.get(key));

    Para controlsForm = controls.addPara();

    // If we are browsing a list of items
    if (isItemBrowse(info)) //  && info.isSecondLevel()
    {
      try {
        // Create a drop down of the different sort columns available
        Set<SortOption> sortOptions = SortOption.getSortOptions();

        // Only generate the list if we have multiple columns
        if (sortOptions.size() > 1) {
          controlsForm.addContent(T_sort_by);
          Select sortSelect = controlsForm.addSelect(BrowseParams.SORT_BY);

          for (SortOption so : sortOptions) {
            sortSelect.addOption(
                so.equals(info.getSortOption()),
                so.getNumber(),
                message("xmlui.ArtifactBrowser.ConfigurableBrowse.sort_by." + so.getName()));
          }
        }
      } catch (BrowseException be) {
        throw new WingException("Unable to get sort options", be);
      }
    }

    // Create a control to changing ascending / descending order
    controlsForm.addContent(T_order);
    Select orderSelect = controlsForm.addSelect(BrowseParams.ORDER);
    orderSelect.addOption("ASC".equals(params.scope.getOrder()), "ASC", T_order_asc);
    orderSelect.addOption("DESC".equals(params.scope.getOrder()), "DESC", T_order_desc);

    // Create a control for the number of records to display
    controlsForm.addContent(T_rpp);
    Select rppSelect = controlsForm.addSelect(BrowseParams.RESULTS_PER_PAGE);
    for (int i = 5; i <= 100; i += 5) {
      rppSelect.addOption((i == info.getResultsPerPage()), i, Integer.toString(i));
    }

    // Create a control for the number of authors per item to display
    // FIXME This is currently disabled, as the supporting functionality
    // is not currently present in xmlui
    // if (isItemBrowse(info))
    // {
    //    controlsForm.addContent(T_etal);
    //    Select etalSelect = controlsForm.addSelect(BrowseParams.ETAL);
    //
    //    etalSelect.addOption((info.getEtAl() < 0), 0, T_etal_all);
    //    etalSelect.addOption(1 == info.getEtAl(), 1, Integer.toString(1));
    //
    //    for (int i = 5; i <= 50; i += 5)
    //    {
    //        etalSelect.addOption(i == info.getEtAl(), i, Integer.toString(i));
    //    }
    // }

    controlsForm.addButton("update").setValue(T_update);
  }