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 SummaryFieldsModifier and TypeFieldDescriptionprotected DataManagerstatic final Stringprotected Metadataprotected ReportsPersistenceprotected ReportsSerialization
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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 ReportfromByteArray(byte[] zipBytes) protected voidimportReport(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 booleanisReportsStructureFile(String name) protected org.apache.commons.compress.archivers.zip.ZipArchiveEntrynewStoredEntry(String name, byte[] data) protected byte[]readBytesFromEntry(org.apache.commons.compress.archivers.zip.ZipArchiveInputStream archiveReader) protected byte[]readFileToByteArray(File file) protected ReportreloadReport(Report report) protected StringreplaceForbiddenCharacters(String fileName) protected voidupdateReportTemplate(Report report, byte[] zipBytes) protected voidwithReportOptions(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- 
ReportImportExportImplpublic ReportImportExportImpl()
 
- 
- 
Method Details- 
exportReportsDescription copied from interface:ReportImportExportExports 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:
- exportReportsin interface- ReportImportExport
- Parameters:
- reports- Collection of Report objects to be exported.
- Returns:
- ZIP byte array with zip archives inside.
 
- 
importReportsDescription copied from interface:ReportImportExportImports reports from ZIP archive. Archive file format is described in exportReports method.- Specified by:
- importReportsin interface- ReportImportExport
- Parameters:
- zipBytes- ZIP archive as a byte array.
- Returns:
- Collection of imported reports.
 
- 
importReportspublic Collection<Report> importReports(byte[] zipBytes, @Nullable EnumSet<ReportImportOption> importOptions) Description copied from interface:ReportImportExportImports reports from ZIP archive. Archive file format is described in exportReports method.- Specified by:
- importReportsin interface- ReportImportExport
- Parameters:
- zipBytes- ZIP archive as a byte array.
- importOptions- - report import options
- Returns:
- Collection of imported reports.
 
- 
importReportsDescription copied from interface:ReportImportExportImports 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:
- importReportsin interface- ReportImportExport
- Parameters:
- path- path to archive file or directory
- Returns:
- Collection of imported reports.
 
- 
importReportspublic Collection<Report> importReports(String path, @Nullable EnumSet<ReportImportOption> importOptions) Description copied from interface:ReportImportExportImports 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:
- importReportsin interface- ReportImportExport
- Parameters:
- path- path to archive file or directory
- importOptions- report import options
- Returns:
- Collection of imported reports.
 
- 
importReportsWithResultpublic ReportImportResult importReportsWithResult(byte[] zipBytes, @Nullable EnumSet<ReportImportOption> importOptions) Description copied from interface:ReportImportExportImports reports from ZIP archive. Archive file format is described in exportReports method.- Specified by:
- importReportsWithResultin interface- ReportImportExport
- Parameters:
- zipBytes- ZIP archive as a byte array.
- importOptions- report - import options
- Returns:
- import result - collection of updated, created reports
 
- 
importReportsFromPathDescription copied from interface:ReportImportExportImport 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:
- importReportsFromPathin interface- ReportImportExport
- Parameters:
- path- to folder with reports
- Returns:
- collection of imported reports
- Throws:
- IOException- if any I/O error occurs
 
- 
exportReportExports 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
 
- 
importReportprotected void importReport(byte[] zipBytes, @Nullable EnumSet<ReportImportOption> importOptions, ReportImportResult importResult) throws IOException - Throws:
- IOException
 
- 
fromByteArray- Throws:
- IOException
 
- 
readFileToByteArray
- 
updateReportTemplate- Throws:
- IOException
 
- 
withReportOptionsprotected void withReportOptions(Report report, @Nullable EnumSet<ReportImportOption> importOptions) 
- 
zipSingleReportFiles- Throws:
- IOException
 
- 
zipContent- Throws:
- IOException
 
- 
newStoredEntryprotected org.apache.commons.compress.archivers.zip.ZipArchiveEntry newStoredEntry(String name, byte[] data) 
- 
replaceForbiddenCharacters
- 
readBytesFromEntryprotected byte[] readBytesFromEntry(org.apache.commons.compress.archivers.zip.ZipArchiveInputStream archiveReader) throws IOException - Throws:
- IOException
 
- 
reloadReport
- 
isReportsStructureFile
 
-