Search in sources :

Example 1 with AdvancedExportService

use of com.axelor.apps.base.service.advancedExport.AdvancedExportService in project axelor-open-suite by axelor.

the class AdvancedExportController method getAdvancedExportFile.

private void getAdvancedExportFile(ActionRequest request, ActionResponse response, AdvancedExport advancedExport, String fileType) throws AxelorException, IOException {
    AdvancedExportService advancedExportService = Beans.get(AdvancedExportService.class);
    if (!advancedExport.getAdvancedExportLineList().isEmpty()) {
        List<Long> recordIds = createCriteria(request, advancedExport);
        File file = advancedExportService.export(advancedExport, recordIds, fileType);
        if (advancedExportService.getIsReachMaxExportLimit()) {
            response.setFlash(I18n.get(IExceptionMessage.ADVANCED_EXPORT_3));
        }
        FileInputStream inStream = new FileInputStream(file);
        MetaFile exportFile = Beans.get(MetaFiles.class).upload(inStream, advancedExportService.getExportFileName());
        inStream.close();
        file.delete();
        downloadExportFile(response, exportFile);
    } else {
        response.setError(I18n.get(IExceptionMessage.ADVANCED_EXPORT_1));
    }
}
Also used : MetaFiles(com.axelor.meta.MetaFiles) MetaFile(com.axelor.meta.db.MetaFile) AdvancedExportService(com.axelor.apps.base.service.advancedExport.AdvancedExportService) File(java.io.File) MetaFile(com.axelor.meta.db.MetaFile) FileInputStream(java.io.FileInputStream)

Aggregations

AdvancedExportService (com.axelor.apps.base.service.advancedExport.AdvancedExportService)1 MetaFiles (com.axelor.meta.MetaFiles)1 MetaFile (com.axelor.meta.db.MetaFile)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1