Added ordering to bitstreams when listing bundles in dspace-api that defaults to sequence_id ASC.

Previously there had been no ordering on order retrieved, and order was dependent on last modified.

UI will pick up on it unless it does an additional sorting afterwards.
Issue #DS-192 - Bitstreams should be returned ordered

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5564 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Peter Dietz
2010-10-22 23:09:41 +00:00
parent 3d2b08842d
commit 56c6ca1f49
5 changed files with 51 additions and 5 deletions

View File

@@ -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<Bitstream>();
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

View File

@@ -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
*

View File

@@ -105,8 +105,6 @@
<!-- Otherwise, iterate over and display all of them -->
<xsl:otherwise>
<xsl:apply-templates select="mets:file">
<xsl:sort data-type="number" select="boolean(./@ID=$primaryBitstream)" order="descending" />
<xsl:sort select="mets:FLocat[@LOCTYPE='URL']/@xlink:title"/>
<xsl:with-param name="context" select="$context"/>
</xsl:apply-templates>
</xsl:otherwise>

View File

@@ -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 <a name> anchors in XMLUI
(Stuart Lewis, Christophe Dupriez)

View File

@@ -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--------------------#
#---------------------------------------------------------------#