Document merging service for report combination¶
The Document merging service is a specialized component within the report generation system designed to combine multiple individual report files into a single downloadable document^[001-todo-code-copy.md]. This process is primarily utilized to aggregate results that have been generated separately but need to be presented as a unified file^[001-todo-code-copy.md].
Implementation¶
The merging logic is handled by implementations of the ReportDocumentService interface^[001-todo-code-copy.md]. Currently, the system provides specific handling for different document types:
- CSV Combination: The
CSVDocumentServiceImplhandles the merging of Comma-Separated Values files^[001-todo-code-copy.md]. ItscombineDocumentmethod accepts a list of byte arrays (representing the file contents)1, strips the header row from subsequent documents to prevent duplication, and joins the data using the system's line separator^[001-todo-code-copy.md]. - PDF Handling: The system currently supports a placeholder for PDF generation and merging (
PDFDocumentServiceImpl), but the actual functionality throws anUnsupportedOperationExceptionstating it is not yet supported^[001-todo-code-copy.md].
Workflow Integration¶
The merging process is triggered asynchronously via a Message queue listener. The system uses a specific listener method, handleCombineDocument, which consumes messages from the COMBINE_FILE_Q (Combine File Queue)2[001-todo-code-copy.md]. Upon receiving a ReportDocumentCombineVo payload, which contains the target ID and document type, the service invokes the domain layer to execute the combination logic^[001-todo-code-copy.md].
Data Flow¶
- Trigger: A request to combine documents is sent to the
plt.basic.report.combine.file.exexchange, routing it to theCOMBINE_FILE_Q^[001-todo-code-copy.md]. - Processing: The
ReportListenerpicks up the message and callsreportDomainService.makeCombineDocument^[001-todo-code-copy.md]. - Execution: The domain service orchestrates the retrieval of existing documents (likely stored in a file system or blob storage as implied by
GcsFileManageServiceImpl^[001-todo-code-copy.md]) and passes their byte content to the appropriateReportDocumentServiceimplementation. - Output: The combined byte array is returned, which is then typically stored or returned to the user as a single file.
Related Concepts¶
- [[Asynchronous processing]]
- [[Report generation workflow]]
- [[File storage abstraction]]
Sources¶
^[001-todo-code-copy.md]