Package org.mapfish.print.processor
Class PdfConfigurationProcessor
java.lang.Object
org.mapfish.print.processor.AbstractProcessor<PdfConfigurationProcessor.In,Void>
org.mapfish.print.processor.PdfConfigurationProcessor
- All Implemented Interfaces:
ConfigurationObject
,Processor<PdfConfigurationProcessor.In,
Void>
public final class PdfConfigurationProcessor
extends AbstractProcessor<PdfConfigurationProcessor.In,Void>
This processor allows the dynamic configuration of the
PDFConfig
object by obtaining data from attributes. For example the title and author could be string
attributes posted from the client, this processor would update the PDFConfig
object with the attribute data allowing per report PDF
metadata.
Note: The PDFConfig
can also be configured in the config.yaml
either at the config or template level.
See also: !updatePdfConfigUpdate attribute [[examples=updatePdfMetadata]]
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The input parameters object.static final class
The object that defines how to update thePDFConfig
(see !updatePdfConfig processor).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.Perform the process on the input attributes.protected void
extraValidation
(List<Throwable> validationErrors, Configuration configuration) Perform any extra validation a subclass may need to perform.void
setUpdates
(Map<String, Object> updates) The pdf metadata property -> attribute name map.Methods inherited from class org.mapfish.print.processor.AbstractProcessor
getInputMapperBiMap, getInputPrefix, getOutputMapperBiMap, getOutputPrefix, getOutputType, setInputMapper, setInputPrefix, setOutputMapper, setOutputPrefix, setPrefix, toString, toString, validate
-
Constructor Details
-
PdfConfigurationProcessor
public PdfConfigurationProcessor()Constructor.
-
-
Method Details
-
setUpdates
The pdf metadata property -> attribute name map. The keys must be one of the values inPDFConfig
and the values must be the name of the attribute to obtain the the data from. Example Configuration:
The type of the attribute must be of the correct type, for example title mus be a string, keywords must be an array of strings, compress must be a boolean.processors: - !updatePdfConfig updates: title: "titleAttribute" subject: "subjectAttribute"
If the value is within the attribute output object then you can use dot separators for each level. For example suppose there is a custom attribute: myconfig, if and it has a property title then the configuration would be:
For more power a "format" can be defined. The format is a printf style format string which will be called with a single value that is identified by the value key/path. In this case the short hand key: value can't be used instead it is as follows:processors: - updatePdfConfig updates: {title: :myconfig.title"}
- updatePdfConfig updates: title: !updatePdfConfigUpdate valueKey: "myconfig.title" format: "Print Report %s"
- Parameters:
updates
- the attribute map
-
extraValidation
Description copied from class:AbstractProcessor
Perform any extra validation a subclass may need to perform.- Specified by:
extraValidation
in classAbstractProcessor<PdfConfigurationProcessor.In,
Void> - Parameters:
validationErrors
- a list to add errors to so that all validation errors are reported as one.configuration
- 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.
-
execute
Description copied from interface:Processor
Perform the process on the input attributes.- Parameters:
in
- 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.
-