/** Test of setShortDescription method, of class BitstreamFormat. */
  @Test
  public void testSetShortDescription() throws SQLException {
    String desc = "short";
    bf.setShortDescription(desc);

    assertThat("testSetShortDescription 0", bf.getShortDescription(), notNullValue());
    assertThat("testSetShortDescription 1", bf.getShortDescription(), not(equalTo("")));
    assertThat("testSetShortDescription 2", bf.getShortDescription(), equalTo(desc));
  }
  /** Test of find method, of class BitstreamFormat. */
  @Test
  public void testFind() throws SQLException {
    BitstreamFormat found = BitstreamFormat.find(context, 1);
    assertThat("testFind 0", found, notNullValue());
    assertThat("testFind 1", found.getShortDescription(), equalTo("Unknown"));

    found = BitstreamFormat.find(context, 2);
    assertThat("testFind 2", found, notNullValue());
    assertThat("testFind 3", found.getShortDescription(), equalTo("License"));
    assertTrue("testFind 4", found.isInternal());
  }
  /** Test of findByShortDescription method, of class BitstreamFormat. */
  @Test
  public void testFindByShortDescription() throws SQLException {
    BitstreamFormat found = BitstreamFormat.findByShortDescription(context, "Adobe PDF");
    assertThat("testFindByShortDescription 0", found, notNullValue());
    assertThat("testFindByShortDescription 1", found.getShortDescription(), equalTo("Adobe PDF"));
    assertFalse("testFindByShortDescription 2", found.isInternal());

    found = BitstreamFormat.findByShortDescription(context, "XML");
    assertThat("testFindByShortDescription 3", found, notNullValue());
    assertThat("testFindByShortDescription 4", found.getShortDescription(), equalTo("XML"));
    assertFalse("testFindByShortDescription 5", found.isInternal());
  }
 /** Test of findUnknown method, of class BitstreamFormat. */
 @Test
 public void testFindUnknown() throws SQLException {
   BitstreamFormat found = BitstreamFormat.findUnknown(context);
   assertThat("testFindUnknown 0", found, notNullValue());
   assertThat("testFindUnknown 1", found.getShortDescription(), equalTo("Unknown"));
   assertFalse("testFindUnknown 2", found.isInternal());
   assertThat("testFindUnknown 3", found.getSupportLevel(), equalTo(0));
 }
  /** Test of findNonInternal method, of class BitstreamFormat. */
  @Test
  public void testFindNonInternal() throws SQLException {

    BitstreamFormat[] found = BitstreamFormat.findNonInternal(context);
    assertThat("testFindNonInternal 0", found, notNullValue());
    int i = 0;
    for (BitstreamFormat b : found) {
      i++;
      assertFalse(
          "testFindNonInternal " + i + " (" + b.getShortDescription() + ")", b.isInternal());
    }
  }
  public void addBody(Body body) throws WingException, SQLException, AuthorizeException {
    // Get all our parameters
    String idsString = parameters.getParameter("formatIDs", null);

    ArrayList<BitstreamFormat> formats = new ArrayList<BitstreamFormat>();
    for (String id : idsString.split(",")) {
      BitstreamFormat format = BitstreamFormat.find(context, Integer.valueOf(id));
      formats.add(format);
    }

    // DIVISION: bitstream-format-confirm-delete
    Division deleted =
        body.addInteractiveDivision(
            "bitstream-format-confirm-delete",
            contextPath + "/admin/format-registry",
            Division.METHOD_POST,
            "primary administrative format-registry");
    deleted.setHead(T_head);
    deleted.addPara(T_para1);

    Table table = deleted.addTable("format-confirm-delete", formats.size() + 1, 3);
    Row header = table.addRow(Row.ROLE_HEADER);
    header.addCell().addContent(T_column1);
    header.addCell().addContent(T_column2);
    header.addCell().addContent(T_column3);

    for (BitstreamFormat format : formats) {
      if (format == null) {
        continue;
      }

      String formatID = String.valueOf(format.getID());
      String mimetype = format.getMIMEType();
      String name = format.getShortDescription();

      Row row = table.addRow();
      row.addCell().addContent(formatID);
      row.addCell().addContent(mimetype);
      row.addCell().addContent(name);
    }
    Para buttons = deleted.addPara();
    buttons.addButton("submit_confirm").setValue(T_submit_delete);
    buttons.addButton("submit_cancel").setValue(T_submit_cancel);

    deleted.addHidden("administrative-continue").setValue(knot.getId());
  }
Example #7
0
  /**
   * Each submission step must define its own information to be reviewed during the final
   * Review/Verify Step in the submission process.
   *
   * <p>The information to review should be tacked onto the passed in List object.
   *
   * <p>NOTE: To remain consistent across all Steps, you should first add a sub-List object (with
   * this step's name as the heading), by using a call to reviewList.addList(). This sublist is the
   * list you return from this method!
   *
   * @param reviewList The List to which all reviewable information should be added
   * @return The new sub-List object created by this step, which contains all the reviewable
   *     information. If this step has nothing to review, then return null!
   */
  public List addReviewSection(List reviewList)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    // Create a new list section for this step (and set its heading)
    List uploadSection = reviewList.addList("submit-review-" + this.stepAndPage, List.TYPE_FORM);
    uploadSection.setHead(T_head);

    // Review all uploaded files
    Item item = submission.getItem();
    Bundle[] bundles = item.getBundles("ORIGINAL");
    Bitstream[] bitstreams = new Bitstream[0];
    if (bundles.length > 0) {
      bitstreams = bundles[0].getBitstreams();
    }

    for (Bitstream bitstream : bitstreams) {
      BitstreamFormat bitstreamFormat = bitstream.getFormat();

      String name = bitstream.getName();
      String url = makeBitstreamLink(item, bitstream);
      String format = bitstreamFormat.getShortDescription();
      Message support = ReviewStep.T_unknown;
      if (bitstreamFormat.getSupportLevel() == BitstreamFormat.KNOWN) {
        support = T_known;
      } else if (bitstreamFormat.getSupportLevel() == BitstreamFormat.SUPPORTED) {
        support = T_supported;
      }

      org.dspace.app.xmlui.wing.element.Item file = uploadSection.addItem();
      file.addXref(url, name);
      file.addContent(" - " + format + " ");
      file.addContent(support);
    }

    // return this new "upload" section
    return uploadSection;
  }
  public void addBody(Body body) throws SQLException, WingException {
    // Get our parameters and state
    int itemID = parameters.getParameterAsInteger("itemID", -1);
    Item item = Item.find(context, itemID);
    String baseURL = contextPath + "/admin/item?administrative-continue=" + knot.getId();

    // DIVISION: main div
    Division main =
        body.addInteractiveDivision(
            "edit-item-status",
            contextPath + "/admin/item",
            Division.METHOD_POST,
            "primary administrative item");
    main.setHead(T_option_head);

    // LIST: options
    List options = main.addList("options", List.TYPE_SIMPLE, "horizontal");
    options.addItem().addXref(baseURL + "&submit_status", T_option_status);
    options
        .addItem()
        .addHighlight("bold")
        .addXref(baseURL + "&submit_bitstreams", T_option_bitstreams);
    options.addItem().addXref(baseURL + "&submit_metadata", T_option_metadata);
    options.addItem().addXref(baseURL + "&view_item", T_option_view);

    // TABLE: Bitstream summary
    Table files = main.addTable("editItemBitstreams", 1, 1);

    files.setHead(T_head1);

    Row header = files.addRow(Row.ROLE_HEADER);
    header.addCellContent(T_column1);
    header.addCellContent(T_column2);
    header.addCellContent(T_column3);
    header.addCellContent(T_column4);
    header.addCellContent(T_column5);

    Bundle[] bundles = item.getBundles();

    for (Bundle bundle : bundles) {

      Cell bundleCell = files.addRow().addCell(1, 5);
      bundleCell.addContent(T_bundle_label.parameterize(bundle.getName()));

      Bitstream[] bitstreams = bundle.getBitstreams();

      for (Bitstream bitstream : bitstreams) {
        boolean primary = (bundle.getPrimaryBitstreamID() == bitstream.getID());
        String name = bitstream.getName();

        if (name != null && name.length() > 50) {
          // If the fiel name is too long the shorten it so that it will display nicely.
          String shortName = name.substring(0, 15);
          shortName += " ... ";
          shortName += name.substring(name.length() - 25, name.length());
          name = shortName;
        }

        String description = bitstream.getDescription();
        String format = null;
        BitstreamFormat bitstreamFormat = bitstream.getFormat();
        if (bitstreamFormat != null) format = bitstreamFormat.getShortDescription();
        String editURL =
            contextPath
                + "/admin/item?administrative-continue="
                + knot.getId()
                + "&bitstreamID="
                + bitstream.getID()
                + "&submit_edit";
        String viewURL =
            contextPath + "/bitstream/id/" + bitstream.getID() + "/" + bitstream.getName();

        Row row = files.addRow();
        CheckBox remove = row.addCell().addCheckBox("remove");
        remove.setLabel("remove");
        remove.addOption(bundle.getID() + "/" + bitstream.getID());
        if (!AuthorizeManager.authorizeActionBoolean(context, item, Constants.REMOVE)) {
          remove.setDisabled();
        }

        if (AuthorizeManager.authorizeActionBoolean(context, bitstream, Constants.WRITE)) {
          // The user can edit the bitstream give them a link.
          Cell cell = row.addCell();
          cell.addXref(editURL, name);
          if (primary) cell.addXref(editURL, T_primary_label);

          row.addCell().addXref(editURL, description);
          row.addCell().addXref(editURL, format);
        } else {
          // The user can't edit the bitstream just show them it.
          Cell cell = row.addCell();
          cell.addContent(name);
          if (primary) cell.addContent(T_primary_label);

          row.addCell().addContent(description);
          row.addCell().addContent(format);
        }

        Highlight highlight = row.addCell().addHighlight("fade");
        highlight.addContent("[");
        highlight.addXref(viewURL, T_view_link);
        highlight.addContent("]");
      }
    }

    if (AuthorizeManager.authorizeActionBoolean(context, item, Constants.ADD)) {
      Cell cell = files.addRow().addCell(1, 5);
      cell.addXref(
          contextPath + "/admin/item?administrative-continue=" + knot.getId() + "&submit_add",
          T_submit_add);
    } else {
      Cell cell = files.addRow().addCell(1, 5);
      cell.addHighlight("fade").addContent(T_no_upload);
    }

    // PARA: actions
    Para actions = main.addPara("editItemActionsP", "editItemActionsP");
    if (AuthorizeManager.authorizeActionBoolean(context, item, Constants.REMOVE))
      actions.addButton("submit_delete").setValue(T_submit_delete);
    else {
      Button button = actions.addButton("submit_delete");
      button.setValue(T_submit_delete);
      button.setDisabled();

      main.addPara().addHighlight("fade").addContent(T_no_remove);
    }
    actions.addButton("submit_return").setValue(T_submit_return);

    main.addHidden("administrative-continue").setValue(knot.getId());
  }
 /** Test of getShortDescription method, of class BitstreamFormat. */
 @Test
 public void testGetShortDescription() {
   assertThat("getShortDescription 0", bf.getShortDescription(), notNullValue());
   assertThat("getShortDescription 1", bf.getShortDescription(), not(equalTo("")));
   assertThat("getShortDescription 2", bf.getShortDescription(), equalTo("XML"));
 }