Class AbstractQueryService<T>

  • Type Parameters:
    T - The kind of query this service supports.
    Direct Known Subclasses:
    QueryService, TemplateService

    public abstract class AbstractQueryService<T>
    extends Service
    Common behaviour for services requesting results from a web-service.
    • Constructor Detail

      • AbstractQueryService

        public AbstractQueryService​(java.lang.String rootUrl,
                                    java.lang.String serviceRelativeUrl,
                                    java.lang.String applicationName)
        Constructor.
        Parameters:
        rootUrl - The root URL to the service provider
        serviceRelativeUrl - The path to the resource.
        applicationName - The name of the application.
    • Method Detail

      • getAllResults

        public java.util.List<java.util.List<java.lang.String>> getAllResults​(T query)
        Returns all the results for the given template template. If you expect a lot of results we would recommend you use getAllResultIterator() method.
        Parameters:
        query - The template to run.
        Returns:
        results
      • getAllJSONResults

        public java.util.List<org.json.JSONObject> getAllJSONResults​(T query)
                                                              throws org.json.JSONException
        Returns all the results for the given template template, as JSON objects (see @link {http://www.intermine.org/wiki/JSONObjectFormat}).
        Parameters:
        query - The query to run.
        Returns:
        The results for this template.
        Throws:
        org.json.JSONException - if the server returns content that cannot be parsed as JSON
      • getAllRowsIterator

        public java.util.Iterator<java.util.List<java.lang.String>> getAllRowsIterator​(T query)
        Returns an iterator over all the rows for the template. Use this method if you expect a lot of results and you would otherwise run out of memory.
        Parameters:
        query - The template to run.
        Returns:
        results as an iterator over lists of strings
      • getRowMapIterator

        public java.util.Iterator<java.util.Map<java.lang.String,​java.lang.Object>> getRowMapIterator​(T query)
        Get an iterator over the results of a query. The iterator returns a representation of one row at a time, in the order received over the connection, up to the maximum result size of 10,000,000 rows from the beginning.
        Parameters:
        query - the query to run.
        Returns:
        an iterator over the rows, where each row is a mapping from output column to value.
      • getRowMapIterator

        public java.util.Iterator<java.util.Map<java.lang.String,​java.lang.Object>> getRowMapIterator​(T query,
                                                                                                            Page page)
        Get an iterator over the results of a query. The iterator returns a representation of one row at a time, in the order received over the connection.
        Parameters:
        query - the query to run.
        page - The subsection of the result set to retrieve.
        Returns:
        an iterator over the rows, where each row is a mapping from output column to value.
      • getRowListIterator

        public java.util.Iterator<java.util.List<java.lang.Object>> getRowListIterator​(T query)
        Get an iterator over the results of a query. The iterator returns a representation of one row at a time, in the order received over the connection. Retrieves up to the maximum result size of 10,000,000 rows from the beginning.
        Parameters:
        query - the query to run.
        Returns:
        an iterator over the rows, where each row is a list of objects.
      • getRowListIterator

        public java.util.Iterator<java.util.List<java.lang.Object>> getRowListIterator​(T query,
                                                                                       Page page)
        Get an iterator over the results of a query. The iterator returns a representation of one row at a time, in the order received over the connection.
        Parameters:
        query - the query to run.
        page - The subsection of the result set to retrieve.
        Returns:
        an iterator over the rows, where each row is a list of objects.
      • getRowsAsMaps

        public java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> getRowsAsMaps​(T query)
        Get results for a query as rows of objects. Get up to the maximum result size of 10,000,000 rows from the beginning.
        Parameters:
        query - The query to run.
        Returns:
        a list of rows, which are each a map from output column (in alternate long and short form) to value.
      • getRowsAsMaps

        public java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> getRowsAsMaps​(T query,
                                                                                                    Page page)
        Get results for a query as rows of objects.
        Parameters:
        query - The query to run.
        page - The subsection of the result set to retrieve.
        Returns:
        a list of rows, which are each a map from output column (in alternate long and short form) to value.
      • getRowsAsLists

        public java.util.List<java.util.List<java.lang.Object>> getRowsAsLists​(T query)
        Get results for a query as rows of objects. Retrieve up to 10,000,000 rows from the beginning.
        Parameters:
        query - The query to run.
        Returns:
        a list of rows, which are each a list of cells.
      • getRowsAsLists

        public java.util.List<java.util.List<java.lang.Object>> getRowsAsLists​(T query,
                                                                               Page page)
        Get results for a query as rows of objects.
        Parameters:
        query - The query to run.
        page - The subsection of the result set to retrieve.
        Returns:
        a list of rows, which are each a list of cells.
      • getResponseTable

        protected XMLTableResult getResponseTable​(Request request)
        Performs the actual remote request and fetches the results.
        Parameters:
        request - a Request object
        Returns:
        a XMLTableResult object containing the response data
      • getRows

        protected RowResultSet getRows​(Request request,
                                       java.util.List<java.lang.String> views)
        Performs the actual remote request and fetches the results.
        Parameters:
        request - a Request object
        views - The list of the output columns
        Returns:
        a RowResultSet object containing the response data
      • getJSONResponse

        protected JSONResult getJSONResponse​(Request request)
        Performs the request and returns a JSONResult containing the data.
        Parameters:
        request - a QueryRequest object
        Returns:
        a JSONResult object containing the data fetched