Class QueryClient

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class QueryClient
    extends ClientApi
    Client for Querying the Inquire backend, using TQL queries. It contains also methods to manage (create, retrieve and remove) shared queries.

    See the documentation in ClientApi for details on authorization.

    • Method Detail

      • create

        public static QueryClient create​(String backendUrl)
        Create a new Query client pointing to the specified inquire server. The url usually looks like: 'http://{host-name}:port/teneo-inquire/'
        Parameters:
        backendUrl - URL of the inquire server
        Returns:
        Query client object
      • create

        public static QueryClient create​(String backendUrl,
                                         com.artisol.teneo.manager.client.TeneoManagerClient managerClient)
        Create a new Query client pointing to the specified inquire server. The url usually looks like: 'http://{host-name}:port/teneo-inquire/'
        Parameters:
        backendUrl - URL of the inquire server
        managerClient - TeneoManagerClient to be used for authorization
        Returns:
        Query client object
      • create

        public static QueryClient create​(String backendUrl,
                                         ExecutorService executorService)
        Create a new Query client pointing to the specified inquire server. The url usually looks like: 'http://{host-name}:port/teneo-inquire/'
        Parameters:
        backendUrl - URL of the inquire server
        executorService - ExecutorService where async query executions will be executed
        Returns:
        Query client object
      • create

        public static QueryClient create​(String backendUrl,
                                         com.artisol.teneo.manager.client.TeneoManagerClient managerClient,
                                         ExecutorService executorService)
        Create a new Query client pointing to the specified inquire server. The url usually looks like: 'http://{host-name}:port/teneo-inquire/'
        Parameters:
        backendUrl - URL of the inquire server
        managerClient - TeneoManagerClient to be used for authorization
        executorService - ExecutorService where async query executions will be executed
        Returns:
        Query client object
      • create

        public static QueryClient create​(String backendUrl,
                                         String accessToken,
                                         ExecutorService executorService)
        Create a new Query client pointing to the specified inquire server. The url usually looks like: 'http://{host-name}:port/teneo-inquire/'
        Parameters:
        backendUrl - URL of the inquire server
        accessToken - accessToken used for authorization
        executorService - ExecutorService where async query executions will be executed
        Returns:
        Query client object
      • create

        public static QueryClient create​(String backendUrl,
                                         String accessToken)
        Create a new Query client pointing to the specified inquire server. The url usually looks like: 'http://{host-name}:port/teneo-inquire/'
        Parameters:
        backendUrl - URL of the inquire server
        accessToken - accessToken used for authorization
        Returns:
        Query client object
      • submitQuery

        public QueryPoller submitQuery​(String lds,
                                       String tql,
                                       Map<String,​Object> parameters)
                                throws com.artisol.teneo.inquire.api.exceptions.InquireException
        Executes a TQL asynchronously query returning a QueryPoller which can be polled to get the latest results and find out when the query has finished.
        Parameters:
        lds - The lds name
        tql - The TQL string to be executed
        parameters - The list of params to be added to the HTTP request
        Returns:
        A QueryPoller object.
        Throws:
        com.artisol.teneo.inquire.api.exceptions.InquireException - If there is any problem processing the request.
      • submitSolutionRevisionQuery

        public QueryPoller submitSolutionRevisionQuery​(String lds,
                                                       Map<String,​Object> parameters)
                                                throws com.artisol.teneo.inquire.api.exceptions.InquireException
        Executes an asynchronously request to get all the solution revisions
        Parameters:
        lds - The lds name
        parameters - The list of params to be added to the HTTP request
        Returns:
        A QueryResultFuture.
        Throws:
        com.artisol.teneo.inquire.api.exceptions.InquireException - If there is any problem processing the request.
      • executeSharedQuery

        public Iterable<Map<String,​Object>> executeSharedQuery​(String lds,
                                                                     String sharedQueryName,
                                                                     Map<String,​Object> parameters)
                                                              throws com.artisol.teneo.inquire.api.exceptions.InquireException
        Executes a Shared Query synchronously and returns the resulting rows. This query cannot be cancelled
        Parameters:
        lds - The lds name
        sharedQueryName - The SharedQuery TQL name to be executed
        parameters - The list of params to be added to the HTTP request
        Returns:
        Query result (List of Maps)
        Throws:
        com.artisol.teneo.inquire.api.exceptions.InquireException - If there is any problem processing the request.
      • submitSharedQuery

        public QueryPoller submitSharedQuery​(String lds,
                                             String identifier,
                                             Map<String,​Object> parameters)
                                      throws com.artisol.teneo.inquire.api.exceptions.InquireException
        Executes a Shared Query asynchronously and returns a QueryPoller which can be polled to get the latest results and find out when the query has finished.
        Parameters:
        lds - The lds name
        identifier - The share query identifier. It can be the either the share query's name or UUID.
        parameters - The list of params to be added to the HTTP request
        Returns:
        A QueryResultFuture.
        Throws:
        com.artisol.teneo.inquire.api.exceptions.InquireException - If there is any problem processing the request.
      • submitQuery

        public QueryCancelable submitQuery​(String lds,
                                           String tql,
                                           Map<String,​Object> parameters,
                                           com.google.common.util.concurrent.FutureCallback<Iterable<Map<String,​Object>>> callback)
                                    throws com.artisol.teneo.inquire.api.exceptions.InquireException
        Executes a TQL query asynchronously, returning a QueryCancelable which can be used to cancel the query. It allows to pass a callback that will be called when query finish or fail.
        Parameters:
        lds - The lds name
        tql - The TQL string to be executed
        parameters - The list of params to be added to the HTTP request
        callback - The callback to be called when query finish
        Returns:
        A handle to the object for cancelling the request.
        Throws:
        com.artisol.teneo.inquire.api.exceptions.InquireException - If there is any problem processing the request.
      • submitSharedQuery

        public QueryCancelable submitSharedQuery​(String lds,
                                                 String sharedQueryName,
                                                 Map<String,​Object> parameters,
                                                 com.google.common.util.concurrent.FutureCallback<Iterable<Map<String,​Object>>> callback)
                                          throws com.artisol.teneo.inquire.api.exceptions.InquireException
        Executes a Shared Query asynchronously, returning a QueryCancelable which can be used to cancel the query. It allows to pass a callback that will be called when query finish or fail.
        Parameters:
        lds - The lds name
        sharedQueryName - The name of the SharedQuery to be executed
        parameters - The list of params to be added to the HTTP request
        callback - Then callback to be called when query finish
        Returns:
        If there is any problem processing the request.
        Throws:
        com.artisol.teneo.inquire.api.exceptions.InquireException - If there is any problem processing the request.
      • executeQuery

        public Iterable<Map<String,​Object>> executeQuery​(String lds,
                                                               String tql,
                                                               Map<String,​Object> parameters)
                                                        throws com.artisol.teneo.inquire.api.exceptions.InquireException
        Executes a TQL query returning the resulting rows. This query cannot be cancelled
        Parameters:
        lds - The lds name
        tql - The TQL string to be executed
        parameters - The list of params to be added to the HTTP request
        Returns:
        Query result (An iterable over Maps of the results)
        Throws:
        com.artisol.teneo.inquire.api.exceptions.InquireException - If there is any problem processing the request.
      • getSolutionRevisions

        public Iterable<Map<String,​Object>> getSolutionRevisions​(String lds,
                                                                       Map<String,​Object> parameters)
                                                                throws com.artisol.teneo.inquire.api.exceptions.InquireException
        Executes a TQL query returning the solution revisions. This query cannot be cancelled
        Parameters:
        lds - The lds name
        parameters - The list of params to be added to the HTTP request
        Returns:
        Query result (An iterable over Maps of the results)
        Throws:
        com.artisol.teneo.inquire.api.exceptions.InquireException - If there is any problem processing the request.
      • getSharedQueries

        public List<com.artisol.teneo.inquire.api.models.SharedQuery> getSharedQueries​(String lds)
                                                                                throws com.artisol.teneo.inquire.api.exceptions.InquireException
        Fetches the SharedQuery's for a lds.
        Parameters:
        lds - The lds name
        Returns:
        A List of all the SharedQuerys of the lds.
        Throws:
        com.artisol.teneo.inquire.api.exceptions.InquireException - If there is any problem processing the request.
      • saveSharedQuery

        public void saveSharedQuery​(String lds,
                                    com.artisol.teneo.inquire.api.models.SharedQuery query)
                             throws com.artisol.teneo.inquire.api.exceptions.InquireException
        Persists a SharedQuery. Overwrites any existing SharedQuery of the same name.
        Parameters:
        lds - The lds name
        query - The query to save
        Throws:
        com.artisol.teneo.inquire.api.exceptions.InquireException - If there is any problem processing the request.
      • deleteSharedQuery

        public void deleteSharedQuery​(String lds,
                                      String identifier)
        Deletes a SharedQuery if it exists.
        Parameters:
        lds - The lds name
        identifier - The share query identifier. It can be the either the share query's name or UUID.