Esri Geoportal Server
1.0

com.esri.gpt.catalog.search
Class ASearchEngine

java.lang.Object
  extended by com.esri.gpt.catalog.search.ASearchEngine
All Implemented Interfaces:
IRequest<SearchRequestDefinition>
Direct Known Subclasses:
SearchEngineCSW, SearchEngineFactory, SearchEngineRest

public abstract class ASearchEngine
extends Object
implements IRequest<SearchRequestDefinition>

Defines operations to be carried out by the search end point.


Constructor Summary
ASearchEngine()
          Default Constructor.
ASearchEngine(RequestContext context)
          Overloaded Constructor.
 
Method Summary
protected  void checkPagination()
          Check pagination.
 Map<String,Object> createInstances(StringSet rids)
          Creates multiple instances of this search engine.
abstract  void doSearch()
          Do search.
 int getConnectionTimeoutMs()
          Gets the connection timeout in milliseconds.
 URI getConnectionUri()
          Gets the connection uri.
 UsernamePasswordCredentials getCredentials()
          Gets the credentials.
 Map<String,String> getFactoryAttributes()
          Gets the factory attributes.
 boolean getHitsOnly()
          Gets the hits only.
 String getKey()
          Gets the key associated with the engine.
 String getKeyAbstract()
          Gets the abstract text connected with the key.
 MessageBroker getMessageBroker()
          Gets the message broker.
abstract  SearchResultRecord getMetadataAsSearchResultRecord(String uuid)
          Gets the metadata as object.
abstract  String getMetadataAsText(String uuid)
          Gets the metadata as text.
 String getMetadataUrl(String uuid)
          Gets the metadata url for record.
 RequestContext getRequestContext()
          Gets the request context.
 SearchRequestDefinition getRequestDefinition()
          Gets the request definition.
 ResourceLinkBuilder getResourceLinkBuilder()
          Gets the resource link builder.
 int getResponseTimeoutMs()
          Gets the response timeout in milliseconds.
abstract  String getSearchQuery()
          Gets the search query as a string representation.
 Long getSearchTimeInMillis()
          Gets the search time in millis.
 double getTimeInSeconds()
          Gets the time in seconds.
 void init()
          Inits the Object after you have set the properties.
protected  String readInputCharacters(InputStream is, String sEncoding)
          Fully reads the characters from the request input stream.
protected abstract  boolean readIsExternalSearch()
          Read is external search.
 void setConnectionTimeoutMs(int connectionTimeout)
          Sets the connection timeout in milliseconds.
 void setConnectionUri(URI connectionUri)
          Sets the connection uri.
 void setCredentials(UsernamePasswordCredentials credentials)
          Sets the credentials.
 void setFactoryAttributes(Map<String,String> factoryAttributes)
          Sets the factory attributes.
 void setHitsOnly(boolean hitsOnly)
          Sets the hits only.
 void setKey(String key)
          Sets the key associated with the key.
 void setMessageBroker(MessageBroker messageBroker)
          Sets the message broker.
 void setRequestContext(RequestContext context)
          Sets the request context.
 void setRequestDefinition(SearchRequestDefinition requestDefinition)
          Sets the request definition.
 void setResourceLinkBuilder(ResourceLinkBuilder resourceLinkBuilder)
          Sets the resource link builder.
 void setResponseTimeout(int responseTimeout)
          Sets the response timeout.
protected  void setSearchTimeInMillis(Long time)
          Sets the search time in millis.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ASearchEngine

public ASearchEngine()
Default Constructor. SearchFactory can instantiate this constructor.


ASearchEngine

public ASearchEngine(RequestContext context)
Overloaded Constructor. SearchFactory can instantiate this constructor.

Parameters:
context - the request context
Method Detail

getHitsOnly

public boolean getHitsOnly()
Gets the hits only.

Returns:
the hits only

setHitsOnly

public void setHitsOnly(boolean hitsOnly)
Sets the hits only.

Parameters:
hitsOnly - the new hits only

getResourceLinkBuilder

public ResourceLinkBuilder getResourceLinkBuilder()
Gets the resource link builder.

Returns:
the resource link builder (never null)

setResourceLinkBuilder

public void setResourceLinkBuilder(ResourceLinkBuilder resourceLinkBuilder)
Sets the resource link builder.

Parameters:
resourceLinkBuilder - the new resource link builder

getConnectionUri

public URI getConnectionUri()
                     throws SearchException
Gets the connection uri. If connection uri is null, the URI in the criteria will be used.

Returns:
the connection uri (possibly null)
Throws:
SearchException - if uri from criteria is invalid

setConnectionUri

public void setConnectionUri(URI connectionUri)
Sets the connection uri. If connection uri is null, the URI in the criteria will be used.

Parameters:
connectionUri - the new connection uri

getRequestContext

public RequestContext getRequestContext()
Gets the request context.

Returns:
the request context (Could be null)

setRequestContext

public void setRequestContext(RequestContext context)
Sets the request context.

Parameters:
context - the new request context

getKeyAbstract

public String getKeyAbstract()
                      throws SearchException
Gets the abstract text connected with the key.

Returns:
the abstract hint
Throws:
SearchException - the search exception

getKey

public String getKey()
Gets the key associated with the engine.

Returns:
the hint (trimmed, never null)

setKey

public void setKey(String key)
            throws SearchException
Sets the key associated with the key.

Parameters:
key - the key
Throws:
SearchException - the search exception (If error)

getCredentials

public UsernamePasswordCredentials getCredentials()
Gets the credentials.

Returns:
the credentials

setCredentials

public void setCredentials(UsernamePasswordCredentials credentials)
Sets the credentials.

Parameters:
credentials - the new credentials

getConnectionTimeoutMs

public int getConnectionTimeoutMs()
Gets the connection timeout in milliseconds.

Returns:
the connection timeout

setConnectionTimeoutMs

public void setConnectionTimeoutMs(int connectionTimeout)
Sets the connection timeout in milliseconds.

Parameters:
connectionTimeout - the new connection timeout

getResponseTimeoutMs

public int getResponseTimeoutMs()
Gets the response timeout in milliseconds.

Returns:
the response timeout

setResponseTimeout

public void setResponseTimeout(int responseTimeout)
Sets the response timeout.

Parameters:
responseTimeout - the new response timeout

doSearch

public abstract void doSearch()
                       throws SearchException
Do search. Should update the requestDefinition.searchResult and requestDefinition.searchResult.pageCursor

Throws:
SearchException - Exceptions from performing a search

getMetadataAsText

public abstract String getMetadataAsText(String uuid)
                                  throws SearchException
Gets the metadata as text.

Parameters:
uuid - the uuid of the metadata
Returns:
the metadata as text
Throws:
SearchException - Exception from retrieving the document

getMetadataAsSearchResultRecord

public abstract SearchResultRecord getMetadataAsSearchResultRecord(String uuid)
                                                            throws SearchException
Gets the metadata as object.

Parameters:
uuid - the uuid of the metadata
Returns:
the metadata as object
Throws:
SearchException - the search exception

getTimeInSeconds

public double getTimeInSeconds()
Gets the time in seconds.

Returns:
the time in seconds

getSearchTimeInMillis

public Long getSearchTimeInMillis()
Gets the search time in millis.

Returns:
the search time in millis

setSearchTimeInMillis

protected void setSearchTimeInMillis(Long time)
Sets the search time in millis.

Parameters:
time - the new search time in millis

getSearchQuery

public abstract String getSearchQuery()
                               throws SearchException
Gets the search query as a string representation. Should be the native query translated from the criteria.

Returns:
the search query
Throws:
SearchException - the search exception

getRequestDefinition

public SearchRequestDefinition getRequestDefinition()
Gets the request definition.

Specified by:
getRequestDefinition in interface IRequest<SearchRequestDefinition>
Returns:
the request definition (possibly null)

setRequestDefinition

public void setRequestDefinition(SearchRequestDefinition requestDefinition)
Sets the request definition.

Specified by:
setRequestDefinition in interface IRequest<SearchRequestDefinition>
Parameters:
requestDefinition - the new request definition

getMetadataUrl

public String getMetadataUrl(String uuid)
                      throws SearchException
Gets the metadata url for record.

Parameters:
uuid - the uuid
Returns:
the metadata url
Throws:
SearchException - the search exception

init

public void init()
          throws SearchException
Inits the Object after you have set the properties. Sets the attribute timeout connection and the attribute response timeout

Throws:
SearchExcpetion - the search excpetion
SearchException - the search exception

getFactoryAttributes

public Map<String,String> getFactoryAttributes()
Gets the factory attributes.

Returns:
the factory attributes (possibly null if not set or if set to null)

setFactoryAttributes

public void setFactoryAttributes(Map<String,String> factoryAttributes)
Sets the factory attributes.

Parameters:
factoryAttributes - the factory attributes

getMessageBroker

public MessageBroker getMessageBroker()
Gets the message broker.

Returns:
the message broker

setMessageBroker

public void setMessageBroker(MessageBroker messageBroker)
Sets the message broker.

Parameters:
messageBroker - the new message broker

readIsExternalSearch

protected abstract boolean readIsExternalSearch()
Read is external search.

Returns:
true, if successful

createInstances

public Map<String,Object> createInstances(StringSet rids)
                                   throws SearchException
Creates multiple instances of this search engine. Created for use by distributed search. Some searchengines consult the DB on every instance so if the searchengine knew beforehand that multiple searchengines need information from the database in the same request, then it is possible for it to generate 1 hit.

Parameters:
rids - the rids
Returns:
the map (value can be error string or ASearchEngine Object)
Throws:
SearchException - the search exception

checkPagination

protected void checkPagination()
                        throws SearchException
Check pagination. Recalculates pagination in-case we come to a service where max results are not returned. Call this after search to straighten out pagination

Throws:
SearchException - the search exception

readInputCharacters

protected String readInputCharacters(InputStream is,
                                     String sEncoding)
                              throws IOException
Fully reads the characters from the request input stream.

Parameters:
is - input stream
sEncoding - character encoding
Returns:
the characters read
Throws:
IOException - if an exception occurs

Esri Geoportal Server
1.0

Copyright 2011 Environmental Systems Research Institute. All rights reserved. Use is subject to license terms.