The v2/queryExecutor Service

In addition to running reports, JasperReports Server exposes queries that you can run through the rest_v2/queryExecutor service. In release 5.1, the only resource that supports queries is a Domain.

Method

URL

GET

http://<host>:<port>/jasperserver-pro/rest_v2/queryExecutor/path/to/Domain/?q=<query>

Argument

Type/Value

Description

q

Required String

The query string is a special format that references the fields and measures exposed by the Domain. To write this query, you must have knowledge of the Domain schema that is not available through the REST services. See below.

Options

accept: application/xml (default)

accept: application/json

Accept-Language: <locale>, <relativeQualityFactor>; for example en_US, q=0.8;

Return Value on Success

Typical Return Values on Failure

200 OK – The body contains the data that is the result of the query. See the format of the data below.

404 Not Found – When the specified Domain does not exist.

If the query is too large to fit in the argument in the URL, use the POST method to send it as request content:

Method

URL

POST

http://<host>:<port>/jasperserver-pro/rest_v2/queryExecutor/path/to/Domain/

Content-Type

Content

application/xml

The query string is a special format that references the fields and measures exposed by the Domain. To write this query, you must have knowledge of the Domain schema that is not available through the REST services. See below.

Options

accept: application/xml (default)

accept: application/json

Accept-Language: <locale>, <relativeQualityFactor>; for example en_US, q=0.8;

Return Value on Success

Typical Return Values on Failure

200 OK – The body contains the data that is the result of the query. See the format of the data below.

404 Not Found – When the specified Domain does not exist.

The following example show the format of a query in XML:

<query>
  <queryFields>
    <queryField id="expense_join_store.ej_store_store_city"/>
    <queryField id="expense_join_store.ej_store_store_country"/>
    <queryField id="expense_join_store.ej_store_store_name"/>
    <queryField id="expense_join_store.ej_store_store_state"/>
    <queryField id="expense_join_store.ej_store_store_street_address"/>
  </queryFields>
  <queryFilterString>expense_join_store.ej_store_store_country == 'USA'
                     and expense_join_store.ej_store_store_state == 'CA'
  </queryFilterString>
</query>

And the following sample shows the result of query. In order to optimize the size of the response, rows are presented as sets of values without the column names repeated for each row. The column IDs appear at the top of the result, as shown in the following example. As with the query, the result requires knowledge of the Domain schema to identify the human-readable column names.

<queryResult>
  <names>
    <name>expense_join_account.ej_account_account_description</name>
    <name>expense_join_account.ej_expense_fact_account_id</name>
    <name>expense_join_account.ej_account_account_parent</name>
    <name>expense_join_account.ej_account_account_rollup</name>
    <name>expense_join_account.ej_account_account_type</name>
    <name>expense_join_account.ej_account_Custom_Members</name>
    <name>expense_join.ej_expense_fact_amount</name>
    <name>expense_join_store.ej_store_store_type</name>
    <name>expense_join_store.ej_store_store_street_address</name>
    <name>expense_join_store.ej_store_store_city</name>
    <name>expense_join_store.ej_store_store_state</name>
    <name>expense_join_store.ej_store_store_postal_code</name>
    <name>expense_join_store.sample_time</name>
  </names>
  <values>
    <row>
      <value xsi:type="xs:string">Marketing</value>
      <value xsi:type="xs:int">4300</value>
      <value xsi:type="xs:int">4000</value>
      <value xsi:type="xs:string">+</value>
      <value xsi:type="xs:string">Expense</value>
      <value xsi:nil="true"/>
      <value xsi:type="xs:double">1884.0000</value>
      <value xsi:type="xs:dateTime">1997-01-01T04:05:06+02:00</value>
      <value xsi:type="xs:string">HeadQuarters</value>
      <value xsi:type="xs:string">1 Alameda Way</value>
      <value xsi:type="xs:string">Alameda</value>
      <value xsi:type="xs:string">CA</value>
      <value xsi:type="xs:int">94502</value>
      <value xsi:type="xs:string">USA</value>
      <value xsi:type="xs:time">04:05:06+02:00</value>
    </row>
     ...
  </values>
</queryResult>

Both date-only and timestamp fields are given in the ISO date-time format such as 1997-01-01T04:05:06+02:00.

For database columns that store a time and date that includes a time zone, such as “timestamp with time zone” in PostgreSQL, the result is not guaranteed to be in the same timezone as stored in the database. These dates and times are converted to the server’s time zone.

Version: 
Feedback