org.dspace.app.xmlui.aspect.discovery
Class AbstractSearch

java.lang.Object
  extended by org.apache.cocoon.util.AbstractLogEnabled
      extended by org.apache.cocoon.xml.AbstractXMLProducer
          extended by org.apache.cocoon.xml.AbstractXMLPipe
              extended by org.apache.cocoon.transformation.AbstractTransformer
                  extended by org.dspace.app.xmlui.wing.AbstractWingTransformer
                      extended by org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer
                          extended by org.dspace.app.xmlui.aspect.discovery.AbstractSearch
All Implemented Interfaces:
org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, org.apache.cocoon.caching.CacheableProcessingComponent, org.apache.cocoon.sitemap.SitemapModelComponent, org.apache.cocoon.transformation.Transformer, org.apache.cocoon.xml.XMLPipe, org.apache.cocoon.xml.XMLProducer, org.apache.excalibur.xml.sax.XMLConsumer, DSpaceTransformer, WingTransformer, ContentHandler, LexicalHandler
Direct Known Subclasses:
SimpleSearch

public abstract class AbstractSearch
extends AbstractDSpaceTransformer
implements org.apache.cocoon.caching.CacheableProcessingComponent

This is an abstract search page. It is a collection of search methods that are common between diffrent search implementation. An implementer must implement at least three methods: addBody(), getQuery(), and generateURL().

See the implementors SimpleSearch.

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
protected  DiscoverQuery queryArgs
          Cached query arguments
protected  DiscoverResult queryResults
          Cached query results
 
Fields inherited from class org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer
context, contextPath, eperson, knot, objectModel, parameters, servletPath, sitemapURI, url
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.transformation.Transformer
ROLE
 
Constructor Summary
AbstractSearch()
           
 
Method Summary
abstract  void addBody(Body body)
          Build the resulting search DRI document.
protected  void buildScopeList(Select scope)
          Add options to the search scope field.
protected  void buildSearchControls(Division div)
           
protected  void buildSearchResultsDivision(Division search)
          Attach a division to the given search division named "search-results" which contains results for this search query.
protected abstract  String generateURL(Map<String,String> parameters)
          Generate a url to the given search implementation with the associated parameters included.
protected  String[] getFacetsList()
           
protected  String[] getFilterQueries()
          Returns all the filter queries for use by solr This method returns more expanded filter queries then the getParameterFilterQueries
 Serializable getKey()
          Generate the unique caching key.
protected  int getParameterEtAl()
           
protected  String[] getParameterFilterQueries()
          Returns a list of the filter queries for use in rendering pages, creating page more urls, ....
protected  String getParameterGroup()
           
protected  String getParameterOrder()
           
protected  int getParameterPage()
           
protected  int getParameterRpp()
           
protected  String getParameterScope()
           
protected  String getParameterSortBy()
           
protected abstract  String getQuery()
          Extract the query string.
protected  DSpaceObject getScope()
          Determine the current scope.
 org.apache.excalibur.source.SourceValidity getValidity()
          Generate the cache validity object.
protected  void logSearch()
           
 void performSearch(DSpaceObject scope)
          Query DSpace for a list of all items / collections / or communities that match the given search query.
 void recycle()
          Recycle
protected  boolean variableScope()
          Determine if the scope of the search should fixed or is changeable by the user.
 
Methods inherited from class org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer
addOptions, addPageMeta, addUserMeta, decodeFromURL, dispose, encodeForURL, generateURL, getComponentName, getObjectManager, handleException, setup
 
Methods inherited from class org.dspace.app.xmlui.wing.AbstractWingTransformer
createWingDocument, endDocument, endElement, endPrefixMapping, getDefaultMessageCatalogue, message, message, setupWing, startDocument, startElement, startPrefixMapping
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
characters, comment, endCDATA, endDTD, endEntity, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDTD, startEntity
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.cocoon.util.AbstractLogEnabled
getLogger, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
characters, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

queryResults

protected DiscoverResult queryResults
Cached query results


queryArgs

protected DiscoverQuery queryArgs
Cached query arguments

Constructor Detail

AbstractSearch

public AbstractSearch()
Method Detail

getKey

public Serializable getKey()
Generate the unique caching key. This key must be unique inside the space of this component.

Specified by:
getKey in interface org.apache.cocoon.caching.CacheableProcessingComponent

getValidity

public org.apache.excalibur.source.SourceValidity getValidity()
Generate the cache validity object.

This validity object should never "over cache" because it will perform the search, and serialize the results using the DSpaceValidity object.

Specified by:
getValidity in interface org.apache.cocoon.caching.CacheableProcessingComponent

addBody

public abstract void addBody(Body body)
                      throws SAXException,
                             WingException,
                             UIException,
                             SQLException,
                             IOException,
                             AuthorizeException
Build the resulting search DRI document.

Specified by:
addBody in interface DSpaceTransformer
Specified by:
addBody in interface WingTransformer
Overrides:
addBody in class AbstractDSpaceTransformer
Throws:
SAXException
WingException
UIException
SQLException
IOException
AuthorizeException

buildSearchResultsDivision

protected void buildSearchResultsDivision(Division search)
                                   throws IOException,
                                          SQLException,
                                          WingException,
                                          SearchServiceException
Attach a division to the given search division named "search-results" which contains results for this search query.

Parameters:
search - The search division to contain the search-results division.
Throws:
IOException
SQLException
WingException
SearchServiceException

buildScopeList

protected void buildScopeList(Select scope)
                       throws SQLException,
                              WingException
Add options to the search scope field. This field determines in what communities or collections to search for the query.

The scope list will depend upon the current search scope. There are three cases:

No current scope: All top level communities are listed.

The current scope is a community: All collections contained within the community are listed.

The current scope is a collection: All parent communities are listed.

Parameters:
scope - The current scope field.
Throws:
SQLException
WingException

performSearch

public void performSearch(DSpaceObject scope)
                   throws UIException,
                          SearchServiceException
Query DSpace for a list of all items / collections / or communities that match the given search query.

Parameters:
scope - the dspace object parent
Throws:
UIException
SearchServiceException

getParameterFilterQueries

protected String[] getParameterFilterQueries()
Returns a list of the filter queries for use in rendering pages, creating page more urls, ....

Returns:
an array containing the filter queries

getFilterQueries

protected String[] getFilterQueries()
Returns all the filter queries for use by solr This method returns more expanded filter queries then the getParameterFilterQueries

Returns:
an array containing the filter queries

getFacetsList

protected String[] getFacetsList()

getParameterPage

protected int getParameterPage()

getParameterRpp

protected int getParameterRpp()

getParameterSortBy

protected String getParameterSortBy()

getParameterGroup

protected String getParameterGroup()

getParameterOrder

protected String getParameterOrder()

getParameterScope

protected String getParameterScope()

getParameterEtAl

protected int getParameterEtAl()

variableScope

protected boolean variableScope()
                         throws SQLException
Determine if the scope of the search should fixed or is changeable by the user.

The search scope when preformed by url, i.e. they are at the url handle/xxxx/xx/search then it is fixed. However at the global level the search is variable.

Returns:
true if the scope is variable, false otherwise.
Throws:
SQLException

getQuery

protected abstract String getQuery()
                            throws UIException
Extract the query string. Under most implementations this will be derived from the url parameters.

Returns:
The query string.
Throws:
UIException

generateURL

protected abstract String generateURL(Map<String,String> parameters)
                               throws UIException
Generate a url to the given search implementation with the associated parameters included.

Parameters:
parameters -
Returns:
The post URL
Throws:
UIException

recycle

public void recycle()
Recycle

Specified by:
recycle in interface org.apache.avalon.excalibur.pool.Recyclable
Overrides:
recycle in class AbstractDSpaceTransformer

buildSearchControls

protected void buildSearchControls(Division div)
                            throws WingException,
                                   SQLException
Throws:
WingException
SQLException

getScope

protected DSpaceObject getScope()
                         throws SQLException
Determine the current scope. This may be derived from the current url handle if present or the scope parameter is given. If no scope is specified then null is returned.

Returns:
The current scope.
Throws:
SQLException

logSearch

protected void logSearch()


Copyright © 2012 DuraSpace. All Rights Reserved.