Esempio n. 1
0
  /** Add the notice div to the body. */
  public void addBody(Body body) throws WingException, SQLException, AuthorizeException {
    String outcome = parameters.getParameter("outcome", null);
    String header = parameters.getParameter("header", null);
    String message = parameters.getParameter("message", null);
    String characters = parameters.getParameter("characters", null);

    if ((message == null || message.length() <= 0)
        && (characters == null || characters.length() <= 0)) {
      throw new WingException("No message found.");
    }

    String rend = "notice";
    if ("neutral".equals(outcome)) {
      rend += " neutral";
    } else if ("success".equals(outcome)) {
      rend += " success";
    } else if ("failure".equals(outcome)) {
      rend += " failure";
    }

    Division div = body.addDivision("general-message", rend);
    if ((header != null) && (!"".equals(header))) {
      div.setHead(message(header));
    } else {
      div.setHead(T_head);
    }

    if (message != null && message.length() > 0) {
      div.addPara(message(message));
    }

    if (characters != null && characters.length() > 0) {
      div.addPara(characters);
    }
  }
Esempio n. 2
0
  public void addBody(Body body) throws WingException {
    Division cannot = body.addDivision("register-cannot", "primary");

    cannot.setHead(T_head);

    EPersonUtils.registrationProgressList(cannot, 0);

    cannot.addPara(T_para1);
  }
Esempio n. 3
0
  /** Display the login form. */
  public void addBody(Body body) throws SQLException, SAXException, WingException {
    // Check if the user has previously attempted to login.
    Request request = ObjectModelHelper.getRequest(objectModel);
    HttpSession session = request.getSession();
    String previousUserName = request.getParameter("username");

    // Get any message parameters
    String header = (String) session.getAttribute(AuthenticationUtil.REQUEST_INTERRUPTED_HEADER);
    String message = (String) session.getAttribute(AuthenticationUtil.REQUEST_INTERRUPTED_MESSAGE);
    String characters =
        (String) session.getAttribute(AuthenticationUtil.REQUEST_INTERRUPTED_CHARACTERS);

    if (header != null || message != null || characters != null) {
      Division reason = body.addDivision("login-reason");

      if (header != null) {
        reason.setHead(message(header));
      } else {
        // Always have a head.
        reason.setHead("Authentication Required");
      }

      if (message != null) {
        reason.addPara(message(message));
      }

      if (characters != null) {
        reason.addPara(characters);
      }
    }

    Division login =
        body.addInteractiveDivision(
            "login", contextPath + "/ldap-login", Division.METHOD_POST, "primary");
    login.setHead(T_head1);

    List list = login.addList("ldap-login", List.TYPE_FORM);

    Text email = list.addItem().addText("username");
    email.setRequired();
    email.setAutofocus("autofocus");
    email.setLabel(T_userName);
    if (previousUserName != null) {
      email.setValue(previousUserName);
      email.addError(T_error_bad_login);
    }

    Item item = list.addItem();
    Password password = item.addPassword("ldap_password");
    password.setRequired();
    password.setLabel(T_password);

    list.addLabel();
    Item submit = list.addItem("login-in", null);
    submit.addButton("submit").setValue(T_submit);
  }
Esempio n. 4
0
  public void addBody(Body body)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    Request request = ObjectModelHelper.getRequest(objectModel);
    boolean help = false, error = false;
    if (request.getParameter("help") != null) {
      help = true;
    }
    if (request.getParameter("error") != null) {
      error = true;
    }

    Division div = body.addInteractiveDivision("test", "", "post", "primary");
    div.setHead("Inline form test");
    div.addPara(
        "There are two options you can use to control how this page is generated. First is the help parameter, if this is present then help text will be provided for all fields. Next is the error parameter, if it is provided then all fields will be generated in error conditions.");

    if (help) {
      div.addPara().addXref(makeURL(false, error), "Turn help OFF");
    } else {
      div.addPara().addXref(makeURL(true, error), "Turn help ON");
    }

    if (error) {
      div.addPara().addXref(makeURL(help, false), "Turn errors OFF");
    } else {
      div.addPara().addXref(makeURL(help, true), "Turn errors ON");
    }

    Division suited = body.addDivision("suited");
    suited.setHead("Fields suited towards being used inline");

    suited.addPara(
        "Below are a list of embedded fields that are normally considered usefully in an inline context.");

    // Text field
    Para p = suited.addPara();
    p.addContent("This is a plain 'Text' field, ");
    Text text = p.addText("text");
    text.setLabel("Text");
    if (help) {
      text.setHelp("This is helpfull text.");
    }
    if (error) {
      text.addError("This field is in error.");
    }
    text.setValue("Current raw value");
    p.addContent(", embedded in a paragraph.");

    // Single Checkbox field
    p = suited.addPara();
    p.addContent("This is a singe 'CheckBox' field, ");
    CheckBox checkBox = p.addCheckBox("yes-or-no");
    if (help) {
      checkBox.setHelp("Select either yes or no.");
    }
    if (error) {
      checkBox.addError("You are incorrect, try again.");
    }
    checkBox.setLabel("Yes or no");
    checkBox.addOption("yes");
    p.addContent(", embedded in a paragraph.");

    // File
    p = suited.addPara();
    p.addContent("This is a 'File' field, ");
    File file = p.addFile("file");
    file.setLabel("File");
    if (help) {
      file.setHelp("Upload a file.");
    }
    if (error) {
      file.addError("This field is in error.");
    }
    p.addContent(", embedded in a paragraph.");

    // Select (single)
    p = suited.addPara();
    p.addContent("This is single 'Select' (aka dropdown) field, ");
    Select select = p.addSelect("select");
    select.setLabel("Select (single)");
    if (help) {
      select.setHelp("Select one of the options");
    }
    if (error) {
      select.addError("This field is in error.");
    }
    select.addOption("one", "uno");
    select.addOption("two", "dos");
    select.addOption("three", "tres");
    select.addOption("four", "cuatro");
    select.addOption("five", "cinco");
    select.setOptionSelected("one");
    p.addContent(", embedded in a paragraph.");

    // Button
    p = suited.addPara();
    p.addContent("This is a 'Button' field, ");
    Button button = p.addButton("button");
    button.setLabel("Button");
    button.setValue("When you touch me I do things, lots of things");
    if (help) {
      button.setHelp("Submit buttons allow the user to submit the form.");
    }
    if (error) {
      button.addError("This button is in error.");
    }
    p.addContent(", embedded in a paragraph.");

    Division unsuited = body.addDivision("unsuited");
    unsuited.setHead("Fields typicaly unsuited towards being used inline");

    unsuited.addPara(
        "Below are a list of embedded fields that are normally considered useless in an inline context. This is because there widgets normally cross multiple lines making them hard to render inline. However these are all legal, but perhaps not advisable, and in some circumstances may be needed.");

    // Text Area Field
    p = unsuited.addPara();
    p.addContent("This is a 'Text Area' field, ");
    TextArea textArea = p.addTextArea("textarea");
    textArea.setLabel("Text Area");
    if (help) {
      textArea.setHelp("This is helpfull text.");
    }
    if (error) {
      textArea.addError("This field is in error.");
    }
    textArea.setValue("This is the raw value");
    p.addContent(", embedded in a paragraph.");

    // Multi-option Checkbox field
    p = unsuited.addPara();
    p.addContent("This is a multi-option 'CheckBox' field, ");
    checkBox = p.addCheckBox("fruit");
    if (help) {
      checkBox.setHelp("Select all the fruits that you like to eat");
    }
    if (error) {
      checkBox.addError("You are incorrect you actualy do like Tootse Rolls.");
    }
    checkBox.setLabel("fruits");
    checkBox.addOption("apple", "Apples");
    checkBox.addOption(true, "orange", "Oranges");
    checkBox.addOption("pear", "Pears");
    checkBox.addOption("tootsie", "Tootsie Roll");
    checkBox.addOption(true, "cherry", "Cherry");
    p.addContent(", embedded in a paragraph.");

    // multi-option Radio field
    p = unsuited.addPara();
    p.addContent("This is a multi-option 'Radio' field, ");
    Radio radio = p.addRadio("sex");
    radio.setLabel("Football colors");
    if (help) {
      radio.setHelp("Select the colors of the best (college) football team.");
    }
    if (error) {
      radio.addError("Error, Maroon & White is the only acceptable answer.");
    }
    radio.addOption("ut", "Burnt Orange & White");
    radio.addOption(true, "tamu", "Maroon & White");
    radio.addOption("ttu", "Tech Red & Black");
    radio.addOption("baylor", "Green & Gold");
    radio.addOption("rice", "Blue & Gray");
    radio.addOption("uh", "Scarlet Red & Albino White");
    p.addContent(", embedded in a paragraph.");

    // Select (multiple)
    p = unsuited.addPara();
    p.addContent("This is multiple 'Select' field, ");
    select = p.addSelect("multi-select");
    select.setLabel("Select (multiple)");
    select.setMultiple();
    select.setSize(4);
    if (help) {
      select.setHelp("Select one or more options");
    }
    if (error) {
      select.addError("This field is in error.");
    }
    select.addOption("one", "uno");
    select.addOption("two", "dos");
    select.addOption("three", "tres");
    select.addOption("four", "cuatro");
    select.addOption("five", "cinco");
    select.setOptionSelected("one");
    select.setOptionSelected("three");
    select.setOptionSelected("five");
    p.addContent(", embedded in a paragraph.");

    // Composite
    p = unsuited.addPara();
    p.addContent("This is a 'Composite' field of two text fields, ");
    Composite composite = p.addComposite("composite-2text");
    composite.setLabel("Composite (two text fields)");
    if (help) {
      composite.setHelp("I am the help for the entire composite");
    }
    if (error) {
      composite.addError("Just the composite is in error");
    }
    text = composite.addText("partA");
    text.setLabel("Part A");
    text.setValue("Value for part A");
    if (help) {
      text.setHelp("Part A");
    }
    text = composite.addText("partB");
    text.setLabel("Part B");
    text.setValue("Value for part B");
    if (help) {
      text.setHelp("Part B");
    }
    p.addContent(", embedded in a paragraph.");
  }
Esempio n. 5
0
  @Override
  public void addBody(Body body)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {

    Request request = ObjectModelHelper.getRequest(objectModel);

    DSpaceObject dso = HandleUtil.obtainHandle(objectModel);

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

    // Build the collection viewer division.

    // Make sure we get our results
    queryResults = getQueryResponse(dso);
    if (this.queryResults != null) {

      Map<String, List<DiscoverResult.FacetResult>> facetFields =
          this.queryResults.getFacetResults();
      if (facetFields == null) {
        facetFields = new LinkedHashMap<String, List<DiscoverResult.FacetResult>>();
      }

      //            facetFields.addAll(this.queryResults.getFacetDates());

      if (facetFields.size() > 0) {
        String facetField =
            String.valueOf(facetFields.keySet().toArray(new String[facetFields.size()])[0]);
        java.util.List<DiscoverResult.FacetResult> values = facetFields.get(facetField);

        if (values != null && 0 < values.size()) {

          Division results = body.addDivision("browse-by-" + facetField + "-results", "primary");

          results.setHead(
              message(
                  "xmlui.ArtifactBrowser.AbstractSearch.type_"
                      + request.getParameter(FACET_FIELD)
                      + "_browse"));

          // Find our faceting offset
          int offSet = queryArgs.getFacetOffset();
          if (offSet == -1) {
            offSet = 0;
          }

          // Only show the nextpageurl if we have at least one result following our current results
          String nextPageUrl = null;
          if (values.size() == (DEFAULT_PAGE_SIZE + 1)) {
            nextPageUrl = getNextPageURL(request);
          }

          results.setSimplePagination(
              (int) queryResults.getDspaceObjects().size(),
              offSet + 1,
              (offSet + (values.size() - 1)),
              getPreviousPageURL(request),
              nextPageUrl);

          Table singleTable =
              results.addTable(
                  "browse-by-" + facetField + "-results",
                  (int) (queryResults.getDspaceObjects().size() + 1),
                  1);

          List<String> filterQueries = new ArrayList<String>();
          if (request.getParameterValues("fq") != null) {
            filterQueries = Arrays.asList(request.getParameterValues("fq"));
          }
          for (int i = 0; i < values.size(); i++) {
            DiscoverResult.FacetResult value = values.get(i);

            String displayedValue = value.getDisplayedValue();
            String filterQuery = value.getAsFilterQuery();

            //                        if(field.getGap() != null){
            //                            //We have a date get the year so we can display it
            //                            DateFormat simpleDateformat = new
            // SimpleDateFormat("yyyy");
            //                            displayedValue =
            // simpleDateformat.format(SolrServiceImpl.toDate(displayedValue));
            //                            filterQuery =
            // ClientUtils.escapeQueryChars(value.getFacetField().getName()) + ":" + displayedValue
            // + "*";
            //                        }

            Cell cell = singleTable.addRow().addCell();

            // No use in selecting the same filter twice
            if (filterQueries.contains(filterQuery)) {
              cell.addContent(displayedValue + " (" + value.getCount() + ")");
            } else {
              cell.addXref(
                  contextPath
                      + (dso == null ? "" : "/handle/" + dso.getHandle())
                      + "/discover?"
                      + "&fq="
                      + URLEncoder.encode(filterQuery, "UTF-8")
                      + (request.getQueryString() != null ? "&" + request.getQueryString() : ""),
                  displayedValue + " (" + value.getCount() + ")");
            }
          }
        }
      }
    }

    // DSpaceObject dso = HandleUtil.obtainHandle(objectModel);

    /*
    if (dso != null)
    {
        if (dso instanceof Collection)
        {
            browseContext.addItem().addXref(contextPath + "/discovery/?q=search.resourcetype%3A2+AND+location%3Al" + dso.getID(), T_head_this_collection );
        }
        if (dso instanceof Community)
        {
            browseContext.addItem().addXref(contextPath + "/discovery/?q=search.resourcetype%3A2+AND+location%3Am" + dso.getID(), T_head_this_community );
        }
    }

    browseGlobal.addItem().addXref(contextPath + "/discovery/?q=search.resourcetype%3A2", T_head_all_of_dspace );
    */
  }
  /** Add the browse-title division. */
  public void addBody(Body body)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    BrowseParams params = getUserParams();
    BrowseInfo info = getBrowseInfo();

    String type = info.getBrowseIndex().getName();

    // Build the DRI Body
    Division div = body.addDivision("browse-by-" + type, "primary");

    div.setHead(getTitleMessage(info));

    // Build the internal navigation (jump lists)
    addBrowseJumpNavigation(div, info, params);

    // Build the sort and display controls
    addBrowseControls(div, info, params);

    // This div will hold the browsing results
    Division results = div.addDivision("browse-by-" + type + "-results", "primary");

    // Add the pagination
    results.setSimplePagination(
        info.getTotal(),
        browseInfo.getOverallPosition() + 1,
        browseInfo.getOverallPosition() + browseInfo.getResultCount(),
        getPreviousPageURL(params, info),
        getNextPageURL(params, info));

    // Reference all the browsed items
    ReferenceSet referenceSet =
        results.addReferenceSet("browse-by-" + type, ReferenceSet.TYPE_SUMMARY_LIST, type, null);

    // Are we browsing items, or unique metadata?
    if (isItemBrowse(info)) {
      // Add the items to the browse results
      for (BrowseItem item : (java.util.List<BrowseItem>) info.getResults()) {
        referenceSet.addReference(item);
      }
    } else // browsing a list of unique metadata entries
    {
      // Create a table for the results
      Table singleTable =
          results.addTable("browse-by-" + type + "-results", browseInfo.getResultCount() + 1, 1);

      // Add the column heading
      singleTable
          .addRow(Row.ROLE_HEADER)
          .addCell()
          .addContent(
              message("xmlui.ArtifactBrowser.ConfigurableBrowse." + type + ".column_heading"));

      // Iterate each result
      for (String singleEntry : browseInfo.getStringResults()) {
        // Create a Map of the query parameters for the link
        Map<String, String> queryParams = new HashMap<String, String>();
        queryParams.put(BrowseParams.TYPE, URLEncode(type));
        queryParams.put(BrowseParams.FILTER_VALUE, URLEncode(singleEntry));

        // Create an entry in the table, and a linked entry
        Cell cell = singleTable.addRow().addCell();
        cell.addXref(super.generateURL(BROWSE_URL_BASE, queryParams), singleEntry);
      }
    }
  }
  /** 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);
      }
    }
  }