Skip to content

Commit f5a70a7

Browse files
author
TanyaEf
committed
Updated InputControlsValuesAdapter, updated Readme.md
1 parent 33830ad commit f5a70a7

File tree

2 files changed

+93
-40
lines changed

2 files changed

+93
-40
lines changed

README.md

Lines changed: 81 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ Table of Contents
2929
* [Polling Export Execution](#polling-export-execution).
3030
* [Finding Running Reports and Jobs](#finding-running-reports-and-jobs).
3131
* [Stopping Running Reports and Jobs](#stopping-running-reports-and-jobs).
32-
5. [Report Parameters services](#report-parameters-services).
33-
* [Listing Report Parameters Structure](#listing-report-parameters-structure).
34-
* [Listing Report Parameter Values](#listing-report-parameter-values).
35-
* [Setting Report Parameter Values](#setting-report-parameter-values).
32+
5. [Input controls service](#input-controls-service).
33+
* [Listing input controls structure](#listing-input-controls-structure).
34+
* [Reordering input controls structure](#reordering-input-controls-structure).
35+
* [Listing input controls values](#listing-input-controls-values).
36+
* [Setting input controls values](#setting-input-controls-values).
3637
6. [Administration services](#administration-services).
3738
1. [Organizations service](#organizations-service).
3839
* [Searching for Organizations](#searching-for-organizations).
@@ -464,50 +465,94 @@ OperationResult<ReportExecutionStatusEntity> operationResult1 =
464465

465466
ReportExecutionStatusEntity statusEntity = operationResult1.getEntity();
466467
```
467-
###Report Parameters services:
468-
The reports service includes methods for reading and setting report parameters.
468+
469+
###Input controls service:
470+
The reports service includes methods for reading and setting input controls of any input controls container, i.e. reportUnit, reportOptions, dashboard, adhocDataView
469471
####Listing Report Parameters Structure
470-
The following code returns a description of the structure of the report parameters for a given report.
472+
The following code returns a description of the structure of the input controls for a given container.
471473
```java
472-
ReportInputControlsListWrapper inputControls =
473-
client.authenticate("jasperadmin", "jasperadmin")
474-
.reportingService()
475-
.report("/reports/samples/Cascading_multi_select_report")
476-
.reportParameters()
477-
.get()
478-
.getEntity();
474+
OperationResult<ReportInputControlsListWrapper> operationResult = session
475+
.inputControlsService()
476+
.inputControls()
477+
.container("/reports/samples/Cascading_multi_select_report")
478+
.get();
479+
ReportInputControlsListWrapper result = operationResult.getEntity();
479480
```
480-
The response contains the structure of the report parameters for the report. It contains the information needed by your application to display the report parameters to your users and allow them to make a selection. In particular, this includes any cascading structure as a set of dependencies between report parameters. Each report parameter also has a type that indicates how the user should be allowed to make a choice: bool, singleSelect, singleSelectRadio, multiSelectCheckbox, multiSelect, singleValue, singleValueText, singleValueNumber, singleValueDate, singleValueDatetime, singleValueTime.
481-
The structure includes a set of validation rules for each report parameter. These rules indicate what type of validation your client should perform on report parameter values it receives from your users, and if the validation fails, the message to display. Depending on the type of the report parameter, the following validations are possible:
481+
The response contains the structure of the input controls for the container. It contains the information needed by your application to display the report parameters to your users and allow them to make a selection. In particular, this includes any cascading structure as a set of dependencies between container parameters. Each input control also has a type that indicates how the user should be allowed to make a choice: `bool, singleSelect, singleSelectRadio, multiSelectCheckbox, multiSelect, singleValue, singleValueText, singleValueNumber, singleValueDate, singleValueDatetime, singleValueTime`.
482+
The structure includes a set of validation rules for each report parameter. These rules indicate what type of validation your client should perform on input control values it receives from your users, and if the validation fails, the message to display. Depending on the type of the report parameter, the following validations are possible:
482483
* mandatoryValidationRule – This input is required and your client should ensure the user enters a value.
483484
* dateTimeFormatValidation – This input must have a data time format and your client should ensure the user enters a valid date and time.
484-
485-
####Listing Report Parameter Values
485+
To skip input controls state generation use `excludeState(true)` setting:
486+
```java
487+
OperationResult<ReportInputControlsListWrapper> operationResult = session
488+
.inputControlsService()
489+
.inputControls()
490+
.container("/reports/samples/Cascading_multi_select_report")
491+
.excludeState(true)
492+
.get();
493+
ReportInputControlsListWrapper result = operationResult.getEntity();
494+
```
495+
####Reordering input controls structure
496+
You can change structure of input controls according to client demands using the next code:
497+
```java
498+
OperationResult<ReportInputControlsListWrapper> reorderedOperationResult = session
499+
.inputControlsService()
500+
.inputControls()
501+
.container("/reports/samples/Cascading_multi_select_report")
502+
.reorder(inputParameters);
503+
```
504+
It is impossible to change input controls except change of theirs order. Sent to server structure MUST be the same as it received
505+
from there, except order.
506+
You cannot modify some values, add or remove control, etc.
507+
####Listing input controls values
486508
The following code returns a description of the possible values of all report parameters for the report. Among these choices, it shows which ones are selected.
487509
```java
488-
InputControlStateListWrapper inputControlsValues =
489-
client.authenticate("jasperadmin", "jasperadmin")
490-
.reportingService()
491-
.report("/reports/samples/Cascading_multi_select_report")
492-
.reportParameters()
510+
OperationResult<InputControlStateListWrapper> operationResult = session
511+
.inputControlsService()
512+
.inputControls()
513+
.container("/reports/samples/Cascading_multi_select_report")
493514
.values()
494-
.get()
495-
.getEntity();
515+
.get();
516+
InputControlStateListWrapper result = operationResult.getEntity();
496517
```
497518
The response contains the structure of the report parameters for the report.
498-
If a selection-type report parameter has a null value, it is given as `~NULL~`. If no selection is made, its value is given as `~NOTHING~`.
499-
####Setting Report Parameter Values
500-
The following code updates the state of current report parameter values, so they are set for the next run of the report.
519+
If a selection-type report parameter has a null value, it is given as `NULL`. If no selection is made, its value is given as `NOTHING`.
520+
Use setting `useCashedData(false)` to avoid getting cashed data:
501521
```java
502-
InputControlStateListWrapper inputControlsValues =
503-
client.authenticate("jasperadmin", "jasperadmin")
504-
.reportingService()
505-
.report("/reports/samples/Cascading_multi_select_report")
506-
.reportParameters()
522+
OperationResult<InputControlStateListWrapper> operationResult = session
523+
.inputControlsService()
524+
.inputControls()
525+
.container("/reports/samples/Cascading_multi_select_report")
507526
.values()
508-
.parameter("Cascading_name_single_select", "A & U Stalker Telecommunications, Inc")
509-
.update()
510-
.getEntity();
527+
.useCashedData(false)
528+
.get();
529+
InputControlStateListWrapper result = operationResult.getEntity();
530+
```
531+
####Setting input controls values
532+
The following code updates the state of specified input controls values, so they are set for the next run of the report.
533+
```java
534+
OperationResult<InputControlStateListWrapper> operationResult = session
535+
.inputControlsService()
536+
.inputControls()
537+
.container("/reports/samples/Cascading_multi_select_report")
538+
.values()
539+
.parameter("Country_multi_select", "Mexico")
540+
.parameter("Cascading_state_multi_select", "Guerrero", "Sinaloa")
541+
.run();
542+
InputControlStateListWrapper result = operationResult.getEntity();
543+
```
544+
In response you get updated values for specified input controls. If you want to get updated values with full structure of input controls, you should use `includeFullStructure(true)` setting:
545+
```java
546+
OperationResult<InputControlStateListWrapper> operationResult = session
547+
.inputControlsService()
548+
.inputControls()
549+
.container("/reports/samples/Cascading_multi_select_report")
550+
.values()
551+
.parameter("Country_multi_select", "USA")
552+
.parameter("Cascading_state_multi_select", "CA", "OR", "WA")
553+
.includeFullStructure(true)
554+
.run();
555+
InputControlStateListWrapper result = operationResult.getEntity();
511556
```
512557
Administration services:
513558
========================

src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/inputControls/InputControlsValuesAdapter.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class InputControlsValuesAdapter extends AbstractAdapter{
2121

2222
private String containerUri;
2323
private Boolean useFreshData = false;
24+
private Boolean includeFullStructure = false;
2425
private MultivaluedHashMap<String, String> inputControlsValues = new MultivaluedHashMap<String, String>();
2526
private StringBuilder ids = new StringBuilder("");
2627

@@ -34,6 +35,11 @@ public InputControlsValuesAdapter useCashedData(Boolean value) {
3435
return this;
3536
}
3637

38+
public InputControlsValuesAdapter includeFullStructure(Boolean value) {
39+
includeFullStructure = value;
40+
return this;
41+
}
42+
3743
public InputControlsValuesAdapter parameter(String name, String value) {
3844
this.inputControlsValues.add(name, value);
3945
return this;
@@ -48,10 +54,12 @@ public OperationResult<InputControlStateListWrapper> run() {
4854
if (inputControlsValues.size() == 0) {
4955
throw new MandatoryParameterNotFoundException();
5056
}
51-
ids.append("/");
52-
Set<String> keySet = inputControlsValues.keySet();
53-
String[] idsArray = keySet.toArray(new String[keySet.size()]);
54-
ids.append(StringUtils.join(idsArray, ";"));
57+
if (!includeFullStructure) {
58+
ids.append("/");
59+
Set<String> keySet = inputControlsValues.keySet();
60+
String[] idsArray = keySet.toArray(new String[keySet.size()]);
61+
ids.append(StringUtils.join(idsArray, ";"));
62+
}
5563
return buildRequest().post(valuesToArrays());
5664
}
5765

0 commit comments

Comments
 (0)