mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 10:04:21 +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.StringTokenizer;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
import org.dspace.sort.SortOption;
|
import org.dspace.sort.SortOption;
|
||||||
@@ -95,17 +96,30 @@ public final class BrowseIndex
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new BrowseIndex object using the definition from the configuration,
|
* Create a new BrowseIndex object using the definition from the configuration,
|
||||||
* and the number of the configuration option. The definition should be of
|
* and the number of the configuration option. The definition should follow
|
||||||
* the form:
|
* one of the following forms:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* [name]:[metadata]:[data type]:[display type]
|
* [name]:item:[sort option]:[order]
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* or
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* [name]:metadata:[metadata]:[data type]:[order]:[sort option]
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* [name] is a freetext name for the field
|
* [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
|
* [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"
|
* [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 definition the configuration definition of this index
|
||||||
* @param number the configuration number of this index
|
* @param number the configuration number of this index
|
||||||
@@ -120,7 +134,7 @@ public final class BrowseIndex
|
|||||||
this.defaultOrder = SortOption.ASCENDING;
|
this.defaultOrder = SortOption.ASCENDING;
|
||||||
this.number = number;
|
this.number = number;
|
||||||
|
|
||||||
String rx = "(\\w+):(\\w+):([\\w\\.\\*,]+):?(\\w*):?(\\w*)";
|
String rx = "(\\w+):(\\w+):([\\w\\.\\*,]+):?(\\w*):?(\\w*):?(\\w*)";
|
||||||
Pattern pattern = Pattern.compile(rx);
|
Pattern pattern = Pattern.compile(rx);
|
||||||
Matcher matcher = pattern.matcher(definition);
|
Matcher matcher = pattern.matcher(definition);
|
||||||
|
|
||||||
@@ -160,6 +174,30 @@ public final class BrowseIndex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
tableBaseName = getItemBrowseIndex().tableBaseName;
|
||||||
}
|
}
|
||||||
else if (isItemIndex())
|
else if (isItemIndex())
|
||||||
|
@@ -1059,7 +1059,8 @@ webui.strengths.show = false
|
|||||||
#
|
#
|
||||||
# webui.browse.index.<n> = <index name> : metadata : \
|
# webui.browse.index.<n> = <index name> : metadata : \
|
||||||
# <schema prefix>.<element>[.<qualifier>|.*] : \
|
# <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.
|
# 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
|
# <other>: any other datatype will be treated the same as 'text', although
|
||||||
# it will apply any custom ordering normalisation configured below
|
# 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
|
# 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
|
# 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:
|
# the message key from Messages.properties using a key of the form:
|
||||||
|
Reference in New Issue
Block a user