diff --git a/dspace-api/src/main/java/org/dspace/content/Bundle.java b/dspace-api/src/main/java/org/dspace/content/Bundle.java index 2ce99e4c57..7e8a226a5f 100644 --- a/dspace-api/src/main/java/org/dspace/content/Bundle.java +++ b/dspace-api/src/main/java/org/dspace/content/Bundle.java @@ -50,6 +50,7 @@ import org.dspace.authorize.AuthorizeConfiguration; import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeManager; import org.dspace.authorize.ResourcePolicy; +import org.dspace.core.ConfigurationManager; import org.dspace.core.Constants; import org.dspace.core.Context; import org.dspace.core.LogManager; @@ -102,13 +103,22 @@ public class Bundle extends DSpaceObject ourContext = context; bundleRow = row; bitstreams = new ArrayList(); + String bitstreamOrderingField = ConfigurationManager.getProperty("webui.bitstream.order.field", "sequence_id"); + String bitstreamOrderingDirection = ConfigurationManager.getProperty("webui.bitstream.order.direction", "ASC"); + + StringBuilder query = new StringBuilder(); + query.append("SELECT bitstream.* FROM bitstream, bundle2bitstream WHERE"); + query.append(" bundle2bitstream.bitstream_id=bitstream.bitstream_id AND"); + query.append(" bundle2bitstream.bundle_id= ?"); + query.append(" ORDER BY bitstream."); + query.append(bitstreamOrderingField); + query.append(" "); + query.append(bitstreamOrderingDirection); // Get bitstreams TableRowIterator tri = DatabaseManager.queryTable( ourContext, "bitstream", - "SELECT bitstream.* FROM bitstream, bundle2bitstream WHERE " - + "bundle2bitstream.bitstream_id=bitstream.bitstream_id AND " - + "bundle2bitstream.bundle_id= ? ", + query.toString(), bundleRow.getIntColumn("bundle_id")); try diff --git a/dspace-api/src/main/java/org/dspace/core/ConfigurationManager.java b/dspace-api/src/main/java/org/dspace/core/ConfigurationManager.java index cb87850d34..6ee767ecd4 100644 --- a/dspace-api/src/main/java/org/dspace/core/ConfigurationManager.java +++ b/dspace-api/src/main/java/org/dspace/core/ConfigurationManager.java @@ -192,6 +192,33 @@ public class ConfigurationManager return intValue; } + /** + * Get a configuration property and specify the fallback default + * + * @param property + * the name of the property + * + * @param defaultValue + * the default value of the property + * + * @return the value of the property or the default value if the property + * does not exist. + */ + public static String getProperty(String property, String defaultValue) + { + if (properties == null) { + loadConfig(null); + } + String propertyValue = properties.getProperty(property); + + if (propertyValue != null) { + propertyValue = propertyValue.trim(); + } else { + propertyValue = defaultValue; + } + return propertyValue; + } + /** * Get a configuration property as a long * diff --git a/dspace-xmlui/dspace-xmlui-webapp/src/main/webapp/themes/dri2xhtml/General-Handler.xsl b/dspace-xmlui/dspace-xmlui-webapp/src/main/webapp/themes/dri2xhtml/General-Handler.xsl index 552a615ca2..1f7d1fe36c 100644 --- a/dspace-xmlui/dspace-xmlui-webapp/src/main/webapp/themes/dri2xhtml/General-Handler.xsl +++ b/dspace-xmlui/dspace-xmlui-webapp/src/main/webapp/themes/dri2xhtml/General-Handler.xsl @@ -105,8 +105,6 @@ - - diff --git a/dspace/CHANGES b/dspace/CHANGES index f45dd623f5..a460836738 100644 --- a/dspace/CHANGES +++ b/dspace/CHANGES @@ -48,6 +48,7 @@ - [DS-563] Brazilian Portuguese (pt_BR) translation for XML-UI 1.6.2 (Peter Dietz) +- [DS-192] Bitstreams should be returned ordered - [DS-549] Added anchors in XMLUI (Stuart Lewis, Christophe Dupriez) diff --git a/dspace/config/dspace.cfg b/dspace/config/dspace.cfg index bf328a6b93..f5aaf164d8 100644 --- a/dspace/config/dspace.cfg +++ b/dspace/config/dspace.cfg @@ -1554,6 +1554,16 @@ authority.minconfidence = ambiguous #xmlui.lookup.select.size = 12 +#### Ordering of bitstreams #### + +## Specify the ordering that bitstreams are listed. +## +## Bitstream field to sort on. Values: sequence_id or name. Default: sequence_id +#webui.bitstream.order.field = "sequence_id" + +## Direction of sorting order. Values: DESC or ASC. Default: ASC +#webui.bitstream.order.direction = ASC + #---------------------------------------------------------------# #--------------JSPUI SPECIFIC CONFIGURATIONS--------------------# #---------------------------------------------------------------#