<%-- - edit-metadata.jsp - - Version: $Revision$ - - Date: $Date$ - - Copyright (c) 2002, Hewlett-Packard Company and Massachusetts - Institute of Technology. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Hewlett-Packard Company nor the name of the - Massachusetts Institute of Technology nor the names of their - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - DAMAGE. --%> <%-- - Edit metadata form - - Attributes to pass in to this page: - submission.info - the SubmissionInfo object - submission.inputs - the DCInputSet - submission.page - the step in submission --%> <%@ page contentType="text/html;charset=UTF-8" %> <%@ page import="java.util.HashMap" %> <%@ page import="java.util.Iterator" %> <%@ page import="java.util.List" %> <%@ page import="java.util.ArrayList" %> <%@ page import="java.util.Map" %> <%@ page import="java.net.URLEncoder" %> <%@ page import="javax.servlet.ServletException" %> <%@ page import="org.dspace.app.webui.jsptag.PopupTag" %> <%@ page import="org.dspace.app.webui.util.DCInput" %> <%@ page import="org.dspace.app.webui.util.DCInputSet" %> <%@ page import="org.dspace.app.webui.servlet.SubmitServlet" %> <%@ page import="org.dspace.app.webui.util.JSPManager" %> <%@ page import="org.dspace.app.webui.util.SubmissionInfo" %> <%@ page import="org.dspace.app.webui.util.UIUtil" %> <%@ page import="org.dspace.content.DCDate" %> <%@ page import="org.dspace.content.DCLanguage" %> <%@ page import="org.dspace.content.DCPersonName" %> <%@ page import="org.dspace.content.DCSeriesNumber" %> <%@ page import="org.dspace.content.DCValue" %> <%@ page import="org.dspace.content.Item" %> <%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %> <%@ page import="javax.servlet.jsp.tagext.TagSupport" %> <%@ page import="javax.servlet.jsp.PageContext" %> <%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <%! void doPersonalName(javax.servlet.jsp.JspWriter out, Item item, String fieldName, String element, String qualifier, boolean repeatable, int fieldCountIncr, String label, PageContext pageContext) throws java.io.IOException { DCValue[] defaults = item.getDC(element, qualifier, Item.ANY); int fieldCount = defaults.length + fieldCountIncr; StringBuffer headers = new StringBuffer(); StringBuffer sb = new StringBuffer(); org.dspace.content.DCPersonName dpn; StringBuffer name = new StringBuffer(); StringBuffer first = new StringBuffer(); StringBuffer last = new StringBuffer(); if (fieldCount == 0) fieldCount = 1; //Width hints used here to affect whole table headers.append(" ") .append("") // .append("Last name
e.g. Smith") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.lastname")) .append("") .append("") // .append("First name(s) + \"Jr\"
e.g. Donald Jr") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.firstname")) .append("") .append(" ") .append(""); out.write(headers.toString()); for (int i = 0; i < fieldCount; i++) { first.setLength(0); first.append(fieldName).append("_first"); if (repeatable) first.append('_').append(i); last.setLength(0); last.append(fieldName).append("_last"); if (repeatable) last.append('_').append(i); if (i == 0) sb.append("") .append(label) .append(""); else sb.append(" "); if (i < defaults.length) dpn = new org.dspace.content.DCPersonName(defaults[i].value); else dpn = new org.dspace.content.DCPersonName(); sb.append("\n\n"); if (repeatable && i < defaults.length) { name.setLength(0); name.append(dpn.getLastName()) .append(' ') .append(dpn.getFirstNames()); // put a remove button next to filled in values sb.append(" ") .append("\" value=\"") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.button.remove")) .append("\"/> "); } else if (repeatable && i == fieldCount - 1) { // put a 'more' button next to the last space sb.append(" "); .append("_more\" value=\"") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.button.add")) .append("\"/> "); } else { // put a blank if nothing else sb.append(" "); } } out.write(sb.toString()); } void doDate(javax.servlet.jsp.JspWriter out, Item item, String fieldName, String element, String qualifier, boolean repeatable, int fieldCountIncr, String label, PageContext pageContext) throws java.io.IOException { DCValue[] defaults = item.getDC(element, qualifier, Item.ANY); int fieldCount = defaults.length + fieldCountIncr; StringBuffer sb = new StringBuffer(); org.dspace.content.DCDate dateIssued; if (fieldCount == 0) fieldCount = 1; for (int i = 0; i < fieldCount; i++) { if (i == 0) sb.append("") .append(label) .append(""); else sb.append(" "); if (i < defaults.length) dateIssued = new org.dspace.content.DCDate(defaults[i].value); else dateIssued = new org.dspace.content.DCDate(""); sb.append("") // .append("Month:") // .append("Day: 0 ? String.valueOf(dateIssued.getDay()) : "" )) // .append("\"/>Year:") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.year")) .append(" 0 ? String.valueOf(dateIssued.getYear()) : "" )) .append("\"/>\n"); if (repeatable && i < defaults.length) { // put a remove button next to filled in values sb.append(" "); .append("\" value=\"") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.button.remove")) .append("\"> "); } else if (repeatable && i == fieldCount - 1) { // put a 'more' button next to the last space sb.append(" "); .append("_more\" value=\"") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.button.add")) .append("\"/> "); } else { // put a blank if nothing else sb.append(" "); } } out.write(sb.toString()); } void doSeriesNumber(javax.servlet.jsp.JspWriter out, Item item, String fieldName, String element, String qualifier, boolean repeatable, int fieldCountIncr, String label, PageContext pageContext) throws java.io.IOException { DCValue[] defaults = item.getDC(element, qualifier, Item.ANY); int fieldCount = defaults.length + fieldCountIncr; StringBuffer sb = new StringBuffer(); org.dspace.content.DCSeriesNumber sn; if (fieldCount == 0) fieldCount = 1; for (int i = 0; i < fieldCount; i++) { if (i == 0) sb.append("") .append(label) .append(""); else sb.append(" "); if (i < defaults.length) sn = new org.dspace.content.DCSeriesNumber(defaults[i].value); else sn = new org.dspace.content.DCSeriesNumber(); sb.append("\n\n"); if (repeatable && i < defaults.length) { // put a remove button next to filled in values sb.append(" "); .append("\" value=\"") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.button.remove")) .append("\"/> "); } else if (repeatable && i == fieldCount - 1) { // put a 'more' button next to the last space sb.append(" "); .append("_more\" value=\"") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.button.add")) .append("\"/> "); } else { // put a blank if nothing else sb.append(" "); } } out.write(sb.toString()); } void doTextArea(javax.servlet.jsp.JspWriter out, Item item, String fieldName, String element, String qualifier, boolean repeatable, int fieldCountIncr, String label, PageContext pageContext) throws java.io.IOException { DCValue[] defaults = item.getDC(element, qualifier, Item.ANY); int fieldCount = defaults.length + fieldCountIncr; StringBuffer sb = new StringBuffer(); String val; if (fieldCount == 0) fieldCount = 1; for (int i = 0; i < fieldCount; i++) { if (i == 0) sb.append("") .append(label) .append(""); else sb.append(" "); if (i < defaults.length) val = defaults[i].value; else val = ""; sb.append("\n"); if (repeatable && i < defaults.length) { // put a remove button next to filled in values sb.append(" "); .append("\" value=\"") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.button.remove")) .append("\"/> "); } else if (repeatable && i == fieldCount - 1) { // put a 'more' button next to the last space sb.append(" "); .append("_more\" value=\"") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.button.add")) .append("\"/> "); } else { // put a blank if nothing else sb.append(" "); } } out.write(sb.toString()); } void doOneBox(javax.servlet.jsp.JspWriter out, Item item, String fieldName, String element, String qualifier, boolean repeatable, int fieldCountIncr, String label, PageContext pageContext) throws java.io.IOException { DCValue[] defaults = item.getDC(element, qualifier, Item.ANY); int fieldCount = defaults.length + fieldCountIncr; StringBuffer sb = new StringBuffer(); String val; if (fieldCount == 0) fieldCount = 1; for (int i = 0; i < fieldCount; i++) { if (i == 0) sb.append("") .append(label) .append(""); else sb.append(" "); if (i < defaults.length) val = defaults[i].value.replaceAll("\"", """); else val = ""; sb.append("\n"); if (repeatable && i < defaults.length) { // put a remove button next to filled in values sb.append(" "); .append("\" value=\"") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.button.remove")) .append("\"/> "); } else if (repeatable && i == fieldCount - 1) { // put a 'more' button next to the last space sb.append(" "); .append("_more\" value=\"") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.button.add")) .append("\"/> "); } else { // put a blank if nothing else sb.append(" "); } } out.write(sb.toString()); } void doTwoBox(javax.servlet.jsp.JspWriter out, Item item, String fieldName, String element, String qualifier, boolean repeatable, int fieldCountIncr, String label, PageContext pageContext) throws java.io.IOException { DCValue[] defaults = item.getDC(element, qualifier, Item.ANY); int fieldCount = defaults.length + fieldCountIncr; StringBuffer sb = new StringBuffer(); StringBuffer headers = new StringBuffer(); if (element.equals("relation") && qualifier.equals("ispartofseries")) { //Width hints used here to affect whole table headers.append(" ") .append("") // .append("Series Name") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.seriesname")) .append("") .append("") // .append("Report or Paper No.") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.paperno")) .append("") .append(" ") .append(""); out.write(headers.toString()); } if (fieldCount == 0) fieldCount = 1; for (int i = 0; i < fieldCount; i++) { if (i == 0) sb.append("") .append(label) .append(""); else sb.append(" "); if (i < defaults.length) sb.append(" \n"); .append("\" value=\"") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.button.remove2")) .append("\"/>\n"); else { sb.append("\n"); } i++; if (i < defaults.length) sb.append(" \n"); .append("\" value=\"") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.button.remove2")) .append("\"/>\n"); else { sb.append(""); if (i+1 >= fieldCount) { sb.append("\n"); .append("_more\" value=\"") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.button.add")) .append("\"/>\n"); } else { sb.append(""); } sb.append(" "); } } out.write(sb.toString()); } void doQualdropValue(javax.servlet.jsp.JspWriter out, Item item, String fieldName, String element, DCInputSet inputs, boolean repeatable, int fieldCountIncr, List qualMap, String label, PageContext pageContext) throws java.io.IOException { DCValue[] unfiltered = item.getDC(element, Item.ANY, Item.ANY); // filter out both unqualified and qualified values occuring elsewhere in inputs ArrayList filtered = new ArrayList(); for (int i = 0; i < unfiltered.length; i++) { String unfilteredFieldName = unfiltered[i].element + "." + unfiltered[i].qualifier; if ( ! inputs.isFieldPresent(unfilteredFieldName) ) { filtered.add( unfiltered[i] ); } } DCValue[] defaults = (DCValue[])filtered.toArray(new DCValue[0]); //DCValue[] defaults = item.getDC(element, Item.ANY, Item.ANY); int fieldCount = defaults.length + fieldCountIncr; StringBuffer sb = new StringBuffer(); String q, v, currentQual, currentVal; if (fieldCount == 0) fieldCount = 1; for (int j = 0; j < fieldCount; j++) { if (j < defaults.length) { currentQual = defaults[j].qualifier; currentVal = defaults[j].value; } else { currentQual = ""; currentVal = ""; } if (j == 0) sb.append("") .append(label) .append(""); else sb.append(" "); // do the dropdown box sb.append(" \n"); if (repeatable && j < defaults.length) { // put a remove button next to filled in values sb.append(" "); .append("\" value=\"") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.button.remove")) .append("\"/> "); } else if (repeatable && j == fieldCount - 1) { // put a 'more' button next to the last space sb.append(" "); .append("_more\" value=\"") .append(LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.edit-metadata.button.add")) .append("\"/> "); } else { // put a blank if nothing else sb.append(" "); } } out.write(sb.toString()); } void doDropDown(javax.servlet.jsp.JspWriter out, Item item, String fieldName, String element, String qualifier, boolean repeatable, List valueList, String label) throws java.io.IOException { DCValue[] defaults = item.getDC(element, qualifier, Item.ANY); StringBuffer sb = new StringBuffer(); Iterator vals; String display, value; int j; sb.append("") .append(label) .append(""); sb.append("") .append(""); out.write(sb.toString()); } %> <% SubmissionInfo si = (SubmissionInfo) request.getAttribute("submission.info"); Item item = si.submission.getItem(); final int halfWidth = 23; final int fullWidth = 50; final int twothirdsWidth = 34; DCInputSet inputSet = (DCInputSet) request.getAttribute("submission.inputs"); Integer pageNumStr = (Integer) request.getAttribute("submission.page"); int pageNum = pageNumStr.intValue(); %>

<% if (pageNum == SubmitServlet.EDIT_METADATA_1) { %>

<% } else { %>

<% } %> <%-- HACK: a
tag seems to be the only way to convince certain --%> <%-- browsers to center the table. --%>
<% int pageIdx = pageNum - SubmitServlet.EDIT_METADATA_1; DCInput[] inputs = inputSet.getPageRows(pageIdx, si.submission.hasMultipleTitles(), si.submission.isPublishedBefore() ); for (int z = 0; z < inputs.length; z++) { String dcElement = inputs[z].getElement(); String dcQualifier = inputs[z].getQualifier(); String fieldName; int fieldCountIncr; boolean repeatable; if (dcQualifier != null && !dcQualifier.equals("*")) fieldName = dcElement + '_' + dcQualifier; else fieldName = dcElement; //if (inputs[z].isRequired()) { // si.jumpToField = fieldName; //} StringBuffer sb; if ((si.missingFields != null) && (si.missingFields.contains(new Integer(z)))) { String req = inputs[z].getWarning(); int anchor = req.indexOf(""); sb = new StringBuffer(req); sb.insert(anchor, ""); } else { sb = new StringBuffer(inputs[z].getHints()); } out.write(sb.toString()); repeatable = inputs[z].getRepeatable(); fieldCountIncr = 0; if (repeatable) { fieldCountIncr = 1; if (si.moreBoxesFor != null && si.moreBoxesFor.equals(fieldName)) { fieldCountIncr = 2; } } String inputType = inputs[z].getInputType(); String label = inputs[z].getLabel(); if (inputType.equals("name")) { doPersonalName(out, item, fieldName, dcElement, dcQualifier, repeatable, fieldCountIncr, label, pageContext); } else if (inputType.equals("date")) { doDate(out, item, fieldName, dcElement, dcQualifier, repeatable, fieldCountIncr, label, pageContext); } else if (inputType.equals("series")) { doSeriesNumber(out, item, fieldName, dcElement, dcQualifier, repeatable, fieldCountIncr, label, pageContext); } else if (inputType.equals("qualdrop_value")) { doQualdropValue(out, item, fieldName, dcElement, inputSet, repeatable, fieldCountIncr, inputs[z].getPairs(), label, pageContext); } else if (inputType.equals("textarea")) { doTextArea(out, item, fieldName, dcElement, dcQualifier, repeatable, fieldCountIncr, label, pageContext); } else if (inputType.equals("dropdown")) { doDropDown(out, item, fieldName, dcElement, dcQualifier, repeatable, inputs[z].getPairs(), label); } else if (inputType.equals("twobox")) { doTwoBox(out, item, fieldName, dcElement, dcQualifier, repeatable, fieldCountIncr, label, pageContext); } else { doOneBox(out, item, fieldName, dcElement, dcQualifier, repeatable, fieldCountIncr, label, pageContext); } %> <%-- HACK: Using this line to give the browser hints as to the widths of cells --%> <% } // end of 'for rows' %>
     
<%-- HACK: Need a space - is there a nicer way to do this than
or a --%> <%-- blank

? --%>

 

<%-- Hidden fields needed for submit servlet to know which item to deal with --%> <%= SubmitServlet.getSubmissionParameters(si) %>
  "/> "/>     "/>