Пример #1
0
  /**
   * Add the basic navigational options:
   *
   * <p>Search - advanced search
   *
   * <p>browse - browse by Titles - browse by Authors - browse by Dates
   *
   * <p>language FIXME: add languages
   *
   * <p>context no context options are added.
   *
   * <p>action no action options are added.
   */
  public void addOptions(Options options)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    /* Create skeleton menu structure to ensure consistent order between aspects,
     * even if they are never used
     */
    List browse = options.addList("browse");
    options.addList("account");
    options.addList("context");
    options.addList("administrative");

    browse.setHead(T_head_browse);

    List browseGlobal = browse.addList("global");
    List browseContext = browse.addList("context");

    browseGlobal.setHead(T_head_all_of_dspace);

    browseGlobal.addItemXref(contextPath + "/community-list", T_communities_and_collections);

    // Add the configured browse lists for 'top level' browsing
    addBrowseOptions(browseGlobal, contextPath + "/browse");

    DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
    if (dso != null) {
      if (dso instanceof Item) {
        // If we are an item change the browse scope to the parent
        // collection.
        dso = ((Item) dso).getOwningCollection();
      }

      if (dso instanceof Collection) {
        browseContext.setHead(T_head_this_collection);
      }
      if (dso instanceof Community) {
        browseContext.setHead(T_head_this_community);
      }

      // Add the configured browse lists for scoped browsing
      String handle = dso.getHandle();
      addBrowseOptions(browseContext, contextPath + "/handle/" + handle + "/browse");
    }
  }
Пример #2
0
  /**
   * Add navigation for the configured browse tables to the supplied list.
   *
   * @param browseList
   * @param browseURL
   * @throws WingException
   */
  private void addBrowseOptions(List browseList, String browseURL) throws WingException {
    // FIXME Exception handling
    try {
      // Get a Map of all the browse tables
      BrowseIndex[] bis = BrowseIndex.getBrowseIndices();
      for (BrowseIndex bix : bis) {
        // Create a Map of the query parameters for this link
        Map<String, String> queryParams = new HashMap<String, String>();

        queryParams.put("type", bix.getName());

        // Add a link to this browse
        browseList.addItemXref(
            super.generateURL(browseURL, queryParams),
            message("xmlui.ArtifactBrowser.Navigation.browse_" + bix.getName()));
      }
    } catch (BrowseException bex) {
      throw new UIException("Unable to get browse indicies", bex);
    }
  }
  public void addBody(Body body) throws WingException, SQLException {
    // Get all our parameters
    String baseURL = contextPath + "/admin/groups?administrative-continue=" + knot.getId();
    String query = parameters.getParameter("query", "");
    int page = parameters.getParameterAsInteger("page", 0);
    int highlightID = parameters.getParameterAsInteger("highlightID", -1);
    // FIXME: Bad!
    //        int resultCount = Group.searchResultCount(context, query);
    int resultCount = Group.search(context, query).length;
    Group[] groups = Group.search(context, query, page * PAGE_SIZE, PAGE_SIZE);

    // DIVISION: groups-main
    Division main =
        body.addInteractiveDivision(
            "groups-main",
            contextPath + "/admin/groups",
            Division.METHOD_POST,
            "primary administrative groups");
    main.setHead(T_main_head);

    // DIVISION: group-actions
    Division actions = main.addDivision("group-actions");
    actions.setHead(T_actions_head);

    // Browse Epeople
    List actionsList = actions.addList("actions");
    actionsList.addLabel(T_actions_create);
    actionsList.addItemXref(baseURL + "&submit_add", T_actions_create_link);
    actionsList.addLabel(T_actions_browse);
    actionsList.addItemXref(baseURL + "&query&submit_search", T_actions_browse_link);

    actionsList.addLabel(T_actions_search);
    org.dspace.app.xmlui.wing.element.Item actionItem = actionsList.addItem();
    Text queryField = actionItem.addText("query");
    if (query != null) queryField.setValue(query);
    queryField.setHelp(T_search_help);
    actionItem.addButton("submit_search").setValue(T_go);

    // DIVISION: group-search
    Division search = main.addDivision("group-search");
    search.setHead(T_search_head);

    if (resultCount > PAGE_SIZE) {
      // If there are enough results then paginate the results
      int firstIndex = page * PAGE_SIZE + 1;
      int lastIndex = page * PAGE_SIZE + groups.length;

      String nextURL = null, prevURL = null;
      if (page < (resultCount / PAGE_SIZE)) nextURL = baseURL + "&page=" + (page + 1);
      if (page > 0) prevURL = baseURL + "&page=" + (page - 1);

      search.setSimplePagination(resultCount, firstIndex, lastIndex, prevURL, nextURL);
    }

    Table table = search.addTable("groups-search-table", groups.length + 1, 1);
    Row header = table.addRow(Row.ROLE_HEADER);
    header.addCell().addContent(T_search_column1);
    header.addCell().addContent(T_search_column2);
    header.addCell().addContent(T_search_column3);
    header.addCell().addContent(T_search_column4);
    header.addCell().addContent(T_search_column5);

    for (Group group : groups) {
      Row row;
      if (group.getID() == highlightID) row = table.addRow(null, null, "highlight");
      else row = table.addRow();

      if (group.getID() > 1) {
        CheckBox select = row.addCell().addCheckBox("select_group");
        select.setLabel(new Integer(group.getID()).toString());
        select.addOption(new Integer(group.getID()).toString());
      } else {
        // Don't allow the user to remove the administrative (id:1) or
        // anonymous group (id:0)
        row.addCell();
      }

      row.addCell().addContent(group.getID());
      row.addCell().addXref(baseURL + "&submit_edit&groupID=" + group.getID(), group.getName());

      int memberCount = group.getMembers().length + group.getMemberGroups().length;
      row.addCell().addContent(memberCount == 0 ? "-" : String.valueOf(memberCount));

      Cell cell = row.addCell();
      if (FlowGroupUtils.getCollectionId(group.getName()) > -1) {
        Collection collection =
            Collection.find(context, FlowGroupUtils.getCollectionId(group.getName()));
        if (collection != null) {
          String collectionName = collection.getMetadata("name");

          if (collectionName == null) collectionName = "";
          else if (collectionName.length() > MAX_COLLECTION_NAME)
            collectionName = collectionName.substring(0, MAX_COLLECTION_NAME - 3) + "...";

          cell.addContent(collectionName + " ");

          Highlight highlight = cell.addHighlight("fade");

          highlight.addContent("[");
          highlight.addXref(
              contextPath + "/handle/" + collection.getExternalIdentifier().getCanonicalForm(),
              T_collection_link);
          highlight.addContent("]");
        }
      }
    }

    if (groups.length <= 0) {
      Cell cell = table.addRow().addCell(1, 5);
      cell.addHighlight("italic").addContent(T_no_results);
    } else {
      search.addPara().addButton("submit_delete").setValue(T_submit_delete);
    }

    search.addHidden("administrative-continue").setValue(knot.getId());
  }
Пример #4
0
  /** Sherpa romeo submission support */
  public void make_sherpaRomeo_submission(Item item, Division divIn) throws WingException {

    if (ConfigurationManager.getBooleanProperty(
        "webui.submission.sherparomeo-policy-enabled", true)) {

      SHERPASubmitService sherpaSubmitService =
          new DSpace().getSingletonService(SHERPASubmitService.class);

      if (sherpaSubmitService.hasISSNs(context, item)) {
        List div = divIn.addList("submit-upload-new", List.TYPE_FORM);
        div.setHead(T_sherpa_title);

        // Since sherpa web service doesn't work reliable with more than 1 issn, perform the service
        // for each issn
        Set<String> issns = sherpaSubmitService.getISSNs(context, item);
        Iterator<String> issnsIterator = issns.iterator();

        int i = 0;
        while (issnsIterator.hasNext()) {
          SHERPAResponse shresp =
              sherpaSubmitService.searchRelatedJournalsByISSN(issnsIterator.next());
          java.util.List<SHERPAJournal> journals = shresp.getJournals();
          java.util.List<SHERPAPublisher> publishers = shresp.getPublishers();

          if (CollectionUtils.isNotEmpty(journals)) {
            for (SHERPAJournal journ : journals) {
              SHERPAPublisher pub = publishers.get(0);

              List sherpaList = div.addList("sherpaList" + (i + 1), "simple", "sherpaList");
              sherpaList
                  .addItem()
                  .addFigure(
                      contextPath + "/static/images/" + (i == 0 ? "romeosmall" : "clear") + ".gif",
                      "http://www.sherpa.ac.uk/romeo/",
                      "sherpaLogo");

              sherpaList.addItem().addHighlight("sherpaBold").addContent(T_sherpa_journal);
              sherpaList.addItem(journ.getTitle() + " (" + journ.getIssn() + ")");

              sherpaList.addItem().addHighlight("sherpaBold").addContent(T_sherpa_publisher);
              sherpaList.addItemXref(pub.getHomeurl(), pub.getName());

              sherpaList.addItem().addHighlight("sherpaBold").addContent(T_sherpa_colour);
              sherpaList
                  .addItem()
                  .addHighlight("sherpaStyle " + pub.getRomeocolour())
                  .addContent(message("xmlui.aspect.sherpa.submission." + pub.getRomeocolour()));
              sherpaList
                  .addItem()
                  .addXref(
                      "http://www.sherpa.ac.uk/romeo/search.php?issn=" + journ.getIssn(),
                      T_sherpa_more,
                      "sherpaMoreInfo");

              i = i + 1;
            }
          }
        }

        List sherpaList = div.addList("sherpaListEnd", "simple", "sherpaList");
        sherpaList.addItem(T_sherpa_consult);
      }
    }
  }
  /**
   * Makes the jump-list navigation for the results
   *
   * @param div
   * @param info
   * @param params
   * @throws WingException
   */
  private void addBrowseJumpNavigation(Division div, BrowseInfo info, BrowseParams params)
      throws WingException {
    // Get the name of the index
    String type = info.getBrowseIndex().getName();

    // Prepare a Map of query parameters required for all links
    Map<String, String> queryParams = new HashMap<String, String>();
    queryParams.putAll(params.getCommonParameters());
    queryParams.putAll(params.getControlParameters());

    // Navigation aid (really this is a poor version of pagination)
    Division jump =
        div.addInteractiveDivision(
            "browse-navigation", BROWSE_URL_BASE, Division.METHOD_POST, "secondary navigation");

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

    // If this is a date based browse, render the date navigation
    if (isSortedByDate(info)) {
      Para jumpForm = jump.addPara();

      // Create a select list to choose a month
      jumpForm.addContent(T_jump_select);
      Select month = jumpForm.addSelect(BrowseParams.MONTH);
      month.addOption(false, "-1", T_choose_month);
      for (int i = 1; i <= 12; i++) {
        month.addOption(false, String.valueOf(i), DCDate.getMonthName(i, Locale.getDefault()));
      }

      // Create a select list to choose a year
      Select year = jumpForm.addSelect(BrowseParams.YEAR);
      year.addOption(false, "-1", T_choose_year);
      int currentYear = DCDate.getCurrent().getYear();
      int i = currentYear;

      // Calculate where to move from 1, 5 to 10 year jumps
      int oneYearBreak = ((currentYear - ONE_YEAR_LIMIT) / 5) * 5;
      int fiveYearBreak = ((currentYear - FIVE_YEAR_LIMIT) / 10) * 10;
      int tenYearBreak = (currentYear - TEN_YEAR_LIMIT);
      do {
        year.addOption(false, String.valueOf(i), String.valueOf(i));

        if (i <= fiveYearBreak) i -= 10;
        else if (i <= oneYearBreak) i -= 5;
        else i--;
      } while (i > tenYearBreak);

      // Create a free text entry box for the year
      jumpForm = jump.addPara();
      jumpForm.addContent(T_jump_year);
      jumpForm.addText("start_with").setHelp(T_jump_year_help);

      jumpForm.addButton("submit").setValue(T_go);
    } else {
      // Create a clickable list of the alphabet
      List jumpList = jump.addList("jump-list", List.TYPE_SIMPLE, "alphabet");
      for (char c = 'A'; c <= 'Z'; c++) {
        Map<String, String> cQuery = new HashMap<String, String>(queryParams);
        cQuery.put(BrowseParams.STARTS_WITH, Character.toString(c));
        jumpList.addItemXref(super.generateURL(BROWSE_URL_BASE, cQuery), Character.toString(c));
      }

      // Create a free text field for the initial characters
      Para jumpForm = jump.addPara();
      jumpForm.addContent(T_starts_with);
      jumpForm.addText(BrowseParams.STARTS_WITH).setHelp(T_starts_with_help);

      jumpForm.addButton("submit").setValue(T_go);
    }
  }
  /** Display a single collection */
  public void addBody(Body body)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
    if (!(dso instanceof Collection)) return;

    // Set up the major variables
    Collection collection = (Collection) dso;

    // Build the collection viewer division.
    Division home = body.addDivision("collection-home", "primary repository collection");
    home.setHead(collection.getMetadata("name"));

    // The search / browse box.
    {
      Division search = home.addDivision("collection-search-browse", "secondary search-browse");

      // Search query
      Division query =
          search.addInteractiveDivision(
              "collection-search",
              contextPath + "/handle/" + collection.getHandle() + "/search",
              Division.METHOD_POST,
              "secondary search");

      Para para = query.addPara("search-query", null);
      para.addContent(T_full_text_search);
      para.addContent(" ");
      para.addText("query");
      para.addContent(" ");
      para.addButton("submit").setValue(T_go);

      // Browse by list
      Division browseDiv = search.addDivision("collection-browse", "secondary browse");
      List browse = browseDiv.addList("collection-browse", List.TYPE_SIMPLE, "collection-browse");
      browse.setHead(T_head_browse);
      String url = contextPath + "/handle/" + collection.getHandle();
      browse.addItemXref(url + "/browse-title", T_browse_titles);
      browse.addItemXref(url + "/browse-author", T_browse_authors);
      browse.addItemXref(url + "/browse-date", T_browse_dates);
    }

    // Add the refrence
    {
      Division viewer = home.addDivision("collection-view", "secondary");
      ReferenceSet mainInclude =
          viewer.addReferenceSet("collection-view", ReferenceSet.TYPE_DETAIL_VIEW);
      mainInclude.addReference(collection);
    }

    // Reciently submitted items
    {
      java.util.List<BrowseItem> items = getRecientlySubmittedIems(collection);

      Division lastSubmittedDiv =
          home.addDivision("collection-recent-submission", "secondary recent-submission");
      lastSubmittedDiv.setHead(T_head_recent_submissions);
      ReferenceSet lastSubmitted =
          lastSubmittedDiv.addReferenceSet(
              "collection-last-submitted",
              ReferenceSet.TYPE_SUMMARY_LIST,
              null,
              "recent-submissions");
      for (BrowseItem item : items) {
        lastSubmitted.addReference(item);
      }
    }
  }