Permalink
Browse files

Merge pull request #54 from EKT/DS-1225

[DS-1225] Show display values (input-forms) for controlled vocabularies in ItemTag
  • Loading branch information...
2 parents 0bad4bf + a228654 commit 70a52cadc25295652c8a056b338630c9f2cb091e abollini committed Sep 17, 2012
@@ -11,7 +11,10 @@
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.StringTokenizer;
@@ -26,7 +29,9 @@
import org.apache.commons.lang.ArrayUtils;
import org.apache.log4j.Logger;
+import org.dspace.app.util.DCInputsReaderException;
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.UIUtil;
import org.dspace.browse.BrowseException;
@@ -291,6 +296,11 @@ public int doStartTag() throws JspException
{
throw new JspException(ie);
}
+ catch (DCInputsReaderException ex)
+ {
+ throw new JspException(ex);
+ }
+
return SKIP_BODY;
}
@@ -368,12 +378,12 @@ public void release()
/**
* Render an item in the given style
*/
- private void render() throws IOException, SQLException
+ private void render() throws IOException, SQLException, DCInputsReaderException
{
JspWriter out = pageContext.getOut();
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
Context context = UIUtil.obtainContext(request);
-
+ Locale sessionLocale = UIUtil.getSessionLocale(request);
String configLine = styleSelection.getConfigurationForStyle(style);
if (configLine == null)
@@ -399,6 +409,7 @@ private void render() throws IOException, SQLException
boolean isLink = false;
boolean isResolver = false;
boolean isNoBreakLine = false;
+ boolean isDisplay = false;
String style = null;
Matcher fieldStyleMatcher = fieldStylePatter.matcher(field);
@@ -424,6 +435,7 @@ private void render() throws IOException, SQLException
isDate = style.contains("date");
isLink = style.contains("link");
isNoBreakLine = style.contains("nobreakline");
+ isDisplay = style.equals("inputform");
isResolver = style.contains("resolver") || urn2baseurl.keySet().contains(style);
field = field.replaceAll("\\("+style+"\\)", "");
}
@@ -473,7 +485,26 @@ else if (eq.length > 2)
out.print(label);
out.print(":&nbsp;</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++)
{
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.subject(nobreakline) = DC subject.keyword, rendered as separated values
# (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)"
#
# If an item has no value for a particular field, it won't be displayed.

0 comments on commit 70a52ca

Please sign in to comment.