org.gcube.opensearch.opensearchoperator
Class OpenSearchOp

java.lang.Object
  extended by org.gcube.opensearch.opensearchoperator.OpenSearchOp

public class OpenSearchOp
extends java.lang.Object

Operator class used to query and obtain results from an external OpenSearch provider identified by an OpenSearchResource. An OpenSearch provider can be either direct or brokered. In the second case, the top provider is used to obtain a list of providers which will provide the actual results. The brokered providers are also described by their OpenSearchResource objects, which are automatically retrieved using a ResourceRepository. The search results undergo a transformation step using a suitable transformation specification that is contained as well in the OpenSearchResource. The transformation allows the operator to split a search result page to individual records and to transform these records to the desired schema, optionally adding an id field extracted from the data. The query(String) method returns an IProxyLocator identifying the ResultSet which contains GenericRecords comprised of one or (optionally) two StringFields, with the first containing the record content and the second containing the record id.

Author:
gerasimos.farantatos

Constructor Summary
OpenSearchOp(OpenSearchResource resource, java.lang.String[] fixedParams, gr.uoa.di.madgik.environment.hint.EnvHintCollection envHints)
          Creates a new OpenSearchOp using the default configuration specified in OpenSearchOpConfig.
OpenSearchOp(OpenSearchResource resource, java.lang.String[] fixedParams, OpenSearchOpConfig config, gr.uoa.di.madgik.environment.hint.EnvHintCollection envHints)
          Creates a new OpenSearchOp using the configuration specified in the respective argument.
 
Method Summary
static void main(java.lang.String[] args)
           
 java.net.URI query(java.lang.String queryString)
          Performs a query in order to obtain results from an OpenSearch provider
 void test(OpenSearchResource res)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OpenSearchOp

public OpenSearchOp(OpenSearchResource resource,
                    java.lang.String[] fixedParams,
                    gr.uoa.di.madgik.environment.hint.EnvHintCollection envHints)
             throws java.lang.Exception
Creates a new OpenSearchOp using the default configuration specified in OpenSearchOpConfig.

Parameters:
resource - The OpenSearch Resource identifying an OpenSearch provider and the transformations necessary to obtain the results
fixedParams - A set of pre-fixed OpenSearch parameters that override user parameters and are to be used while querying a broker. The user parameters are used while querying the retrieved OpenSearch providers.
envHints - An Environment Hint collection to be passed to the InformationSystem, if it is available.
Throws:
java.lang.Exception - In case of error

OpenSearchOp

public OpenSearchOp(OpenSearchResource resource,
                    java.lang.String[] fixedParams,
                    OpenSearchOpConfig config,
                    gr.uoa.di.madgik.environment.hint.EnvHintCollection envHints)
             throws java.lang.Exception
Creates a new OpenSearchOp using the configuration specified in the respective argument. In addition to using an InformationSystem to retrieve OpenSearch resources, a non-IS local mode is supported, mainly for the purpose of using the operator in the absence of an InformationSystem.

Parameters:
resource - The OpenSearch Resource identifying an OpenSearch provider and the transformations necessary to obtain the results
fixedParams - A set of pre-fixed OpenSearch parameters that override user parameters and are to be used while querying a broker. The user parameters are used while querying the retrieved OpenSearch providers.
config - The configuration to be used
envHints - An Environment Hint collection to be passed to the InformationSystem, if it is available.
Throws:
java.lang.Exception - In case of error
Method Detail

query

public java.net.URI query(java.lang.String queryString)
                   throws java.lang.Exception
Performs a query in order to obtain results from an OpenSearch provider

Parameters:
queryString - The operator query, in the form of qualified OpenSearch parameter, value pairs, where value should be double-quoted. The qualified OpenSearch parameters consist of the parameter names prefixed by their URl-encoded URI namespace. The namespace prefix should also be present in the case of standard OpenSearch parameters such as searchTerms. Some configuration parameters of the operator are exposed through the query interface, namely sequentialResults and numOfResults. In that case, their name should be prefixed by the config prefix, e.g. config:numOfResults="100"
Returns:
The locator of the query output
Throws:
java.lang.Exception - In case of error while creating an OpenSearchWorker to handle the request

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

test

public void test(OpenSearchResource res)
          throws java.lang.Exception
Throws:
java.lang.Exception