Class ReportImportExportImpl

java.lang.Object
io.jmix.reports.impl.ReportImportExportImpl
All Implemented Interfaces:
ReportImportExport

@Component("report_ReportImportExport") public class ReportImportExportImpl extends Object implements ReportImportExport
  • Field Details

  • Constructor Details

    • ReportImportExportImpl

      public ReportImportExportImpl()
  • Method Details

    • exportReports

      public byte[] exportReports(Collection<Report> reports)
      Description copied from interface: ReportImportExport
      Exports all reports and their templates into one zip archive. Each report is exported into a separate zip archive with 2 files (report.xml and a template file (for example MyReport.doc)). For example: return byte[] (bytes of zip arhive) -- MegaReport.zip ---- report.xml ---- Mega report.xls -- Other report.zip ---- report.xml ---- other report.odt
      Specified by:
      exportReports in interface ReportImportExport
      Parameters:
      reports - Collection of Report objects to be exported.
      Returns:
      ZIP byte array with zip archives inside.
    • importReports

      public Collection<Report> importReports(byte[] zipBytes)
      Description copied from interface: ReportImportExport
      Imports reports from ZIP archive. Archive file format is described in exportReports method.
      Specified by:
      importReports in interface ReportImportExport
      Parameters:
      zipBytes - ZIP archive as a byte array.
      Returns:
      Collection of imported reports.
    • importReports

      public Collection<Report> importReports(byte[] zipBytes, @Nullable EnumSet<ReportImportOption> importOptions)
      Description copied from interface: ReportImportExport
      Imports reports from ZIP archive. Archive file format is described in exportReports method.
      Specified by:
      importReports in interface ReportImportExport
      Parameters:
      zipBytes - ZIP archive as a byte array.
      importOptions - - report import options
      Returns:
      Collection of imported reports.
    • importReportsWithResult

      public ReportImportResult importReportsWithResult(byte[] zipBytes, @Nullable EnumSet<ReportImportOption> importOptions)
      Description copied from interface: ReportImportExport
      Imports reports from ZIP archive. Archive file format is described in exportReports method.
      Specified by:
      importReportsWithResult in interface ReportImportExport
      Parameters:
      zipBytes - ZIP archive as a byte array.
      importOptions - report - import options
      Returns:
      import result - collection of updated, created reports
    • importReportsFromPath

      public Collection<Report> importReportsFromPath(String path) throws IOException
      Description copied from interface: ReportImportExport
      Import all reports from the specified folder. Folder should have the following structure, in other cases RuntimeException will be thrown

      folder sub-folder1 report.structure template.doc sub-folder2 report.structure template.docx

      Specified by:
      importReportsFromPath in interface ReportImportExport
      Parameters:
      path - to folder with reports
      Returns:
      collection of imported reports
      Throws:
      IOException - if any I/O error occurs
    • exportReport

      protected byte[] exportReport(Report report) throws IOException
      Exports single report to ZIP archive with name <report name>.zip. There are 2 files in archive: report.structure and a template file (odt, xls or other..)
      Parameters:
      report - Report object that must be exported.
      Returns:
      ZIP archive as a byte array.
      Throws:
      IOException - if any I/O error occurs
    • importReport

      protected void importReport(byte[] zipBytes, @Nullable EnumSet<ReportImportOption> importOptions, ReportImportResult importResult) throws IOException
      Throws:
      IOException
    • fromByteArray

      @Nullable protected Report fromByteArray(byte[] zipBytes) throws IOException
      Throws:
      IOException
    • updateReportTemplate

      protected void updateReportTemplate(Report report, byte[] zipBytes) throws IOException
      Throws:
      IOException
    • withReportOptions

      protected void withReportOptions(Report report, @Nullable EnumSet<ReportImportOption> importOptions)
    • zipSingleReportFiles

      protected byte[] zipSingleReportFiles(File[] files) throws IOException
      Throws:
      IOException
    • zipContent

      protected byte[] zipContent(Map<String,Object> stringObjectMap) throws IOException
      Throws:
      IOException
    • newStoredEntry

      protected org.apache.commons.compress.archivers.ArchiveEntry newStoredEntry(String name, byte[] data)
    • replaceForbiddenCharacters

      protected String replaceForbiddenCharacters(String fileName)
    • readBytesFromEntry

      protected byte[] readBytesFromEntry(org.apache.commons.compress.archivers.zip.ZipArchiveInputStream archiveReader) throws IOException
      Throws:
      IOException
    • reloadReport

      @Nullable protected Report reloadReport(Report report)
    • isReportsStructureFile

      protected boolean isReportsStructureFile(String name)