Package org.dspace.discovery
Class SearchUtils
- java.lang.Object
-
- org.dspace.discovery.SearchUtils
-
public class SearchUtils extends Object
Util methods used by discovery- Author:
- Kevin Van de Velde (kevin at atmire dot com), Mark Diggory (markd at atmire dot com), Ben Bosman (ben at atmire dot com)
-
-
Field Summary
Fields Modifier and Type Field Description static StringAUTHORITY_SEPARATORstatic StringFILTER_SEPARATORstatic StringLAST_INDEXED_FIELDstatic StringNAMED_RESOURCE_TYPEstatic StringRESOURCE_ID_FIELDstatic StringRESOURCE_TYPE_FIELDstatic StringRESOURCE_UNIQUE_ID
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Set<DiscoveryConfiguration>addDiscoveryConfigurationForParents(Context context, Set<DiscoveryConfiguration> configurations, String prefix, DSpaceObject dso)Retrieve the configuration for the current dspace object and all its parents and add it to the provided setstatic voidclearCachedSearchService()Clear the cachedSearchServiceinstance, forcing it to be retrieved from the service manager again next timegetSearchService()is called.static List<DiscoveryConfiguration>getAllDiscoveryConfigurations(Context context, Item item)Method that retrieves a list of all the configuration objects from the given item A configuration object can be returned for each parent community/collectionstatic List<DiscoveryConfiguration>getAllDiscoveryConfigurations(Context context, WorkspaceItem witem)Return all the discovery configuration applicable to the provided workspace itemstatic List<DiscoveryConfiguration>getAllDiscoveryConfigurations(Context context, WorkflowItem witem)Return all the discovery configuration applicable to the provided workflow itemstatic DiscoveryConfigurationServicegetConfigurationService()static DiscoveryConfigurationgetDiscoveryConfiguration()Retrieves the Discovery Configuration for a null context, prefix and DSpace object.static DiscoveryConfigurationgetDiscoveryConfiguration(Context context, String prefix, DSpaceObject dso)Return the discovery configuration to use in a specific scope for the king of search identified by the prefix.static DiscoveryConfigurationgetDiscoveryConfiguration(Context context, DSpaceObject dso)Retrieves the Discovery Configuration with a null prefix for a DSpace object.static DiscoveryConfigurationgetDiscoveryConfigurationByDSO(Context context, DSpaceObject dso)Return the discovery configuration for the provided DSOstatic DiscoveryConfigurationgetDiscoveryConfigurationByName(String configurationName)Return the discovery configuration identified by the specified namestatic List<String>getIgnoredMetadataFields(int type)static DiscoverQueryBuildergetQueryBuilder()static SearchServicegetSearchService()Return an instance of theSearchService.
-
-
-
Field Detail
-
AUTHORITY_SEPARATOR
public static final String AUTHORITY_SEPARATOR
- See Also:
- Constant Field Values
-
LAST_INDEXED_FIELD
public static final String LAST_INDEXED_FIELD
- See Also:
- Constant Field Values
-
RESOURCE_UNIQUE_ID
public static final String RESOURCE_UNIQUE_ID
- See Also:
- Constant Field Values
-
RESOURCE_TYPE_FIELD
public static final String RESOURCE_TYPE_FIELD
- See Also:
- Constant Field Values
-
RESOURCE_ID_FIELD
public static final String RESOURCE_ID_FIELD
- See Also:
- Constant Field Values
-
NAMED_RESOURCE_TYPE
public static final String NAMED_RESOURCE_TYPE
- See Also:
- Constant Field Values
-
FILTER_SEPARATOR
public static final String FILTER_SEPARATOR
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSearchService
public static SearchService getSearchService()
Return an instance of theSearchService.
-
clearCachedSearchService
public static void clearCachedSearchService()
Clear the cachedSearchServiceinstance, forcing it to be retrieved from the service manager again next timegetSearchService()is called. In practice, this is only necessary for integration tests in some environments where the cached version may no longer be up to date between tests.
-
getDiscoveryConfiguration
public static DiscoveryConfiguration getDiscoveryConfiguration()
Retrieves the Discovery Configuration for a null context, prefix and DSpace object. This will result in returning the default configuration- Returns:
- the default configuration
-
getDiscoveryConfiguration
public static DiscoveryConfiguration getDiscoveryConfiguration(Context context, DSpaceObject dso)
Retrieves the Discovery Configuration with a null prefix for a DSpace object.- Parameters:
context- the dabase contextdso- the DSpace object- Returns:
- the Discovery Configuration for the specified DSpace object
-
getDiscoveryConfiguration
public static DiscoveryConfiguration getDiscoveryConfiguration(Context context, String prefix, DSpaceObject dso)
Return the discovery configuration to use in a specific scope for the king of search identified by the prefix. A null prefix mean the normal query, other predefined values are workspace or workflow- Parameters:
context- the database contextprefix- the namespace of the configuration to lookup if anydso- the DSpaceObject- Returns:
- the discovery configuration for the specified scope
-
addDiscoveryConfigurationForParents
public static Set<DiscoveryConfiguration> addDiscoveryConfigurationForParents(Context context, Set<DiscoveryConfiguration> configurations, String prefix, DSpaceObject dso) throws SQLException
Retrieve the configuration for the current dspace object and all its parents and add it to the provided set- Parameters:
context- - The database contextconfigurations- - The set of configurations to add the retrieved configurations toprefix- - The namespace of the configuration to lookup if anydso- - The DSpace Object- Returns:
- the set of configurations with additional retrieved ones for the dspace object and parents
- Throws:
SQLException
-
getDiscoveryConfigurationByName
public static DiscoveryConfiguration getDiscoveryConfigurationByName(String configurationName)
Return the discovery configuration identified by the specified name- Parameters:
configurationName- the configuration name assigned to the bean in the discovery.xml- Returns:
- the discovery configuration
-
getDiscoveryConfigurationByDSO
public static DiscoveryConfiguration getDiscoveryConfigurationByDSO(Context context, DSpaceObject dso)
Return the discovery configuration for the provided DSO- Parameters:
context- - The database contextdso- - The DSpace object to retrieve the configuration for- Returns:
- the discovery configuration for the provided DSO
-
getConfigurationService
public static DiscoveryConfigurationService getConfigurationService()
-
getAllDiscoveryConfigurations
public static List<DiscoveryConfiguration> getAllDiscoveryConfigurations(Context context, Item item) throws SQLException
Method that retrieves a list of all the configuration objects from the given item A configuration object can be returned for each parent community/collection- Parameters:
context- the database contextitem- the DSpace item- Returns:
- a list of configuration objects
- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
getAllDiscoveryConfigurations
public static List<DiscoveryConfiguration> getAllDiscoveryConfigurations(Context context, WorkspaceItem witem) throws SQLException
Return all the discovery configuration applicable to the provided workspace item- Parameters:
context-witem- a workspace item- Returns:
- a list of discovery configuration
- Throws:
SQLException
-
getAllDiscoveryConfigurations
public static List<DiscoveryConfiguration> getAllDiscoveryConfigurations(Context context, WorkflowItem witem) throws SQLException
Return all the discovery configuration applicable to the provided workflow item- Parameters:
context-witem- a workflow item- Returns:
- a list of discovery configuration
- Throws:
SQLException
-
getQueryBuilder
public static DiscoverQueryBuilder getQueryBuilder()
-
-