use of com.axelor.meta.db.MetaFile 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));
}
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class AdvancedImportController method importData.
public void importData(ActionRequest request, ActionResponse response) {
try {
AdvancedImport advancedImport = request.getContext().asType(AdvancedImport.class);
if (advancedImport.getId() != null) {
advancedImport = Beans.get(AdvancedImportRepository.class).find(advancedImport.getId());
}
MetaFile logFile = Beans.get(DataImportService.class).importData(advancedImport);
if (logFile != null) {
response.setValue("errorLog", logFile);
} else {
response.setValue("errorLog", null);
response.setFlash(I18n.get(IExceptionMessage.ADVANCED_IMPORT_IMPORT_DATA));
response.setSignal("refresh-app", true);
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class ConvertDemoDataFileController method convertDemoDataFile.
public void convertDemoDataFile(ActionRequest request, ActionResponse response) throws IOException, AxelorException, ParseException {
MetaFile metaFile = Beans.get(MetaFileRepository.class).find(Long.valueOf(((Map) request.getContext().get("importFile")).get("id").toString()));
File dataFile = MetaFiles.getPath(metaFile).toFile();
if (Files.getFileExtension(dataFile.getName()).equals("xlsx")) {
response.setValue("$csvMetaFile", Beans.get(ConvertDemoDataFileService.class).convertDemoDataExcelFile(dataFile));
} else {
response.setError(I18n.get(IExceptionMessage.VALIDATE_FILE_TYPE));
}
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class Importer method createFinalWorkspace.
protected File createFinalWorkspace(MetaFile metaFile) throws IOException {
File data = MetaFiles.getPath(metaFile).toFile();
File finalWorkspace = new File(workspace, computeFinalWorkspaceName(data));
finalWorkspace.mkdir();
if (isZip(data)) {
unZip(data, finalWorkspace);
} else {
FileUtils.copyFile(data, new File(finalWorkspace, metaFile.getFileName()));
}
if (Files.getFileExtension(data.getName()).equals("xlsx"))
importExcel(new File(finalWorkspace, metaFile.getFileName()));
return finalWorkspace;
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class UserServiceImpl method getUserActiveCompanyLogoLink.
@Override
public String getUserActiveCompanyLogoLink() {
final Company company = this.getUserActiveCompany();
if (company == null) {
return null;
}
MetaFile logo = company.getLogo();
if (logo == null) {
return null;
}
return metaFiles.getDownloadLink(logo, company);
}
Aggregations