Class PrintTemplateUtil
java.lang.Object
com.ssgllc.fish.service.util.published.PrintTemplateUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.ssgllc.fish.document.GeneratedDocgenerateDocument(String printTemplateName, String entityId, Map<String, Object> formData, String taskInstanceId, String type, Instant asOfDate) Generates a document based on the specified print template, entity data, and other parameters.static com.ssgllc.fish.document.GeneratedDocgenerateDocumentWithDataSource(String printTemplateName, String entityId, Map<String, Object> formData, String taskInstanceId, Instant asOfDate, List<?> dataSource) Generate a document from a Jasper template while passing it a specific "data source".
-
Constructor Details
-
PrintTemplateUtil
public PrintTemplateUtil()
-
-
Method Details
-
generateDocument
public static com.ssgllc.fish.document.GeneratedDoc generateDocument(String printTemplateName, String entityId, Map<String, Object> formData, String taskInstanceId, String type, Instant asOfDate) throws ExceptionGenerates a document based on the specified print template, entity data, and other parameters. Note that the entity and field permissions are not checked for the current user and the document is generated with super user permissions
Example:
def formData = [field1: "value1", field2: "value2"]
def doc = printTemplateUtil.generateDocument("PersonTemplate", "c0a83801-655d-13e2-8191-9067f826208c", [:], null, "docx", dateUtil.startOfToday())
return bpmUtil.createProcessDocFromGeneratedDoc(doc, execution.processInstanceId)
Returns:
A generated DOCX document based on the "PersonTemplate" for the entity with the specified id.- Parameters:
printTemplateName- The name of the print template to be used.entityId- The ID of the entity for which the document is generated.formData- A map of form data used as input for the print template.taskInstanceId- The ID of the task instance associated with the document generation.type- The type of document to generate ("pdf", "docx", or "report").asOfDate- The date for fetching entity data as of a particular moment in time, if applicable.- Returns:
- A
GeneratedDocobject containing the generated document, ornullif the document could not be generated. - Throws:
NoSuchMethodException- If a required method for document generation is not found.IOException- If an I/O error occurs during document generation.Exception
-
generateDocumentWithDataSource
public static com.ssgllc.fish.document.GeneratedDoc generateDocumentWithDataSource(String printTemplateName, String entityId, Map<String, Object> formData, String taskInstanceId, Instant asOfDate, List<?> dataSource) throws ExceptionGenerate a document from a Jasper template while passing it a specific "data source". Since only Jasper templates supportdataSource,typeis assumed to be "report". For general documentation, seegenerateDocument(java.lang.String, java.lang.String, java.util.Map<java.lang.String, java.lang.Object>, java.lang.String, java.lang.String, java.time.Instant).
dataSourcecan be in one of 3 formats:-
A list of maps, as in
[[firstName: "John", lastName: "Doe"], [firstName: "Jane", lastName: "Doe"]]. Each map is a "row" of data and their keys are "columns". Because of this, all maps must have the same keys. - A list of entities. Each entity must be the same type. Remember to define fields in the Jasper template corresponding to the entities' fields.
- A list of arrays. The list items must be arrays, not lists. The first array consists of strings that name the "columns" used by all the other arrays. The other arrays are the "rows", and can contain any type. All arrays must be the same length.
- Parameters:
printTemplateName- The name of the print template to be used.entityId- The ID of the entity for which the document is generated.formData- A map of form data used as input for the print template.taskInstanceId- The ID of the task instance associated with the document generation.asOfDate- The date for fetching entity data as of a particular moment in time, if applicable.dataSource- The primary data source given to Jasper when generating the document.- Returns:
- Throws:
Exception
-
A list of maps, as in
-