mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 14:03:17 +00:00
DS-1225-Show display values for controlled vocabularies(input forms) in Item Page
This commit is contained in:
@@ -11,7 +11,10 @@ import java.io.IOException;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
@@ -26,7 +29,9 @@ import javax.servlet.jsp.tagext.TagSupport;
|
|||||||
|
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.dspace.app.util.DCInputsReaderException;
|
||||||
import org.dspace.app.util.MetadataExposure;
|
import org.dspace.app.util.MetadataExposure;
|
||||||
|
import org.dspace.app.util.Util;
|
||||||
import org.dspace.app.webui.util.StyleSelection;
|
import org.dspace.app.webui.util.StyleSelection;
|
||||||
import org.dspace.app.webui.util.UIUtil;
|
import org.dspace.app.webui.util.UIUtil;
|
||||||
import org.dspace.browse.BrowseException;
|
import org.dspace.browse.BrowseException;
|
||||||
@@ -291,6 +296,11 @@ public class ItemTag extends TagSupport
|
|||||||
{
|
{
|
||||||
throw new JspException(ie);
|
throw new JspException(ie);
|
||||||
}
|
}
|
||||||
|
catch (DCInputsReaderException ex)
|
||||||
|
{
|
||||||
|
throw new JspException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return SKIP_BODY;
|
return SKIP_BODY;
|
||||||
}
|
}
|
||||||
@@ -368,12 +378,12 @@ public class ItemTag extends TagSupport
|
|||||||
/**
|
/**
|
||||||
* Render an item in the given style
|
* Render an item in the given style
|
||||||
*/
|
*/
|
||||||
private void render() throws IOException, SQLException
|
private void render() throws IOException, SQLException, DCInputsReaderException
|
||||||
{
|
{
|
||||||
JspWriter out = pageContext.getOut();
|
JspWriter out = pageContext.getOut();
|
||||||
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
|
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
|
||||||
Context context = UIUtil.obtainContext(request);
|
Context context = UIUtil.obtainContext(request);
|
||||||
|
Locale sessionLocale = UIUtil.getSessionLocale(request);
|
||||||
String configLine = styleSelection.getConfigurationForStyle(style);
|
String configLine = styleSelection.getConfigurationForStyle(style);
|
||||||
|
|
||||||
if (configLine == null)
|
if (configLine == null)
|
||||||
@@ -399,6 +409,7 @@ public class ItemTag extends TagSupport
|
|||||||
boolean isLink = false;
|
boolean isLink = false;
|
||||||
boolean isResolver = false;
|
boolean isResolver = false;
|
||||||
boolean isNoBreakLine = false;
|
boolean isNoBreakLine = false;
|
||||||
|
boolean isDisplay = false;
|
||||||
|
|
||||||
String style = null;
|
String style = null;
|
||||||
Matcher fieldStyleMatcher = fieldStylePatter.matcher(field);
|
Matcher fieldStyleMatcher = fieldStylePatter.matcher(field);
|
||||||
@@ -424,6 +435,7 @@ public class ItemTag extends TagSupport
|
|||||||
isDate = style.contains("date");
|
isDate = style.contains("date");
|
||||||
isLink = style.contains("link");
|
isLink = style.contains("link");
|
||||||
isNoBreakLine = style.contains("nobreakline");
|
isNoBreakLine = style.contains("nobreakline");
|
||||||
|
isDisplay = style.equals("inputform");
|
||||||
isResolver = style.contains("resolver") || urn2baseurl.keySet().contains(style);
|
isResolver = style.contains("resolver") || urn2baseurl.keySet().contains(style);
|
||||||
field = field.replaceAll("\\("+style+"\\)", "");
|
field = field.replaceAll("\\("+style+"\\)", "");
|
||||||
}
|
}
|
||||||
@@ -473,7 +485,26 @@ public class ItemTag extends TagSupport
|
|||||||
|
|
||||||
out.print(label);
|
out.print(label);
|
||||||
out.print(": </td><td class=\"metadataFieldValue\">");
|
out.print(": </td><td class=\"metadataFieldValue\">");
|
||||||
|
|
||||||
|
//If the values are in controlled vocabulary and the display value should be shown
|
||||||
|
if (isDisplay){
|
||||||
|
List<String> displayValues = new ArrayList<String>();
|
||||||
|
|
||||||
|
|
||||||
|
displayValues = Util.getControlledVocabulariesDisplayValueLocalized(item, values, schema, element, qualifier, sessionLocale);
|
||||||
|
|
||||||
|
if (displayValues != null && !displayValues.isEmpty())
|
||||||
|
{
|
||||||
|
for (int d = 0; d < displayValues.size(); d++)
|
||||||
|
{
|
||||||
|
out.print(displayValues.get(d));
|
||||||
|
if (d<displayValues.size()-1) out.print(" <br/>");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.print("</td>");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (int j = 0; j < values.length; j++)
|
for (int j = 0; j < values.length; j++)
|
||||||
{
|
{
|
||||||
if (values[j] != null && values[j].value != null)
|
if (values[j] != null && values[j].value != null)
|
||||||
|
@@ -1443,6 +1443,8 @@ report.dir = ${dspace.dir}/reports/
|
|||||||
# dc.date.issued(date) = DC date.issued, render as a date
|
# dc.date.issued(date) = DC date.issued, render as a date
|
||||||
# dc.subject(nobreakline) = DC subject.keyword, rendered as separated values
|
# dc.subject(nobreakline) = DC subject.keyword, rendered as separated values
|
||||||
# (see also webui.itemdisplay.inclusespace and webui.itemdisplay.separator options)
|
# (see also webui.itemdisplay.inclusespace and webui.itemdisplay.separator options)
|
||||||
|
# dc.language(inputform) = If the dc.language is in a controlled vocabulary, then the displayed value will be shown based on the stored value from the value-pairs-name in input forms.
|
||||||
|
# The input-forms will be loaded based on the session locale. If the displayed value is not found, then the value will be shown as is.
|
||||||
# "link/date" options can be combined with "nobreakline" option using a space among them i.e "dc.identifier.uri(link nobreakline)"
|
# "link/date" options can be combined with "nobreakline" option using a space among them i.e "dc.identifier.uri(link nobreakline)"
|
||||||
#
|
#
|
||||||
# If an item has no value for a particular field, it won't be displayed.
|
# If an item has no value for a particular field, it won't be displayed.
|
||||||
|
Reference in New Issue
Block a user