Class 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)
    • Method Detail

      • clearCachedSearchService

        public static void clearCachedSearchService()
        Clear the cached SearchService instance, forcing it to be retrieved from the service manager again next time getSearchService() 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 context
        dso - 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 context
        prefix - the namespace of the configuration to lookup if any
        dso - 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 context
        configurations - - The set of configurations to add the retrieved configurations to
        prefix - - The namespace of the configuration to lookup if any
        dso - - 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 context
        dso - - The DSpace object to retrieve the configuration for
        Returns:
        the discovery configuration for the provided DSO
      • getIgnoredMetadataFields

        public static List<String> getIgnoredMetadataFields​(int type)
      • 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 context
        item - 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