mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 07:23:08 +00:00
DS-1218 BrowseDAO based on discovery
This contribution is supported by the University of Hong Kong that has adopted the first version of this code since July 2010 Software development by the CILEA SURplus Team (http://www.cilea.it) This is a full featured provider for the DSpace Browse System that read data from the Discovery Search SOLR core. The browse supports: - all the actual browse system configuration options (item and metadata browse, pagination, sorting) - browse of withdrawn items - browse of private items (XMLUI only) - search for authors used in the item mapper tool Major changes: - add two new search methods to the SearchService that allow you to specify if you want or not withdrawn items in your result. The old methods just call these new methods asking for no withdrawn item (this assure backcompatiliby) - the SearchServiceImpl now index also withdrawn item, new SolrDoc field "withdrawn" - DiscoverResult.Facet now keep information also about authority so that is possible distinct facets related to homonyms authors, etc. (this feature can be disabled in the discovery.cfg) - changed the schema.xml the default should be to ignore field if not otherwise specified (see also below) - better support for projection, metadata are stored (not indexed) with all related informations attached (authority, language). Metadata to store for projection can be defined in the discovery.cfg Other notes: - SolrBrowseDAO/SolrCreateBrowseDAO use settings defined in the main dspace.cfg (the browse section) this mean that sorting configuration is not related to the discovery search sorting etc. - Browse consumer should be disabled (if not only overhead but it still works), the actual index work is done using the Discovery "plugin" SolrServiceIndexPlugin (configurated via spring) - SolrCreateBrowseDAO is able to remove the old tables created by the DBMS DAO implementations simply using the browse command line script (dspace index -d -f) - to build the browse index it is required to run the discovery index client (dspace update-discovery-index -b)
This commit is contained in:
@@ -29,19 +29,34 @@ public class BrowseDAOFactory
|
||||
public static BrowseDAO getInstance(Context context)
|
||||
throws BrowseException
|
||||
{
|
||||
String db = ConfigurationManager.getProperty("db.name");
|
||||
if ("postgres".equals(db))
|
||||
{
|
||||
return new BrowseDAOPostgres(context);
|
||||
}
|
||||
else if ("oracle".equals(db))
|
||||
{
|
||||
return new BrowseDAOOracle(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BrowseException("The configuration for db.name is either invalid, or contains an unrecognised database");
|
||||
}
|
||||
String className = ConfigurationManager.getProperty("browseDAO.class");
|
||||
if (className == null)
|
||||
{
|
||||
// For compatibility with previous versions
|
||||
String db = ConfigurationManager.getProperty("db.name");
|
||||
if ("postgres".equals(db))
|
||||
{
|
||||
return new BrowseDAOPostgres(context);
|
||||
}
|
||||
else if ("oracle".equals(db))
|
||||
{
|
||||
return new BrowseDAOOracle(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BrowseException("The configuration for db.name is either invalid, or contains an unrecognised database");
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
return (BrowseDAO) Class
|
||||
.forName(ConfigurationManager.getProperty("browseDAO.class"))
|
||||
.getConstructor(Context.class).newInstance(context);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new BrowseException("The configuration for browseDAO is invalid: "+className, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,19 +70,34 @@ public class BrowseDAOFactory
|
||||
public static BrowseCreateDAO getCreateInstance(Context context)
|
||||
throws BrowseException
|
||||
{
|
||||
String db = ConfigurationManager.getProperty("db.name");
|
||||
if ("postgres".equals(db))
|
||||
{
|
||||
return new BrowseCreateDAOPostgres(context);
|
||||
}
|
||||
else if ("oracle".equals(db))
|
||||
{
|
||||
return new BrowseCreateDAOOracle(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BrowseException("The configuration for db.name is either invalid, or contains an unrecognised database");
|
||||
}
|
||||
String className = ConfigurationManager.getProperty("browseCreateDAO.class");
|
||||
if (className == null)
|
||||
{
|
||||
// For compatibility with previous versions
|
||||
String db = ConfigurationManager.getProperty("db.name");
|
||||
if ("postgres".equals(db))
|
||||
{
|
||||
return new BrowseCreateDAOPostgres(context);
|
||||
}
|
||||
else if ("oracle".equals(db))
|
||||
{
|
||||
return new BrowseCreateDAOOracle(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BrowseException("The configuration for db.name is either invalid, or contains an unrecognised database");
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
return (BrowseCreateDAO) Class
|
||||
.forName(ConfigurationManager.getProperty("browseCreateDAO.class"))
|
||||
.getConstructor(Context.class).newInstance(context);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new BrowseException("The configuration for browseCreateDAO is invalid: "+className, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.content.authority;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* This is a *very* stupid test fixture for authority control with AuthorityVariantsSupport.
|
||||
*
|
||||
* @author Andrea Bollini (CILEA)
|
||||
*/
|
||||
public class TestAuthority implements ChoiceAuthority, AuthorityVariantsSupport
|
||||
{
|
||||
|
||||
@Override
|
||||
public List<String> getVariants(String key, String locale)
|
||||
{
|
||||
if (StringUtils.isNotBlank(key))
|
||||
{
|
||||
List<String> variants = new ArrayList<String>();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
variants.add(key+"_variant#"+i);
|
||||
}
|
||||
return variants;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Choices getMatches(String field, String text, int collection,
|
||||
int start, int limit, String locale)
|
||||
{
|
||||
Choices choices = new Choices(false);
|
||||
if (StringUtils.isNotBlank(text))
|
||||
{
|
||||
|
||||
List<Choice> choiceValues = new ArrayList<Choice>();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
choiceValues.add(new Choice(text + "_authority#" + i, text
|
||||
+ "_value#" + i, text + "_label#" + i));
|
||||
}
|
||||
choices = new Choices(
|
||||
(Choice[]) choiceValues.toArray(new Choice[choiceValues
|
||||
.size()]), 0, 3, Choices.CF_AMBIGUOUS, false);
|
||||
}
|
||||
|
||||
return choices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Choices getBestMatch(String field, String text, int collection,
|
||||
String locale)
|
||||
{
|
||||
Choices choices = new Choices(false);
|
||||
if (StringUtils.isNotBlank(text))
|
||||
{
|
||||
|
||||
List<Choice> choiceValues = new ArrayList<Choice>();
|
||||
|
||||
choiceValues.add(new Choice(text + "_authoritybest", text
|
||||
+ "_valuebest", text + "_labelbest"));
|
||||
|
||||
choices = new Choices(
|
||||
(Choice[]) choiceValues.toArray(new Choice[choiceValues
|
||||
.size()]), 0, 3, Choices.CF_UNCERTAIN, false);
|
||||
}
|
||||
return choices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel(String field, String key, String locale)
|
||||
{
|
||||
if (StringUtils.isNotBlank(key))
|
||||
{
|
||||
return key.replaceAll("authority", "label");
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user