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 classThe input object forMergeDataSourceProcessor.static final recordThe output object forMergeDataSourceProcessor.static final classDescribes the objects used as sources for a merged data source (see !mergeDataSources processor).static enumAn enumeration of the different types of source objects.Nested classes/interfaces inherited from class org.mapfish.print.processor.AbstractProcessor
AbstractProcessor.ContextNested 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 -
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 voidextraValidation(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.voidsetSources(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
-
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.DATASOURCEthe object each row in the datasource will be used to form a row in the merged DataSource. If the source type isMergeDataSourceProcessor.SourceType.SINGLEthe 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:AbstractProcessorPerform any extra validation a subclass may need to perform.- Specified by:
extraValidationin 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:ProcessorReturns 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 theValuesobject.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
Valuesobject 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
HasDefaultValueannotation 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:
createInputParameterin interfaceProcessor<MergeDataSourceProcessor.In,MergeDataSourceProcessor.Out>
-
execute
@Nullable public MergeDataSourceProcessor.Out execute(MergeDataSourceProcessor.In values, Processor.ExecutionContext context) throws Exception Description copied from interface:ProcessorPerform the process on the input attributes.- Specified by:
executein interfaceProcessor<MergeDataSourceProcessor.In,MergeDataSourceProcessor.Out> - Parameters:
values- A Java object whose public fields are populated from theValuesobject (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
Valuesobject. The key in theValuesobject 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:CustomDependenciesGet what we dynamically depends on, for the "values" input.- Specified by:
getDependenciesin interfaceCustomDependencies
-