Class SearchHelper

java.lang.Object
org.dlese.dpc.schemedit.SearchHelper

public class SearchHelper extends Object
Class to perform searches and cache the results as well as the query and sort information. Used to provide access to search results from different JSP pages (e.g., search, view).
Author:
Jonathan Ostwald
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the SearchHelper object
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the cachedRecIndex attribute of the SearchHelper object
    gets the Cached current record id
    int
    Return the index of the current record in the searchResults
    Returns all the searchResults
    getHits(int start, int length)
    Returns a range of searchResults
    int
    gets the index in the searchResults for the record having provided id.
    boolean
    Convienence caller of isEmpty for jsp pages.
    int
    Gets the number of searchResult items
    getRecId(int recIndex)
    Gets the id of the result at specifiec index of search results.
    Gets the ResultDoc for given record id from the index, returning null if a result is not found.
    Returns the current searchResults, doing a fresh search and sort if the index has changed since the searchResults were calculated.
    boolean
    Returns true if there are no searchResults
    search(org.apache.lucene.search.Query query)
    Return the results of search with the provided query, performing new search only if a new query string is provided or if the index has changed since the last search.
    search(org.apache.lucene.search.Query query, Object sortObj)
    Description of the Method
    void
    Sets the cachedRecIndex attribute of the SearchHelper object
    void
    Sets the currentRecId attribute of the RecordList object
    void
    setResults(ResultDoc resultDoc)
    Sets the results to the single resultDoc provided

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SearchHelper

      public SearchHelper(SimpleLuceneIndex index)
      Constructor for the SearchHelper object
      Parameters:
      index - NOT YET DOCUMENTED
  • Method Details

    • getResults

      public ResultDocList getResults()
      Returns the current searchResults, doing a fresh search and sort if the index has changed since the searchResults were calculated.

      When do we FORCE a new search?? - during sort (where the sort may have changed, but the index has not, so search would not have otherwise have been performed. NOTE: we could also force search by reseting the lastIndexMod to -1!

      RETHINK this logic. why cache anything? why not just return the searchResults or an empty list??

      Returns:
      The results value
    • search

      public ResultDocList search(org.apache.lucene.search.Query query)
      Return the results of search with the provided query, performing new search only if a new query string is provided or if the index has changed since the last search.

      Parameters:
      query - the lucene Query
      Returns:
      search results
    • search

      public ResultDocList search(org.apache.lucene.search.Query query, Object sortObj)
      Description of the Method
      Parameters:
      query - Description of the Parameter
      sortObj - Description of the Parameter
      Returns:
      Description of the Return Value
    • getHits

      public List getHits()
      Returns all the searchResults
      Returns:
      The hits value
    • getHits

      public List getHits(int start, int length)
      Returns a range of searchResults
      Parameters:
      start - beginning index
      length - length of range
      Returns:
      List of records from specified starting index
    • getIndexOf

      public int getIndexOf(String recId)
      gets the index in the searchResults for the record having provided id.
      Parameters:
      recId - a record id
      Returns:
      the index, or -1 if no record is found
    • isEmpty

      public boolean isEmpty()
      Returns true if there are no searchResults
      Returns:
      The empty value
    • getIsEmpty

      public boolean getIsEmpty()
      Convienence caller of isEmpty for jsp pages.
      Returns:
      returns true if there are no search results.
    • getNumHits

      public int getNumHits()
      Gets the number of searchResult items
      Returns:
      The numHits value
    • getCurrentRecId

      public String getCurrentRecId()
      gets the Cached current record id
      Returns:
      The currentRecId value
    • setCurrentRecId

      public void setCurrentRecId(String id)
      Sets the currentRecId attribute of the RecordList object
      Parameters:
      id - The new currentRecId value
    • getRecId

      public String getRecId(int recIndex)
      Gets the id of the result at specifiec index of search results.
      Parameters:
      recIndex - index into search results
      Returns:
      the id or null if not found
    • getCurrentRecIndex

      public int getCurrentRecIndex()
      Return the index of the current record in the searchResults
      Returns:
      The currentRecIndex value
    • getCachedRecIndex

      public int getCachedRecIndex()
      Gets the cachedRecIndex attribute of the SearchHelper object
      Returns:
      The cachedRecIndex value
    • setCachedRecIndex

      public void setCachedRecIndex(int i)
      Sets the cachedRecIndex attribute of the SearchHelper object
      Parameters:
      i - The new cachedRecIndex value
    • setResults

      public void setResults(ResultDoc resultDoc)
      Sets the results to the single resultDoc provided
      Parameters:
      resultDoc - The new results value
    • getResultDoc

      public ResultDoc getResultDoc(String id)
      Gets the ResultDoc for given record id from the index, returning null if a result is not found.

      If more than one result is found (this should not happen), print a message and return the first result.

      Parameters:
      id - record ID
      Returns:
      The resultDoc value or null if resultDoc is not found.