View Javadoc
1   package fr.tiogars.inception.domains.domaintemplate.services;
2   
3   import java.io.IOException;
4   
5   import org.springframework.stereotype.Service;
6   import org.springframework.transaction.annotation.Transactional;
7   
8   /** Generates a printable PDF for all active DomainTemplates. */
9   @Service
10  public class DomainTemplatesPrintAllService {
11  
12      private final DomainTemplateFindAllService findAllService;
13      private final DomainTemplatePdfRenderer renderer;
14  
15      public DomainTemplatesPrintAllService(DomainTemplateFindAllService findAllService, DomainTemplatePdfRenderer renderer) {
16          this.findAllService = findAllService;
17          this.renderer = renderer;
18      }
19  
20      /**
21       * Prints all active records ordered by code.
22       *
23       * @return PDF bytes, including an empty-list message when there are no records
24       * @throws IOException when the PDF cannot be generated
25       */
26      @Transactional(readOnly = true)
27      public byte[] printAll() throws IOException {
28          return renderer.render("DomainTemplates", findAllService.findAll());
29      }
30  }