示例#1
0
  public void addListPolicies(List parent, DSpaceObject dso, Collection owningCollection)
      throws WingException, SQLException {
    if (!isAdvancedFormEnabled) {
      return;
    }
    parent.addLabel(T_head_policies_table);

    java.util.List<ResourcePolicy> resourcePolicies =
        authorizeService.findPoliciesByDSOAndType(context, dso, ResourcePolicy.TYPE_CUSTOM);
    if (resourcePolicies.isEmpty()) {
      parent.addItem(T_no_policies);
      return;
    }

    for (ResourcePolicy rp : resourcePolicies) {
      int id = rp.getID();

      String name = "";
      if (rp.getRpName() != null) name = rp.getRpName();

      String action = resourcePolicyService.getActionText(rp);

      // if it is the default policy for the Submitter don't show it.
      if (dso instanceof org.dspace.content.Item) {
        org.dspace.content.Item item = (org.dspace.content.Item) dso;
        if (rp.getEPerson() != null) {
          if (item.getSubmitter().equals(rp.getEPerson())) continue;
        }
      }

      String group = "";
      if (rp.getGroup() != null) group = rp.getGroup().getName();

      // start
      String startDate = "";
      if (rp.getStartDate() != null) {
        startDate = DateFormatUtils.format(rp.getStartDate(), "yyyy-MM-dd");
      }

      // endDate
      String endDate = "";
      if (rp.getEndDate() != null) {
        endDate = DateFormatUtils.format(rp.getEndDate(), "yyyy-MM-dd");
      }

      parent.addItem(T_policy.parameterize(name, action, group, startDate, endDate));
    }
  }
示例#2
0
  public void addRioxxVersionSection(List upload, Item item) throws WingException {
    String version = item.getMetadata("rioxxterms.version");

    if (StringUtils.isNotBlank(version) && !"NA".equals(version)) {
      try {
        DCInputsReader a = new DCInputsReader();
        java.util.List<String> pairs = a.getPairs("rioxxterms_version");
        int humanReadable = pairs.indexOf(version) - 1;
        version = pairs.get(humanReadable);
      } catch (DCInputsReaderException e) {
        log.error(e.getMessage(), e);
      }
      upload
          .addItem("upload-rioxx-version-warning", "upload-rioxx-version-warning")
          .addContent(T_rioxx_version.parameterize(version));
    }
  }
示例#3
0
  public void addListGroups(String groupID, List form, int errorFlag, Collection owningCollection)
      throws WingException, SQLException {

    if (isAdvancedFormEnabled) {
      // currently set group
      form.addLabel(T_groups);
      Select groupSelect = form.addItem().addSelect("group_id");
      groupSelect.setMultiple(false);

      java.util.List<Group> loadedGroups = null;

      // retrieve groups
      String name = ConfigurationManager.getProperty("webui.submission.restrictstep.groups");
      if (name != null) {
        Group uiGroup = groupService.findByName(context, name);
        if (uiGroup != null) loadedGroups = uiGroup.getMemberGroups();
      }
      if (loadedGroups == null || loadedGroups.size() == 0) {
        loadedGroups = groupService.findAll(context, GroupService.NAME);
      }

      // if no group selected for default set anonymous
      if (groupID == null || groupID.equals("")) groupID = "0";
      // when we're just loading the main step, also default to anonymous
      if (errorFlag == AccessStep.STATUS_COMPLETE) {
        groupID = "0";
      }
      for (Group group : loadedGroups) {
        boolean selectGroup = group.getID().toString().equals(groupID);
        groupSelect.addOption(selectGroup, group.getID().toString(), group.getName());
      }

      if (errorFlag == AccessStep.STATUS_DUPLICATED_POLICY
          || errorFlag == AccessStep.EDIT_POLICY_STATUS_DUPLICATED_POLICY
          || errorFlag == UploadWithEmbargoStep.STATUS_EDIT_POLICIES_DUPLICATED_POLICY
          || errorFlag == UploadWithEmbargoStep.STATUS_EDIT_POLICY_DUPLICATED_POLICY) {
        groupSelect.addError(T_error_duplicated_policy);
      }
    }
  }
示例#4
0
  public void addEmbargoDateSimpleForm(DSpaceObject dso, List form, int errorFlag)
      throws SQLException, WingException {

    String date = null;

    if (dso != null) {
      java.util.List<ResourcePolicy> policies =
          authorizeService.findPoliciesByDSOAndType(context, dso, ResourcePolicy.TYPE_CUSTOM);
      if (policies.size() > 0) {
        ResourcePolicy rp = policies.get(0);
        if (rp.getStartDate() != null) {
          date = DateFormatUtils.format(rp.getStartDate(), "yyyy-MM-dd");
        }
        globalReason = rp.getRpDescription();
      }
    }
    //        CheckBox privateCheckbox = form.addItem().addCheckBox("emabrgo_option");
    //        privateCheckbox.setLabel(T_item_embargoed);
    //        if(date!=null){
    //            privateCheckbox.addOption(true, CB_EMBARGOED, "");
    //        }
    //        else{
    //            privateCheckbox.addOption(false, CB_EMBARGOED, "");
    //        }

    // Date
    Text startDate = form.addItem().addText("embargo_until_date");
    startDate.setLabel(T_item_embargoed);
    if (errorFlag == org.dspace.submit.step.AccessStep.STATUS_ERROR_FORMAT_DATE) {
      startDate.addError(T_error_date_format);
    } else if (errorFlag == org.dspace.submit.step.AccessStep.STATUS_ERROR_MISSING_DATE) {
      startDate.addError(T_error_missing_date);
    }

    if (date != null) {
      startDate.setValue(date);
    }
    startDate.setHelp(T_label_date_help);
  }
示例#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 );
    */
  }
示例#6
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);
      }
    }
  }
示例#7
0
  public void addTablePolicies(Division parent, DSpaceObject dso, Collection owningCollection)
      throws WingException, SQLException {
    if (!isAdvancedFormEnabled) {
      return;
    }
    Division div = parent.addDivision("access-existing-policies");
    div.setHead(T_head_policies_table);
    div.addPara(T_policies_help.parameterize(owningCollection));

    java.util.List<ResourcePolicy> resourcePolicies =
        authorizeService.findPoliciesByDSOAndType(context, dso, ResourcePolicy.TYPE_CUSTOM);

    if (resourcePolicies.isEmpty()) {
      div.addPara(T_no_policies);
      return;
    }

    int cols = resourcePolicies.size();
    if (cols == 0) cols = 1;
    Table policies = div.addTable("policies", 6, cols);
    Row header = policies.addRow(Row.ROLE_HEADER);

    header.addCellContent(T_column0); // name
    header.addCellContent(T_column1); // action
    header.addCellContent(T_column2); // group
    header.addCellContent(T_column3); // start_date
    header.addCellContent(T_column4); // end_date

    for (ResourcePolicy rp : resourcePolicies) {
      int id = rp.getID();

      String name = "";
      if (rp.getRpName() != null) name = rp.getRpName();

      String action = resourcePolicyService.getActionText(rp);

      // if it is the default policy for the Submitter don't show it.
      if (dso instanceof org.dspace.content.Item) {
        org.dspace.content.Item item = (org.dspace.content.Item) dso;
        if (rp.getEPerson() != null) {
          if (item.getSubmitter().equals(rp.getEPerson())) continue;
        }
      }

      String group = "";
      if (rp.getGroup() != null) group = rp.getGroup().getName();

      Row row = policies.addRow();

      row.addCellContent(name);
      row.addCellContent(action);
      row.addCellContent(group);

      // start
      String startDate = "";
      if (rp.getStartDate() != null) {
        startDate = DateFormatUtils.format(rp.getStartDate(), "yyyy-MM-dd");
      }
      row.addCellContent(startDate);

      // endDate
      String endDate = "";
      if (rp.getEndDate() != null) {
        endDate = DateFormatUtils.format(rp.getEndDate(), "yyyy-MM-dd");
      }
      row.addCellContent(endDate);

      Button edit = row.addCell().addButton("submit_edit_edit_policies_" + id);
      edit.setValue(T_table_submit_edit);

      Button delete = row.addCell().addButton("submit_delete_edit_policies_" + id);
      delete.setValue(T_table_submit_delete);
    }
  }