use of com.axelor.data.adapter.DataAdapter in project axelor-open-suite by axelor.
the class DataImportServiceImpl method importData.
@Override
public MetaFile importData(AdvancedImport advancedImport) throws IOException, AxelorException, ClassNotFoundException {
adapterMap = new HashMap<String, DataAdapter>();
importContext = new HashMap<String, Object>();
language = advancedImport.getLanguageSelect();
dataDir = Files.createTempDir();
String extension = Files.getFileExtension(advancedImport.getImportFile().getFileName());
DataReaderService reader = dataReaderFactory.getDataReader(extension);
reader.initialize(advancedImport.getImportFile(), advancedImport.getFileSeparator());
List<CSVInput> inputs = this.process(reader, advancedImport);
if (advancedImport.getAttachment() != null) {
this.processAttachments(advancedImport.getAttachment());
}
MetaFile logFile = this.importData(inputs);
FileUtils.forceDelete(dataDir);
return logFile;
}
use of com.axelor.data.adapter.DataAdapter in project axelor-open-suite by axelor.
the class DataImportServiceImpl method createAdapter.
private DataAdapter createAdapter(String typeName, String format) {
DataAdapter adapter = adapterMap.get(format);
if (adapter == null) {
adapter = new DataAdapter(("Adapter" + counter), JavaTimeAdapter.class, "type", typeName, "format", format);
adapterMap.put(format, adapter);
counter++;
}
return adapter;
}
use of com.axelor.data.adapter.DataAdapter in project axelor-open-suite by axelor.
the class DataImportServiceImpl method getAdapter.
private String getAdapter(String type, String dateFormat) {
String adapter = null;
switch(type) {
case "LocalDate":
DataAdapter dateAdapter = this.createAdapter("LocalDate", dateFormat);
adapter = dateAdapter.getName();
break;
case "LocalDateTime":
DataAdapter dateTimeAdapter = this.createAdapter("LocalDateTime", dateFormat);
adapter = dateTimeAdapter.getName();
break;
case "LocalTime":
DataAdapter timeAdapter = this.createAdapter("LocalTime", dateFormat);
adapter = timeAdapter.getName();
break;
case "ZoneDateTime":
DataAdapter zonedDateTimeAdapter = this.createAdapter("ZonedDateTime", dateFormat);
adapter = zonedDateTimeAdapter.getName();
break;
}
return adapter;
}
Aggregations