use of com.axelor.apps.base.db.ImportConfiguration in project axelor-open-suite by axelor.
the class ImportConfigurationController method run.
public void run(ActionRequest request, ActionResponse response) {
ImportConfiguration importConfiguration = request.getContext().asType(ImportConfiguration.class);
try {
ImportHistory importHistory = Beans.get(ImportService.class).run(importConfiguration);
response.setValue("statusSelect", ImportConfigurationRepository.STATUS_COMPLETED);
response.setValue("endDateTime", Beans.get(AppBaseService.class).getTodayDateTime().toLocalDateTime());
response.setAttr("importHistoryList", "value:add", importHistory);
File readFile = MetaFiles.getPath(importHistory.getLogMetaFile()).toFile();
response.setNotify(FileUtils.readFileToString(readFile, StandardCharsets.UTF_8).replaceAll("(\r\n|\n\r|\r|\n)", "<br />"));
} catch (Exception e) {
response.setValue("statusSelect", ImportConfigurationRepository.STATUS_ERROR);
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.base.db.ImportConfiguration in project axelor-open-suite by axelor.
the class FECImportController method runImport.
public void runImport(ActionRequest request, ActionResponse response) {
try {
FECImport fecImport = request.getContext().asType(FECImport.class);
fecImport = Beans.get(FECImportRepository.class).find(fecImport.getId());
ImportConfiguration importConfig = new ImportConfiguration();
importConfig.setBindMetaFile(fecImport.getBindMetaFile());
importConfig.setDataMetaFile(Beans.get(MetaFiles.class).upload(new FileInputStream(MetaFiles.getPath(fecImport.getDataMetaFile()).toFile()), "FEC.csv"));
ImportHistory importHistory = Beans.get(FactoryImporter.class).createImporter(importConfig).run();
File readFile = MetaFiles.getPath(importHistory.getLogMetaFile()).toFile();
response.setNotify(FileUtils.readFileToString(readFile, StandardCharsets.UTF_8).replaceAll("(\r\n|\n\r|\r|\n)", "<br />"));
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.base.db.ImportConfiguration in project axelor-open-suite by axelor.
the class LeadController method getLeadImportConfig.
public void getLeadImportConfig(ActionRequest request, ActionResponse response) {
ImportConfiguration leadImportConfig = Beans.get(ImportConfigurationRepository.class).all().filter("self.bindMetaFile.fileName = ?1", ImportLeadConfiguration.IMPORT_LEAD_CONFIG).fetchOne();
logger.debug("ImportConfig for lead: {}", leadImportConfig);
if (leadImportConfig == null) {
response.setFlash(I18n.get(IExceptionMessage.LEAD_4));
} else {
response.setView(ActionView.define(I18n.get(IExceptionMessage.LEAD_5)).model("com.axelor.apps.base.db.ImportConfiguration").add("form", "import-configuration-form").param("popup", "reload").param("forceEdit", "true").param("popup-save", "false").param("show-toolbar", "false").context("_showRecord", leadImportConfig.getId().toString()).map());
}
}
use of com.axelor.apps.base.db.ImportConfiguration in project axelor-open-suite by axelor.
the class ImportLeadConfiguration method importFiles.
public Object importFiles(Object bean, Map<String, Object> values) {
assert bean instanceof ImportConfiguration;
final Path path = (Path) values.get("__path__");
ImportConfiguration importConfig = (ImportConfiguration) bean;
try {
File file = path.resolve(FILES_DIR + File.separator + IMPORT_LEAD_CONFIG).toFile();
importConfig.setBindMetaFile(metaFiles.upload(file));
file = path.resolve(FILES_DIR + File.separator + IMPORT_LEAD_CSV).toFile();
importConfig.setDataMetaFile(metaFiles.upload(file));
} catch (IOException e) {
log.debug("Error importing lead import config", e);
return null;
}
return importConfig;
}
Aggregations