Package io.jmix.reports.impl
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 Summary
Modifier and TypeFieldDescriptionprotected DataManager
static final String
protected Metadata
protected ReportsPersistence
protected ReportsSerialization
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]
exportReport
(Report report) Exports single report to ZIP archive with name<report name>.zip
.byte[]
exportReports
(Collection<Report> reports) Exports all reports and their templates into one zip archive.protected Report
fromByteArray
(byte[] zipBytes) protected void
importReport
(byte[] zipBytes, EnumSet<ReportImportOption> importOptions, ReportImportResult importResult) importReports
(byte[] zipBytes) Imports reports from ZIP archive.importReports
(byte[] zipBytes, EnumSet<ReportImportOption> importOptions) Imports reports from ZIP archive.importReports
(String path) Imports reports from ZIP archive(s) by path.importReports
(String path, EnumSet<ReportImportOption> importOptions) Imports reports from ZIP archive(s) by path.importReportsFromPath
(String path) Import all reports from the specified folder.importReportsWithResult
(byte[] zipBytes, EnumSet<ReportImportOption> importOptions) Imports reports from ZIP archive.protected boolean
isReportsStructureFile
(String name) protected org.apache.commons.compress.archivers.ArchiveEntry
newStoredEntry
(String name, byte[] data) protected byte[]
readBytesFromEntry
(org.apache.commons.compress.archivers.zip.ZipArchiveInputStream archiveReader) protected byte[]
readFileToByteArray
(File file) protected Report
reloadReport
(Report report) protected String
replaceForbiddenCharacters
(String fileName) protected void
updateReportTemplate
(Report report, byte[] zipBytes) protected void
withReportOptions
(Report report, EnumSet<ReportImportOption> importOptions) protected byte[]
zipContent
(Map<String, Object> stringObjectMap) protected byte[]
zipSingleReportFiles
(File[] files)
-
Field Details
-
ENCODING
- See Also:
-
reportsPersistence
-
reportsSerialization
-
dataManager
-
metadata
-
-
Constructor Details
-
ReportImportExportImpl
public ReportImportExportImpl()
-
-
Method Details
-
exportReports
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 interfaceReportImportExport
- Parameters:
reports
- Collection of Report objects to be exported.- Returns:
- ZIP byte array with zip archives inside.
-
importReports
Description copied from interface:ReportImportExport
Imports reports from ZIP archive. Archive file format is described in exportReports method.- Specified by:
importReports
in interfaceReportImportExport
- 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 interfaceReportImportExport
- Parameters:
zipBytes
- ZIP archive as a byte array.importOptions
- - report import options- Returns:
- Collection of imported reports.
-
importReports
Description copied from interface:ReportImportExport
Imports reports from ZIP archive(s) by path. Path can point to the ZIP file directly or to some directory with ZIP files. Archive file format is the same as produced by exportReports.- Specified by:
importReports
in interfaceReportImportExport
- Parameters:
path
- path to archive file or directory- Returns:
- Collection of imported reports.
-
importReports
public Collection<Report> importReports(String path, @Nullable EnumSet<ReportImportOption> importOptions) Description copied from interface:ReportImportExport
Imports reports from ZIP archive(s) by path. Path can point to the archive file directly or to some directory with archive files. Archive file format is the same as produced by exportReports.- Specified by:
importReports
in interfaceReportImportExport
- Parameters:
path
- path to archive file or directoryimportOptions
- 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 interfaceReportImportExport
- Parameters:
zipBytes
- ZIP archive as a byte array.importOptions
- report - import options- Returns:
- import result - collection of updated, created reports
-
importReportsFromPath
Description copied from interface:ReportImportExport
Import all reports from the specified folder. Folder should have the following structure, in other cases RuntimeException will be thrownfolder sub-folder1 report.structure template.doc sub-folder2 report.structure template.docx
- Specified by:
importReportsFromPath
in interfaceReportImportExport
- Parameters:
path
- to folder with reports- Returns:
- collection of imported reports
- Throws:
IOException
- if any I/O error occurs
-
exportReport
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
- Throws:
IOException
-
readFileToByteArray
-
updateReportTemplate
- Throws:
IOException
-
withReportOptions
protected void withReportOptions(Report report, @Nullable EnumSet<ReportImportOption> importOptions) -
zipSingleReportFiles
- Throws:
IOException
-
zipContent
- Throws:
IOException
-
newStoredEntry
protected org.apache.commons.compress.archivers.ArchiveEntry newStoredEntry(String name, byte[] data) -
replaceForbiddenCharacters
-
readBytesFromEntry
protected byte[] readBytesFromEntry(org.apache.commons.compress.archivers.zip.ZipArchiveInputStream archiveReader) throws IOException - Throws:
IOException
-
reloadReport
-
isReportsStructureFile
-