Class MergeDataSourceProcessor
- All Implemented Interfaces:
ConfigurationObject
,CustomDependencies
,Processor<MergeDataSourceProcessor.In,
MergeDataSourceProcessor.Out>
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]]
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The input object forMergeDataSourceProcessor
.static class
The output object forMergeDataSourceProcessor
.static final class
Describes the objects used as sources for a merged data source (see !mergeDataSources processor).static enum
An enumeration of the different types of source objects.Nested classes/interfaces inherited from class org.mapfish.print.processor.AbstractProcessor
AbstractProcessor.Context
Nested classes/interfaces inherited from interface org.mapfish.print.processor.Processor
Processor.ExecutionContext
-
Field Summary
Fields inherited from interface org.mapfish.print.processor.Processor
MDC_APPLICATION_ID_KEY, MDC_JOB_ID_KEY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a new/clean instance of a parameter object.execute
(MergeDataSourceProcessor.In values, Processor.ExecutionContext context) Perform the process on the input attributes.protected void
extraValidation
(List<Throwable> validationErrors, Configuration config) Perform any extra validation a subclass may need to perform.Get what we dynamically depends on, for the "values" input.void
setSources
(List<MergeDataSourceProcessor.Source> sources) The source to add to the merged DataSource.Methods inherited from class org.mapfish.print.processor.AbstractProcessor
getInputMapperBiMap, getInputPrefix, getOutputMapperBiMap, getOutputPrefix, getOutputType, setInputMapper, setInputPrefix, setOutputMapper, setOutputPrefix, setPrefix, toString, toString, validate
-
Constructor Details
-
MergeDataSourceProcessor
protected MergeDataSourceProcessor()Constructor.
-
-
Method Details
-
setSources
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 isMergeDataSourceProcessor.SourceType.SINGLE
the object will be a single row even if it is in fact a DataSource.See also: !mergeSource
- Parameters:
sources
- the source objects to merge
-
extraValidation
Description copied from class:AbstractProcessor
Perform any extra validation a subclass may need to perform.- Specified by:
extraValidation
in classAbstractProcessor<MergeDataSourceProcessor.In,
MergeDataSourceProcessor.Out> - Parameters:
validationErrors
- a list to add errors to so that all validation errors are reported as one.config
- the containing configuration
-
createInputParameter
Description copied from interface:Processor
Returns a new/clean instance of a parameter object. This instance's will be inspected using reflection to find its public fields and the properties will be set from theValues
object.The way the properties will be looked up is to
- take the bean property name
- map it using the input mapper, (if the input mapper does not have a mapping for the property then the unmapped property name is used)
- Look up the property value in the
Values
object using the mapped property name - set the value on the instance created by this method. If the value is null an exception
will be thrown UNLESS the
HasDefaultValue
annotation is on the field for the property.
It is important to realize that super classes will also be analyzed, so care must be had with inheritance.
- Specified by:
createInputParameter
in interfaceProcessor<MergeDataSourceProcessor.In,
MergeDataSourceProcessor.Out>
-
execute
@Nullable public MergeDataSourceProcessor.Out execute(MergeDataSourceProcessor.In values, Processor.ExecutionContext context) throws Exception Description copied from interface:Processor
Perform the process on the input attributes.- Specified by:
execute
in interfaceProcessor<MergeDataSourceProcessor.In,
MergeDataSourceProcessor.Out> - Parameters:
values
- A Java object whose public fields are populated from theValues
object (which is used for transferring properties between processors).context
- The execution context for a print task.- Returns:
- A Java object whose public fields will be put into the
Values
object. The key in theValues
object is the name of the field or if there is a mapping in theProcessor.getOutputMapperBiMap()
map, the mapped name. The key is determined in a similar way as for the input object. - Throws:
Exception
-
getDependencies
Description copied from interface:CustomDependencies
Get what we dynamically depends on, for the "values" input.- Specified by:
getDependencies
in interfaceCustomDependencies
-