19 package org.turro.importer;
21 import java.io.IOException;
22 import java.io.Reader;
23 import java.util.ArrayList;
24 import java.util.Collections;
25 import java.util.HashMap;
26 import java.util.List;
28 import java.util.logging.Level;
29 import java.util.logging.Logger;
30 import org.turro.csv.CSVs;
31 import org.turro.ws.WsMember;
39 private final String name, service;
41 private boolean fullImport;
44 private List<String> headers;
45 private List<ImporterRegister> data;
49 this.service = service;
74 if(fileName.toLowerCase().endsWith(
"csv")) {
76 }
else if(fileName.toLowerCase().endsWith(
"tdf")) {
83 data =
new ArrayList<>();
84 headers =
new ArrayList<>();
89 this.fullImport = fullImport;
120 CSVs csv = type.equals(
ImporterDataType.
CSV) ? CSVs.cvs().reader(reader) : CSVs.tdf().reader(reader);
121 List<Map<String, String>> values = csv.parse();
122 headers = csv.getRealHeaders();
123 return values.stream().map(
register -> ImporterRegister.from(
new HashMap<String, Object>(
register))).toList();
125 }
catch (IOException ex) {
128 return Collections.EMPTY_LIST;
abstract boolean isInRole()
List< ImporterRegister > getData()
void importData(Reader reader)
void setType(ImporterDataType type)
void setType(String fileName)
void setFullImport(boolean fullImport)
List< ImporterRegister > importDataFrom(Reader reader)
void processData(WsMember member)
abstract void process(WsMember member, List< ImporterRegister > data)
List< String > getHeaders()
AbstractImporterProvider(String name, String service)