use of com.axelor.apps.base.db.ImportConfiguration in project axelor-open-suite by axelor.
the class AccountChartService method importAccountChartData.
public void importAccountChartData(AccountChart act, File configFile, Map<String, Object> importContext) throws IOException, AxelorException {
ImportConfiguration importConfiguration = new ImportConfiguration();
importConfiguration.setDataMetaFile(act.getMetaFile());
importConfiguration.setBindMetaFile(metaFiles.upload(configFile));
factoryImporter.createImporter(importConfiguration).run(importContext);
}
use of com.axelor.apps.base.db.ImportConfiguration in project axelor-open-suite by axelor.
the class ImportConfigurationBaseRepository method copy.
@Override
public ImportConfiguration copy(ImportConfiguration entity, boolean deep) {
ImportConfiguration importConfiguration = super.copy(entity, deep);
importConfiguration.setImportHistoryList(null);
importConfiguration.setStatusSelect(ImportConfigurationRepository.STATUS_DRAFT);
importConfiguration.setStartDateTime(null);
importConfiguration.setEndDateTime(null);
return importConfiguration;
}
use of com.axelor.apps.base.db.ImportConfiguration in project axelor-open-suite by axelor.
the class ImportCityServiceImpl method importCityData.
/**
* Imports city data
*
* @param configXmlFile
* @param dataCsvFile
* @return
*/
protected ImportHistory importCityData(File configXmlFile, File dataCsvFile) {
ImportHistory importHistory = null;
try {
ImportConfiguration importConfiguration = new ImportConfiguration();
importConfiguration.setBindMetaFile(metaFiles.upload(configXmlFile));
importConfiguration.setDataMetaFile(metaFiles.upload(dataCsvFile));
importHistory = factoryImporter.createImporter(importConfiguration).run();
} catch (Exception e) {
TraceBackService.trace(e);
printWriter.append(e.getLocalizedMessage() + " at " + e.getStackTrace()[0] + "\n");
}
return importHistory;
}
use of com.axelor.apps.base.db.ImportConfiguration in project axelor-open-suite by axelor.
the class ImportDemoDataServiceImpl method importFileData.
private MetaFile importFileData(File dataFile, File configFile, String dataFileName, String configFileName) throws IOException, AxelorException {
ImportConfiguration config = new ImportConfiguration();
MetaFile configMetaFile = metaFiles.upload(new FileInputStream(configFile), configFileName + ".xml");
MetaFile dataMetaFile = metaFiles.upload(new FileInputStream(dataFile), dataFileName + ".csv");
config.setBindMetaFile(configMetaFile);
config.setDataMetaFile(dataMetaFile);
config.setTypeSelect("csv");
ImportHistory importHistory = factoryImporter.createImporter(config).run();
MetaFiles.getPath(configMetaFile).toFile().delete();
MetaFiles.getPath(dataMetaFile).toFile().delete();
return importHistory.getLogMetaFile();
}
use of com.axelor.apps.base.db.ImportConfiguration in project axelor-open-suite by axelor.
the class ICalendarController method importCalendarFile.
public void importCalendarFile(ActionRequest request, ActionResponse response) throws IOException, ParserException {
ImportConfiguration imp = request.getContext().asType(ImportConfiguration.class);
Object object = request.getContext().get("_id");
ICalendar cal = null;
if (object != null) {
Long id = Long.valueOf(object.toString());
cal = Beans.get(ICalendarRepository.class).find(id);
}
if (cal == null) {
cal = new ICalendar();
}
File data = MetaFiles.getPath(imp.getDataMetaFile()).toFile();
Beans.get(ICalendarService.class).load(cal, data);
response.setCanClose(true);
response.setReload(true);
}
Aggregations