Class DataSourceAttribute
- All Implemented Interfaces:
Attribute
,ConfigurationObject
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]]-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the attributes.Get the attribute value.Get the class of the value.parseAttribute
(Template template, PArray jsonValue) 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
(Map<String, Attribute> attributes) The attributes that are acceptable by this dataSource.void
setConfigName
(String name) Set the name of the attribute as set in the configuration file.void
setDefault
(List<Object> defaultData) Default values for this attribute.void
validate
(List<Throwable> validationErrors, Configuration configuration) validate that the configuration was correct.
-
Constructor Details
-
DataSourceAttribute
public DataSourceAttribute()
-
-
Method Details
-
setDefault
Default values for this attribute. Example:attributes: datasource: !datasource attributes: name: !string {} count: !integer {} default: - name: "name" - count: 3
- Parameters:
defaultData
- The default values.
-
getAttributes
Gets the attributes.- Returns:
- the attributes
-
setAttributes
The attributes that are acceptable by this dataSource. The format is the same as the template attributes section.- Parameters:
attributes
- the attributes
-
printClientConfig
public void printClientConfig(org.json.JSONWriter json, Template template) throws org.json.JSONException Description copied from interface:Attribute
Write this attribute out the the json writer so that clients can know what attributes are expected.- Specified by:
printClientConfig
in interfaceAttribute
- Parameters:
json
- the json writer to write totemplate
- the template that this attribute is part of- Throws:
org.json.JSONException
-
setConfigName
Description copied from interface:Attribute
Set the name of the attribute as set in the configuration file.- Specified by:
setConfigName
in interfaceAttribute
- Parameters:
name
- the name of the attribute
-
validate
Description copied from interface:ConfigurationObject
validate that the configuration was correct.- Specified by:
validate
in interfaceConfigurationObject
- Parameters:
validationErrors
- a list to add any detected errors to.configuration
- the containing configuration
-
parseAttribute
public DataSourceAttribute.DataSourceAttributeValue parseAttribute(@Nonnull Template template, @Nullable PArray jsonValue) throws org.json.JSONException - Parameters:
template
- the containing templatejsonValue
- the json- Throws:
org.json.JSONException
-
getValueType
Description copied from interface:Attribute
Get the class of the value.- Specified by:
getValueType
in interfaceAttribute
- Returns:
- the value class
-
getValue
public Object getValue(@Nonnull Template template, @Nonnull String attributeName, @Nonnull PObject requestJsonAttributes) Description copied from interface:Attribute
Get the attribute value.
-