Document Data Snapshot
Overview
The Document Data Snapshot Plugin will assemble the metadata for a document, including the renderingData
for dynamic documents.
After the results of this plugin call are persisted, the document will be in the dataReady
state.
The plugin is executed asynchronously with any client request.
Example
The following example adds metadata to be made available to a document template rendered for a quote transaction:
public class DataSnapshotPluginImpl implements DocumentDataSnapshotPlugin {
@Override
public DocumentDataSnapshot dataSnapshot(DamageProtectionQuoteRequest damageProtectionQuoteRequest) {
var quote = damageProtectionQuoteRequest.quote();
var myMeta = new HashMap<String, String>();
myMeta.put("specialKey", "specialValue");
return DocumentDataSnapshot.builder().metadata(myMeta).renderingData(quote).build();
}
}
Since metadata is optional, the specialKey
value would be fetched like this in a Velocity template:
$metadata.get().get("specialKey")
Note that the quote
is passed as an argument to renderingData
in the return
statement, ensuring that the standard rendering data is passed along to the template for this type of request. If you are using the Data Snapshot Plugin for a request, you must ensure that the method returns all the data that your template requires.