public final class MergeDataSourceProcessor extends AbstractProcessor<MergeDataSourceProcessor.In,MergeDataSourceProcessor.Out> implements CustomDependencies
This processor combines DataSources and individual processor outputs (or attribute values) into a single DataSource which can be used in a jasper report's detail section.
An example use case is where we might have zero or many of tables and zero or many legends. You can configure the template with a detail section that contains a subreport, the name of which is a field in the DataSources and the DataSources for the sub-template another field. Then you can merge the legend and the tables into a single DataSources. This way the report will nicely expand depending on if you have a legend and how many tables you have in your report.
[[examples=merged_datasource]]| Modifier and Type | Class and Description |
|---|---|
static class |
MergeDataSourceProcessor.In
The input object for
MergeDataSourceProcessor. |
static class |
MergeDataSourceProcessor.Out
The output object for
MergeDataSourceProcessor. |
static class |
MergeDataSourceProcessor.Source
Describes the objects used as sources for a merged data source
(see !mergeDataSources processor).
|
static class |
MergeDataSourceProcessor.SourceType
An enumeration of the different types of source objects.
|
AbstractProcessor.ContextProcessor.ExecutionContextMDC_JOB_ID_KEY| Modifier | Constructor and Description |
|---|---|
protected |
MergeDataSourceProcessor()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
MergeDataSourceProcessor.In |
createInputParameter()
Returns a new/clean instance of a parameter object.
|
MergeDataSourceProcessor.Out |
execute(MergeDataSourceProcessor.In values,
Processor.ExecutionContext context)
Perform the process on the input attributes.
|
protected void |
extraValidation(java.util.List<java.lang.Throwable> validationErrors,
Configuration config)
Perform any extra validation a subclass may need to perform.
|
java.util.Collection<java.lang.String> |
getDependencies()
Get what we dynamically depends on, for the "values" input.
|
void |
setSources(java.util.List<MergeDataSourceProcessor.Source> sources)
The source to add to the merged DataSource.
|
getInputMapperBiMap, getInputPrefix, getOutputMapperBiMap, getOutputPrefix, getOutputType, setInputMapper, setInputPrefix, setOutputMapper, setOutputPrefix, setPrefix, toString, toString, validatepublic void setSources(java.util.List<MergeDataSourceProcessor.Source> sources)
The source to add to the merged DataSource.
Each source indicates if it should be treated
as a datasource or as a single item to add to the merged DataSource. If the source indicates that it is
a MergeDataSourceProcessor.SourceType.DATASOURCE the object
each row in the datasource will be used to form a row in the merged DataSource. If the source type is
MergeDataSourceProcessor.SourceType.SINGLE the object will
be a single row even if it is in fact a DataSource.
See also: !mergeSource
sources - the source objects to mergeprotected void extraValidation(java.util.List<java.lang.Throwable> validationErrors,
Configuration config)
AbstractProcessorextraValidation in class AbstractProcessor<MergeDataSourceProcessor.In,MergeDataSourceProcessor.Out>validationErrors - a list to add errors to so that all validation errors are reported as
one.config - the containing configuration@Nullable public MergeDataSourceProcessor.In createInputParameter()
ProcessorValues object.
The way the properties will be looked up is to
Values object using the mapped
property name
HasDefaultValue annotation is on the field for
the property.
createInputParameter in interface Processor<MergeDataSourceProcessor.In,MergeDataSourceProcessor.Out>@Nullable public MergeDataSourceProcessor.Out execute(MergeDataSourceProcessor.In values, Processor.ExecutionContext context) throws java.lang.Exception
Processorexecute in interface Processor<MergeDataSourceProcessor.In,MergeDataSourceProcessor.Out>values - A Java object whose public fields are populated from the Values object (which is used for transferring properties between
processors).context - The execution context for a print task.Values object. The key in the
Values
object is the name of the field or if there is a mapping in the Processor.getOutputMapperBiMap()
map, the mapped name. The key is determined in a similar way as for the input object.java.lang.Exception@Nonnull public java.util.Collection<java.lang.String> getDependencies()
CustomDependenciesgetDependencies in interface CustomDependencies