Get Operation

The get operation is used to obtain information about a resource. In the case of file resources, such as images, fonts, JRXML files, and JAR files, the resource file is attached to the response message.

This method’s behavior differs according to the type of object specified:

Generally, a simple resource descriptor is returned.
If you get a resource file, the file content is attached to the response; if you do not want the server to attach files to the response, set the request’s NO_ATTACHMENT argument to true.
If you get a report unit, all the related resources are added as child resource descriptors to the report unit descriptor.
To get an input control that is based on a query, you must set the IC_GET_QUERY_DATA argument to the valid URI of a datasource for the control, or you can handle the NONE condition as in the sample code java-webapp-sample.

If you set the datasource in the input control, that datasource is used to execute the query and populate the resource descriptor. This can be useful when the input control must be rendered (for example, on a web page) in order to capture a value to pass when executing a report.

You can use parameters in the input control to select query values, including the datasource. See the examples starting on .

The following sample request gets a file resource:

<request operationName="get" locale="en">
  <resourceDescriptor name="JRLogo" wsType="img" uriString="/images/JRLogo" isNew="false">
    <label>JR logo</label>
    <description>JR logo</description>
  </resourceDescriptor>
</request>

The service only uses the uriString to identify the resource to get and check for access permissions. This means that other information present in the resource description (such as resource properties, label, and description) are not actually used or required.

If a file is attached to the response, the returned resource descriptor has the PROP_HAS_DATA property set to true. By default, the attachments format is MIME. You can use DIME attachments by specifying the USE_DIME_ATTACHMENTS argument in the request.

A get call always returns a resource descriptor. If the specified resource is not found, or the specified user cannot access it, an error with code 2 is returned.

Java sample:

String imgUri = "/images/JRLogo";
ResourceDescriptor rdis = new ResourceDescriptor();
rdis.setParentFolder("/images");
rdis.setUriString(imgUri);
ResourceDescriptor result = wsclient.get(rdis, null);

PHP sample:

$result = ws_get($someInputControlUri, array( IC_GET_QUERY_DATA => 
$someDatasourceUri ) );

The resource descriptor of an input control that includes data obtained by setting the IC_GET_QUERY_DATA argument to true would be similar to the following XML:

<resourceDescriptor name="TEST_LIST" wsType="inputControl" uriString=  "/MyInputControls/TEST_LIST" isNew="false"><br />
  <label>My test list</label>
  <description>My test list</description>
  <resourceProperty name="PROP_RESOURCE_TYPE">
    <value>com.jaspersoft.jasperserver.api.metadata.common.domain.InputControl</
      value>
  </resourceProperty>
  <resourceProperty name="PROP_PARENT_FOLDER">
    <value>/MyInputControls</value>
  </resourceProperty>
  <resourceProperty name="PROP_VERSION">
    <value>6</value>
  </resourceProperty>
  <resourceProperty name="PROP_HAS_DATA">
    <value>false</value>
  </resourceProperty>
  <resourceProperty name="PROP_IS_REFERENCE">
    <value>false</value>
  </resourceProperty>
  <resourceProperty name="PROP_INPUTCONTROL_IS_MANDATORY">
    <value>true</value>
  </resourceProperty>
  <resourceProperty name="PROP_INPUTCONTROL_IS_READONLY">
    <value>false</value>
  </resourceProperty>
  <resourceProperty name="PROP_INPUTCONTROL_TYPE">
    <value>7</value>
  </resourceProperty>
  <resourceProperty name="PROP_QUERY_VALUE_COLUMN">
    <value>name</value>
  </resourceProperty>
  <resourceProperty name="PROP_QUERY_VISIBLE_COLUMNS">
    <resourceProperty name="PROP_QUERY_VISIBLE_COLUMN_NAME">
      <value>name</value>
    </resourceProperty>
    <resourceProperty name="PROP_QUERY_VISIBLE_COLUMN_NAME">
      <value>phone_office</value>
    </resourceProperty>
    <resourceProperty name="PROP_QUERY_VISIBLE_COLUMN_NAME">
      <value>billing_address_city</value>
    </resourceProperty>
  </resourceProperty>
  <resourceProperty name="PROP_QUERY_DATA">
    <resourceProperty name="PROP_QUERY_DATA_ROW">
      <value>A &amp; L Powers Engineering, Inc</value>
      <resourceProperty name="PROP_QUERY_DATA_ROW_COLUMN">
        <value>A &amp; L Powers Engineering, Inc</value>
      </resourceProperty>
      <resourceProperty name="PROP_QUERY_DATA_ROW_COLUMN">
        <value>738-555-3283</value>
      </resourceProperty>
      <resourceProperty name="PROP_QUERY_DATA_ROW_COLUMN">
        <value>Haney</value>
      </resourceProperty>
    </resourceProperty>
    <resourceProperty name="PROP_QUERY_DATA_ROW">
      <value>A &amp; U Jaramillo Telecommunications, Inc</value>
      <resourceProperty name="PROP_QUERY_DATA_ROW_COLUMN">
        <value>A &amp; U Jaramillo Telecommunications, Inc</value>
      </resourceProperty>
      <resourceProperty name="PROP_QUERY_DATA_ROW_COLUMN">
        <value>564-555-6913</value>
      </resourceProperty>
      <resourceProperty name="PROP_QUERY_DATA_ROW_COLUMN">
        <value>Walla Walla</value>
      </resourceProperty>
    </resourceProperty>
    <resourceProperty name="PROP_QUERY_DATA_ROW">
      <value>A &amp; U Stalker Telecommunications, Inc</value>
      <resourceProperty name="PROP_QUERY_DATA_ROW_COLUMN">
        <value>A &amp; U Stalker Telecommunications, Inc</value>
      </resourceProperty>
      <resourceProperty name="PROP_QUERY_DATA_ROW_COLUMN">
        <value>323-555-1226</value>
      </resourceProperty>
      <resourceProperty name="PROP_QUERY_DATA_ROW_COLUMN">
        <value>Mill Valley</value>
      </resourceProperty>
    </resourceProperty>
    <resourceProperty name="PROP_QUERY_DATA_ROW">
      <value>A &amp; X Caravello Engineering, Inc</value>
      <resourceProperty name="PROP_QUERY_DATA_ROW_COLUMN">
        <value>A &amp; X Caravello Engineering, Inc</value>
      </resourceProperty>
      <resourceProperty name="PROP_QUERY_DATA_ROW_COLUMN">
        <value>958-555-5890</value>
      </resourceProperty>
      <resourceProperty name="PROP_QUERY_DATA_ROW_COLUMN">
        <value>Tlaxiaco</value>
      </resourceProperty>
    </resourceProperty>
  </resourceProperty>
  <resourceDescriptor name="query" wsType="query" uriString="/MyInputControls/
    TEST_LIST_files/query" isNew="false">
    <label>query</label>
  <description>query</description>
  <resourceProperty name="PROP_RESOURCE_TYPE">
    <value>com.jaspersoft.jasperserver.api.metadata.common.domain.Query</value>
  </resourceProperty>
  <resourceProperty name="PROP_PARENT_FOLDER">
    <value>/MyInputControls/TEST_LIST_files</value>
  </resourceProperty>
  <resourceProperty name="PROP_VERSION">
    <value>1</value>
  </resourceProperty>
  <resourceProperty name="PROP_HAS_DATA">
    <value>false</value>
  </resourceProperty>
  <resourceProperty name="PROP_IS_REFERENCE">
    <value>false</value>
  </resourceProperty>
  <resourceProperty name="PROP_QUERY">
    <value>SELECT name, phone_office, billing_address_city FROM accounts order by 
      name</value>
  </resourceProperty>
  <resourceProperty name="PROP_QUERY_LANGUAGE">
    <value>sql</value>
  </resourceProperty>
    <resourceDescriptor name="" wsType="datasource" uriString="" isNew="false">
      <label>null</label>
      <resourceProperty name="PROP_REFERENCE_URI">
        <value>/datasources/JServerJdbcDS</value>
      </resourceProperty>
      <resourceProperty name="PROP_IS_REFERENCE">
        <value>true</value>
      </resourceProperty>
    </resourceDescriptor>
  </resourceDescriptor>
</resourceDescriptor>

The query result is a set of rows that represents the full set of possible values for the input control. For each row, the repository web service returns the value that runReport expects for that particular option in the input control. Each row also includes the column values that should be displayed in the input control when prompting users.

Query Results

This figure shows input controls based on queries, as they are rendered by the iReport Designer plugin for JasperReports Server. When the web services run report units, the rendering of input controls is left to the client application. The best way to proceed is:

Get the report unit.
Check for query-based input controls by looking at the PROP_INPUTCONTROL_TYPE resource property or each child resource descriptor where wsType is equal to inputControl.
Get each query-based input control by setting the IC_GET_QUERY_DATA argument to true.
Render the input controls (if used in the report unit), being mindful of the input control properties (such as read only and mandatory).
Call the runReport service and pass the user-selected values.

The rows are stored in the PROP_QUERY_DATA resource property: for each row, a child resource property named PROP_QUERY_DATA_ROW contains the value and a set of children that contain the column values; these last resource properties are named PROP_QUERY_DATA_ROW_COLUMN.

The following schema may elucidate the whole data structure:

PROP_QUERY_DATA
  (
  PROP_QUERY_DATA_ROW, value
    (
    PROP_QUERY_DATA_ROW_COLUMN, value
    PROP_QUERY_DATA_ROW_COLUMN, value
    ... 
    )
  PROP_QUERY_DATA_ROW, value
    (
    PROP_QUERY_DATA_ROW_COLUMN, value
    PROP_QUERY_DATA_ROW_COLUMN, value
    ... 
    )
  PROP_QUERY_DATA_ROW, value
    (
    PROP_QUERY_DATA_ROW_COLUMN, value
    PROP_QUERY_DATA_ROW_COLUMN, value
    ... 
    )
  )

In Java, to simplify response processing, the resourceDescriptor class provides the getQueryData() method that returns a list of InputControlQueryDataRow, which is a convenient class containing all the row information (row and column values).

Version: 
Feedback
randomness