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));
}
}
Aggregations