org.jbpm.services.api.query

## Interface QueryService

- All Known Subinterfaces:
    QueryServiceEJBLocal, QueryServiceEJBRemote
  All Known Implementing Classes:
    QueryServiceCDIImpl, QueryServiceEJBImpl, QueryServiceImpl

      public interface QueryService

  Advanced queries service that allows to register custom queries that will be equipped with tailored capabilities of querying data.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<QueryDefinition>` | `getQueries(org.kie.api.runtime.query.QueryContext queryContext)` Returns list of query definitions registered in the system
    `QueryDefinition` | `getQuery(String uniqueQueryName)` Returns query definition details that is registered under given uniqueQueryName
    `<T> T` | `query(String queryName, QueryResultMapper<T> mapper, org.kie.api.runtime.query.QueryContext queryContext, QueryParam... filterParams)` Performs query on given query definition that had to be previously registered.
    `<T> T` | `query(String queryName, QueryResultMapper<T> mapper, org.kie.api.runtime.query.QueryContext queryContext, QueryParamBuilder<?> paramBuilder)` Performs query on given query definition that had to be previously registered.
    `void` | `registerQuery(QueryDefinition queryDefinition)` Registers new query definition in the system so it can be used for executing queries on top of it.
    `void` | `replaceQuery(QueryDefinition queryDefinition)` Registers or replaces existing query.
    `void` | `unregisterQuery(String uniqueQueryName)` Removes the query definition from the system

- - ### Method Detail

    - #### registerQuery

          void registerQuery(QueryDefinition queryDefinition)
                             throws QueryAlreadyRegisteredException

      Registers new query definition in the system so it can be used for executing queries on top of it.
      Parameters:
        `queryDefinition` - definition of the query to be registered
      Throws:
        `QueryAlreadyRegisteredException` - in case there is already query registered with given name (queryDefinition.getName())

    - #### replaceQuery

          void replaceQuery(QueryDefinition queryDefinition)

      Registers or replaces existing query. Similar to what `registerQuery` does, though it won't throw exception in case there is already query registered but simply replace it.
      Parameters:
        `queryDefinition` - definition of the query to be registered/replaced

    - #### unregisterQuery

          void unregisterQuery(String uniqueQueryName)
                               throws QueryNotFoundException

      Removes the query definition from the system
      Parameters:
        `uniqueQueryName` - unique name that query was registered under
      Throws:
        `QueryNotFoundException` - in case there is no such query registered

    - #### getQuery

          QueryDefinition getQuery(String uniqueQueryName)
                                   throws QueryNotFoundException

      Returns query definition details that is registered under given uniqueQueryName
      Parameters:
        `uniqueQueryName` - unique name that query was registered under
      Returns:
        query definition details if found
      Throws:
        `QueryNotFoundException` - in case there is no such query registered

    - #### getQueries

          List<QueryDefinition> getQueries(org.kie.api.runtime.query.QueryContext queryContext)

      Returns list of query definitions registered in the system
      Parameters:
        `queryContext` - provides pagnition information for the query
      Returns:
        returns list of found queries

    - #### query

          <T> T query(String queryName,
                    QueryResultMapper<T> mapper,
                    org.kie.api.runtime.query.QueryContext queryContext,
                    QueryParam... filterParams)
                  throws QueryNotFoundException

      Performs query on given query definition that had to be previously registered. Results will be mapped by given `mapper` and:
      - sorting and paging will be applied based on `queryContext`
      - filtering of results will be done based on `filterParams` if given
      Parameters:
        `queryName` - unique name that query was registered under
        `mapper` - type of the `QueryResultMapper` to map raw data set into list of objects
        `queryContext` - query context carrying paging and sorting details
        `filterParams` - additional filter parameters to narrow down the result
      Returns:
        results mapped to objects from raw data set
      Throws:
        `QueryNotFoundException` - in case there is no such query registered

    - #### query

          <T> T query(String queryName,
                    QueryResultMapper<T> mapper,
                    org.kie.api.runtime.query.QueryContext queryContext,
                    QueryParamBuilder<?> paramBuilder)
                  throws QueryNotFoundException

      Performs query on given query definition that had to be previously registered. Results will be mapped by given `mapper` and:
      - sorting and paging will be applied based on `queryContext`
      - filtering of results will be done based on `paramBuilder` which is an implementation of `QueryParamBuilder` for building advanced filters
      Parameters:
        `queryName` - unique name that query was registered under
        `mapper` - type of the `QueryResultMapper` to map raw data set into list of objects
        `queryContext` - query context carrying paging and sorting details
        `paramBuilder` - implementation of `QueryParamBuilder` that allows to build custom filters in advanced way
      Returns:
        results mapped to objects from raw data set
      Throws:
        `QueryNotFoundException` - in case there is no such query registered

Copyright © 2001–2016 JBoss by Red Hat. All rights reserved.