mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 18:14:26 +00:00
Merge pull request #1165 from tuub/DS-2885
DS-2885: Making sort option for metadata browse indexes configurable
This commit is contained in:
@@ -12,6 +12,7 @@ import java.util.ArrayList;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.sort.SortOption;
|
||||
@@ -95,17 +96,30 @@ public final class BrowseIndex
|
||||
|
||||
/**
|
||||
* Create a new BrowseIndex object using the definition from the configuration,
|
||||
* and the number of the configuration option. The definition should be of
|
||||
* the form:
|
||||
* and the number of the configuration option. The definition should follow
|
||||
* one of the following forms:
|
||||
*
|
||||
* <code>
|
||||
* [name]:[metadata]:[data type]:[display type]
|
||||
* [name]:item:[sort option]:[order]
|
||||
* </code>
|
||||
*
|
||||
* or
|
||||
*
|
||||
* <code>
|
||||
* [name]:metadata:[metadata]:[data type]:[order]:[sort option]
|
||||
* </code>
|
||||
*
|
||||
* [name] is a freetext name for the field
|
||||
* item or metadata defines the display type
|
||||
* [metadata] is the usual format of the metadata such as dc.contributor.author
|
||||
* [sort option] is the name of a separately defined sort option
|
||||
* [order] must be either asc or desc
|
||||
* [data type] must be either "title", "date" or "text"
|
||||
* [display type] must be either "single" or "full"
|
||||
*
|
||||
* If you use the first form (to define an index of type item), the order
|
||||
* is facultative. If you use the second form (for type metadata), the order
|
||||
* and sort option are facultative, but you must configure the order if you
|
||||
* want to configure the sort option.
|
||||
*
|
||||
* @param definition the configuration definition of this index
|
||||
* @param number the configuration number of this index
|
||||
@@ -120,7 +134,7 @@ public final class BrowseIndex
|
||||
this.defaultOrder = SortOption.ASCENDING;
|
||||
this.number = number;
|
||||
|
||||
String rx = "(\\w+):(\\w+):([\\w\\.\\*,]+):?(\\w*):?(\\w*)";
|
||||
String rx = "(\\w+):(\\w+):([\\w\\.\\*,]+):?(\\w*):?(\\w*):?(\\w*)";
|
||||
Pattern pattern = Pattern.compile(rx);
|
||||
Matcher matcher = pattern.matcher(definition);
|
||||
|
||||
@@ -159,6 +173,30 @@ public final class BrowseIndex
|
||||
this.defaultOrder = SortOption.DESCENDING;
|
||||
}
|
||||
}
|
||||
|
||||
if (matcher.groupCount() > 5)
|
||||
{
|
||||
String sortName = matcher.group(6).trim();
|
||||
if (sortName.length() > 0)
|
||||
{
|
||||
for (SortOption so : SortOption.getSortOptions())
|
||||
{
|
||||
if (so.getName().equals(sortName))
|
||||
{
|
||||
sortOption = so;
|
||||
}
|
||||
}
|
||||
|
||||
// for backward compatability we ignore the keywords
|
||||
// single and full here
|
||||
if (!sortName.equalsIgnoreCase("single")
|
||||
&& !sortName.equalsIgnoreCase("full")
|
||||
&& sortOption == null)
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tableBaseName = getItemBrowseIndex().tableBaseName;
|
||||
}
|
||||
|
@@ -1059,7 +1059,8 @@ webui.strengths.show = false
|
||||
#
|
||||
# webui.browse.index.<n> = <index name> : metadata : \
|
||||
# <schema prefix>.<element>[.<qualifier>|.*] : \
|
||||
# (date | title | text) : (asc | desc)
|
||||
# (date | title | text) : (asc | desc) : \
|
||||
# <sort option name>
|
||||
#
|
||||
# This form represent a unique index of metadata values from the item.
|
||||
#
|
||||
@@ -1072,9 +1073,10 @@ webui.strengths.show = false
|
||||
# <other>: any other datatype will be treated the same as 'text', although
|
||||
# it will apply any custom ordering normalisation configured below
|
||||
#
|
||||
# The final part of the configuration is optional, and specifies the default ordering
|
||||
# The two last parts of the configuration are optional, and specifies the default ordering
|
||||
# for the index - whether it is ASCending (the default, and best for text indexes), or
|
||||
# DESCending (useful for dates - ie. most recent submissions)
|
||||
# DESCending (useful for dates - ie. most recent submissions) - and the sort option to use.
|
||||
# If you want to define the sort option you must define order as well.
|
||||
#
|
||||
# NOTE: the text to render the index will use the <index name> parameter to select
|
||||
# the message key from Messages.properties using a key of the form:
|
||||
|
Reference in New Issue
Block a user