Package com.artisol.teneo.inquire.client
Class QueryClient
- java.lang.Object
-
- com.artisol.teneo.inquire.client.ClientApi
-
- com.artisol.teneo.inquire.client.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.
-
-
Field Summary
-
Fields inherited from class com.artisol.teneo.inquire.client.ClientApi
accessToken, backendTarget, client, executorService, managerClient, objectMapper, PAGE_SIZE, PARAM_IDENTIFIER, PARAM_PROCESS_ID, PARAM_QUERY, resultType
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static QueryClient
create(String backendUrl)
Create a new Query client pointing to the specified inquire server.static QueryClient
create(String backendUrl, com.artisol.teneo.manager.client.TeneoManagerClient managerClient)
Create a new Query client pointing to the specified inquire server.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.static QueryClient
create(String backendUrl, String accessToken)
Create a new Query client pointing to the specified inquire server.static QueryClient
create(String backendUrl, String accessToken, ExecutorService executorService)
Create a new Query client pointing to the specified inquire server.static QueryClient
create(String backendUrl, ExecutorService executorService)
Create a new Query client pointing to the specified inquire server.void
deleteSharedQuery(String lds, String identifier)
Deletes aSharedQuery
if it exists.Iterable<Map<String,Object>>
executeQuery(String lds, String tql, Map<String,Object> parameters)
Executes a TQL query returning the resulting rows.Iterable<Map<String,Object>>
executeSharedQuery(String lds, String sharedQueryName, Map<String,Object> parameters)
Executes a Shared Query synchronously and returns the resulting rows.List<com.artisol.teneo.inquire.api.models.SharedQuery>
getSharedQueries(String lds)
Fetches theSharedQuery
's for a lds.Iterable<Map<String,Object>>
getSolutionRevisions(String lds, Map<String,Object> parameters)
Executes a TQL query returning the solution revisions.void
saveSharedQuery(String lds, com.artisol.teneo.inquire.api.models.SharedQuery query)
Persists aSharedQuery
.QueryPoller
submitQuery(String lds, String tql, Map<String,Object> parameters)
Executes a TQL asynchronously query returning aQueryPoller
which can be polled to get the latest results and find out when the query has finished.QueryCancelable
submitQuery(String lds, String tql, Map<String,Object> parameters, com.google.common.util.concurrent.FutureCallback<Iterable<Map<String,Object>>> callback)
Executes a TQL query asynchronously, returning aQueryCancelable
which can be used to cancel the query.QueryPoller
submitSharedQuery(String lds, String identifier, Map<String,Object> parameters)
Executes a Shared Query asynchronously and returns aQueryPoller
which can be polled to get the latest results and find out when the query has finished.QueryCancelable
submitSharedQuery(String lds, String sharedQueryName, Map<String,Object> parameters, com.google.common.util.concurrent.FutureCallback<Iterable<Map<String,Object>>> callback)
Executes a Shared Query asynchronously, returning aQueryCancelable
which can be used to cancel the query.QueryPoller
submitSolutionRevisionQuery(String lds, Map<String,Object> parameters)
Executes an asynchronously request to get all the solution revisions-
Methods inherited from class com.artisol.teneo.inquire.client.ClientApi
close, containsSavedResults, convertDataName, deleteSavedResults, deleteSolution, doDelete, doGet, doPost, doPut, getBearerToken, getDataOverview, getListOfLds, getUserInfo, getVersion, listSolutions, loadSavedResults, login, logout, ping, publishSolution, retrieveSession, saveResults, status
-
-
-
-
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 servermanagerClient
-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 serverexecutorService
-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 servermanagerClient
-TeneoManagerClient
to be used for authorizationexecutorService
-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 serveraccessToken
- accessToken used for authorizationexecutorService
-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 serveraccessToken
- 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 aQueryPoller
which can be polled to get the latest results and find out when the query has finished.- Parameters:
lds
- The lds nametql
- The TQL string to be executedparameters
- 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 nameparameters
- 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 namesharedQueryName
- The SharedQuery TQL name to be executedparameters
- 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 aQueryPoller
which can be polled to get the latest results and find out when the query has finished.- Parameters:
lds
- The lds nameidentifier
- 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 aQueryCancelable
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 nametql
- The TQL string to be executedparameters
- The list of params to be added to the HTTP requestcallback
- 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 aQueryCancelable
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 namesharedQueryName
- The name of the SharedQuery to be executedparameters
- The list of params to be added to the HTTP requestcallback
- 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 nametql
- The TQL string to be executedparameters
- 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 nameparameters
- 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 theSharedQuery
's for a lds.- Parameters:
lds
- The lds name- Returns:
- A List of all the
SharedQuery
s 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 aSharedQuery
. Overwrites any existingSharedQuery
of the same name.- Parameters:
lds
- The lds namequery
- The query to save- Throws:
com.artisol.teneo.inquire.api.exceptions.InquireException
- If there is any problem processing the request.
-
-