mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 18:14:26 +00:00
Minor corrections following the generalisation of sort ordering
git-svn-id: http://scm.dspace.org/svn/repo/trunk@2568 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -50,11 +50,11 @@ package org.dspace.text.filter;
|
|||||||
public abstract class InitialArticleWord implements TextFilter
|
public abstract class InitialArticleWord implements TextFilter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* When no language is passed, just return the string
|
* When no language is passed, use null and let implementation decide what to do
|
||||||
*/
|
*/
|
||||||
public String filter(String str)
|
public String filter(String str)
|
||||||
{
|
{
|
||||||
return str;
|
return filter(str, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -48,6 +48,9 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.dspace.core.ConfigurationManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements MARC 21 standards to disregard initial
|
* Implements MARC 21 standards to disregard initial
|
||||||
* definite or indefinite article in sorting.
|
* definite or indefinite article in sorting.
|
||||||
@@ -76,8 +79,8 @@ public class MARC21InitialArticleWord extends InitialArticleWord
|
|||||||
protected String[] getArticleWords(String lang)
|
protected String[] getArticleWords(String lang)
|
||||||
{
|
{
|
||||||
// No language - no words
|
// No language - no words
|
||||||
if (lang == null)
|
if (StringUtils.isEmpty(lang))
|
||||||
return null;
|
return defaultWords;
|
||||||
|
|
||||||
Language l = Language.getLanguage(lang);
|
Language l = Language.getLanguage(lang);
|
||||||
|
|
||||||
@@ -97,6 +100,8 @@ public class MARC21InitialArticleWord extends InitialArticleWord
|
|||||||
// Mapping of IANA codes to article word lists
|
// Mapping of IANA codes to article word lists
|
||||||
private static Map ianaArticleMap = new HashMap();
|
private static Map ianaArticleMap = new HashMap();
|
||||||
|
|
||||||
|
private static String[] defaultWords = null;
|
||||||
|
|
||||||
// Static initialisation - convert word -> languages map
|
// Static initialisation - convert word -> languages map
|
||||||
// into language -> words map
|
// into language -> words map
|
||||||
static
|
static
|
||||||
@@ -300,6 +305,45 @@ public class MARC21InitialArticleWord extends InitialArticleWord
|
|||||||
// Add language/article entry to map
|
// Add language/article entry to map
|
||||||
ianaArticleMap.put(lang.IANA, new MARC21InitialArticleWord.ArticlesForLang(lang, words));
|
ianaArticleMap.put(lang.IANA, new MARC21InitialArticleWord.ArticlesForLang(lang, words));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Setup default stop words for null languages
|
||||||
|
String defaultLangs = ConfigurationManager.getProperty("marc21wordfilter.defaultlang");
|
||||||
|
if (!StringUtils.isEmpty(defaultLangs))
|
||||||
|
{
|
||||||
|
String[] langArr = defaultLangs.split("[, ]+");
|
||||||
|
if (langArr != null && langArr.length > 0)
|
||||||
|
{
|
||||||
|
int wordCount = 0;
|
||||||
|
ArticlesForLang[] afl = new ArticlesForLang[langArr.length];
|
||||||
|
|
||||||
|
for (int idx = 0; idx < afl.length; idx++)
|
||||||
|
{
|
||||||
|
Language l = Language.getLanguage(langArr[idx]);
|
||||||
|
if (l != null && ianaArticleMap.containsKey(l.IANA))
|
||||||
|
{
|
||||||
|
afl[idx] = (ArticlesForLang)ianaArticleMap.get(l.IANA);
|
||||||
|
if (afl[idx] != null)
|
||||||
|
{
|
||||||
|
wordCount += afl[idx].words.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wordCount > 0)
|
||||||
|
{
|
||||||
|
int destPos = 0;
|
||||||
|
defaultWords = new String[wordCount];
|
||||||
|
for (int idx = 0; idx < afl.length; idx++)
|
||||||
|
{
|
||||||
|
if (afl[idx] != null)
|
||||||
|
{
|
||||||
|
System.arraycopy(afl[idx].words, 0, defaultWords, destPos, afl[idx].words.length);
|
||||||
|
destPos += afl[idx].words.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrapper class for inserting word arrays into a map
|
// Wrapper class for inserting word arrays into a map
|
||||||
|
@@ -576,7 +576,7 @@ webui.itemlist.sort-option.3 = dateaccessioned:dc.date.accessioned:date
|
|||||||
|
|
||||||
# Set the options for how the indexes are sorted
|
# Set the options for how the indexes are sorted
|
||||||
#
|
#
|
||||||
# All sort normalisations are carried out by the BrowseOrderDelegate.
|
# All sort normalisations are carried out by the OrderFormatDelegate.
|
||||||
# The plugin manager can be used to specify your own delegates for each datatype.
|
# The plugin manager can be used to specify your own delegates for each datatype.
|
||||||
#
|
#
|
||||||
# The default datatypes (and delegates) are:
|
# The default datatypes (and delegates) are:
|
||||||
|
Reference in New Issue
Block a user