// Part B:
// If the user has already uploaded files provide a list for the user.
if (bitstreams.length > 0 || disableFileEditing)
{
Table summary = div.addTable("submit-upload-summary",(bitstreams.length * 2) + 2,7);
summary.setHead(T_head2);
Row header = summary.addRow(Row.ROLE_HEADER);
header.addCellContent(T_column0); // primary bitstream
header.addCellContent(T_column1); // select checkbox
header.addCellContent(T_column2); // file name
header.addCellContent(T_column3); // size
header.addCellContent(T_column4); // description
header.addCellContent(T_column5); // format
header.addCellContent(T_column6); // edit button
for (Bitstream bitstream : bitstreams)
{
int id = bitstream.getID();
String name = bitstream.getName();
String url = makeBitstreamLink(item, bitstream);
long bytes = bitstream.getSize();
String desc = bitstream.getDescription();
String algorithm = bitstream.getChecksumAlgorithm();
String checksum = bitstream.getChecksum();
Row row = summary.addRow();
// Add radio-button to select this as the primary bitstream
Radio primary = row.addCell().addRadio("primary_bitstream_id");
primary.addOption(String.valueOf(id));
// If this bitstream is already marked as the primary bitstream
// mark it as such.
if(bundles[0].getPrimaryBitstreamID() == id) {
primary.setOptionSelected(String.valueOf(id));
}
if (!disableFileEditing)
{
// Workflow users can not remove files.
CheckBox remove = row.addCell().addCheckBox("remove");
remove.setLabel("remove");
remove.addOption(id);
}
else
{
row.addCell();
}
row.addCell().addXref(url,name);
row.addCellContent(bytes + " bytes");
if (desc == null || desc.length() == 0)
{
row.addCellContent(T_unknown_name);
}
else
{
row.addCellContent(desc);
}
BitstreamFormat format = bitstream.getFormat();
if (format == null)
{
row.addCellContent(T_unknown_format);
}
else
{
int support = format.getSupportLevel();
Cell cell = row.addCell();
cell.addContent(format.getMIMEType());
cell.addContent(" ");
switch (support)
{
case 1:
cell.addContent(T_supported);
break;
case 2:
cell.addContent(T_known);
break;
case 3:
cell.addContent(T_unsupported);
break;
}
}
Button edit = row.addCell().addButton("submit_edit_"+id);
edit.setValue(T_submit_edit);
Row checksumRow = summary.addRow();
checksumRow.addCell();
Cell checksumCell = checksumRow.addCell(null, null, 0, 6, null);
checksumCell.addHighlight("bold").addContent(T_checksum);
checksumCell.addContent(" ");
checksumCell.addContent(algorithm + ":" + checksum);
}
if (!disableFileEditing)
{
// Workflow users can not remove files.
Row actionRow = summary.addRow();
actionRow.addCell();
Button removeSeleceted = actionRow.addCell(null, null, 0, 6, null).addButton("submit_remove_selected");
removeSeleceted.setValue(T_submit_remove);
}