Skip to content

Commit

Permalink
Merge pull request #54 from EKT/DS-1225
Browse files Browse the repository at this point in the history
[DS-1225] Show display values (input-forms) for controlled vocabularies in ItemTag
  • Loading branch information
abollini committed Sep 17, 2012
2 parents f523572 + beb95a3 commit d37a351
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -291,6 +296,11 @@ public int doStartTag() throws JspException
{
throw new JspException(ie);
}
catch (DCInputsReaderException ex)
{
throw new JspException(ex);
}


return SKIP_BODY;
}
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand All @@ -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+"\\)", "");
}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions dspace/config/dspace.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d37a351

Please sign in to comment.