Commit c27abafc authored by Marco Descher's avatar Marco Descher
Browse files

wip

parent db11ec29
...@@ -10,6 +10,7 @@ import java.util.ArrayList; ...@@ -10,6 +10,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.slf4j.Logger; import org.slf4j.Logger;
import ch.elexis.core.model.IOrganization; import ch.elexis.core.model.IOrganization;
...@@ -24,6 +25,9 @@ public class MediportInsurerImporter implements MisthiosTask { ...@@ -24,6 +25,9 @@ public class MediportInsurerImporter implements MisthiosTask {
public MisthiosTaskResult run(Map<String, Object> context) { public MisthiosTaskResult run(Map<String, Object> context) {
IModelService coreModelService = (IModelService) context.get("coreModelService"); IModelService coreModelService = (IModelService) context.get("coreModelService");
Logger logger = (Logger) context.get("logger"); Logger logger = (Logger) context.get("logger");
IProgressMonitor monitor = (IProgressMonitor) context.get("monitor");
monitor.beginTask("Importiere MediData Versichererliste", IProgressMonitor.UNKNOWN);
URL sourceFile; URL sourceFile;
try { try {
...@@ -32,12 +36,12 @@ public class MediportInsurerImporter implements MisthiosTask { ...@@ -32,12 +36,12 @@ public class MediportInsurerImporter implements MisthiosTask {
return MisthiosTaskResult.ERROR(e1); return MisthiosTaskResult.ERROR(e1);
} }
try (InputStream is = sourceFile.openStream()) { try (InputStream is = sourceFile.openStream()) {
importCSVFromStream(coreModelService, logger, is); importCSVFromStream(coreModelService, logger, monitor, is);
monitor.done();
return MisthiosTaskResult.OK();
} catch (IOException e) { } catch (IOException e) {
return MisthiosTaskResult.ERROR(e); return MisthiosTaskResult.ERROR(e);
} }
return null;
} }
private static final String SEPARATOR = ";"; private static final String SEPARATOR = ";";
...@@ -61,7 +65,7 @@ public class MediportInsurerImporter implements MisthiosTask { ...@@ -61,7 +65,7 @@ public class MediportInsurerImporter implements MisthiosTask {
private static final int IDX_MEDIPORT_SUPPORT = 15; private static final int IDX_MEDIPORT_SUPPORT = 15;
public static List<IOrganization> importCSVFromStream(IModelService coreModelService, Logger logger, public static List<IOrganization> importCSVFromStream(IModelService coreModelService, Logger logger,
InputStream csvInStream) { IProgressMonitor monitor, InputStream csvInStream) {
List<IOrganization> insurerList = new ArrayList<IOrganization>(); List<IOrganization> insurerList = new ArrayList<IOrganization>();
try { try {
BufferedReader reader = new BufferedReader(new InputStreamReader(csvInStream)); BufferedReader reader = new BufferedReader(new InputStreamReader(csvInStream));
...@@ -131,6 +135,7 @@ public class MediportInsurerImporter implements MisthiosTask { ...@@ -131,6 +135,7 @@ public class MediportInsurerImporter implements MisthiosTask {
// insurer.setSupportsMediport(MEDIPORT_CONNECTED.equalsIgnoreCase(mediport)); // insurer.setSupportsMediport(MEDIPORT_CONNECTED.equalsIgnoreCase(mediport));
insurerList.add(insurer); insurerList.add(insurer);
monitor.worked(1);
} }
reader.close(); reader.close();
} catch (Exception e) { } catch (Exception e) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment