public final class DataSourceAttribute extends java.lang.Object implements Attribute
This attribute represents a collection of attributes which can be used as the data source of a Jasper report's table/detail section.
For example consider the case where the report should contain multiple tables or charts but the number of reports
may change depending on the request. In this case the client will post a datasource attribute json object containing an array
of all the table attribute objects. The DataSourceProcessor will process
the datasource attribute and create a Jasper datasource that contains all the tables.
This datasource must be used in tandem with the DataSourceProcessor processor
(see !createDataSource processor).
The json data of this attribute is special since it represents an array of attributes, each element in the array must
contain all of the attributes required to satisfy the processors in the
DataSourceProcessor.
Example configuration:
datasource: !datasource
table: !table
map: !map
width: 200
height: 100
Example request data:
datasource: [
{
table: {
... // normal table attribute data
},
map: {
... // normal map attribute data
}
}, {
table: {
... // normal table attribute data
},
map: {
... // normal map attribute data
}
}
]
[[examples=verboseExample,datasource_dynamic_tables,datasource_many_dynamictables_legend,
datasource_multiple_maps,customDynamicReport,report]]| Modifier and Type | Class and Description |
|---|---|
static class |
DataSourceAttribute.DataSourceAttributeValue
The value class for the
DataSourceAttribute. |
| Constructor and Description |
|---|
DataSourceAttribute() |
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<java.lang.String,Attribute> |
getAttributes()
Gets the attributes.
|
java.lang.Class |
getValueType()
Get the class of the value.
|
DataSourceAttribute.DataSourceAttributeValue |
parseAttribute(MapfishParser parser,
Template template,
PArray jsonValue)
Parser the attributes into the value object.
|
void |
printClientConfig(org.json.JSONWriter json,
Template template)
Write this attribute out the the json writer so that clients can know what attributes are expected.
|
void |
setAttributes(java.util.Map<java.lang.String,Attribute> attributes)
The attributes that are acceptable by this dataSource.
|
void |
setConfigName(java.lang.String name)
Set the name of the attribute as set in the configuration file.
|
void |
setDefault(java.util.List<java.lang.Object> defaultData)
Default values for this attribute.
|
void |
validate(java.util.List<java.lang.Throwable> validationErrors,
Configuration configuration)
validate that the configuration was correct.
|
public void setDefault(java.util.List<java.lang.Object> defaultData)
Default values for this attribute. Example:
attributes:
datasource: !datasource
attributes:
name: !string {}
count: !integer {}
default:
- name: "name"
- count: 3defaultData - The default values.public void setAttributes(java.util.Map<java.lang.String,Attribute> attributes)
attributes - the attributespublic java.util.Map<java.lang.String,Attribute> getAttributes()
public void printClientConfig(org.json.JSONWriter json,
Template template)
throws org.json.JSONException
AttributeprintClientConfig in interface Attributejson - the json writer to write totemplate - the template that this attribute is part oforg.json.JSONExceptionpublic void setConfigName(java.lang.String name)
AttributesetConfigName in interface Attributename - the name of the attributepublic void validate(java.util.List<java.lang.Throwable> validationErrors,
Configuration configuration)
ConfigurationObjectvalidate in interface ConfigurationObjectvalidationErrors - a list to add any detected errors to.configuration - the containing configurationpublic DataSourceAttribute.DataSourceAttributeValue parseAttribute(@Nonnull MapfishParser parser, @Nonnull Template template, @Nullable PArray jsonValue) throws org.json.JSONException
parser - the parsertemplate - the containing templatejsonValue - the jsonorg.json.JSONExceptionpublic java.lang.Class getValueType()
AttributegetValueType in interface Attribute