# HG changeset patch # User Tom Gottfried # Date 1657185548 -7200 # Node ID 7e767c0c9a6dbb386d9746a3d01fa87bbf245538 # Parent ca1319d5816d91624d8889ecaff10c98eb252ba0 Improve importer start _ Consider no given info gew files as error instead of starting to process an empty list. _ Reduce code duplication. diff -r ca1319d5816d -r 7e767c0c9a6d backend/src/main/java/org/dive4elements/river/importer/Importer.java --- a/backend/src/main/java/org/dive4elements/river/importer/Importer.java Thu Apr 28 18:02:21 2022 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/Importer.java Thu Jul 07 11:19:08 2022 +0200 @@ -17,6 +17,8 @@ import java.io.File; import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -133,6 +135,18 @@ /** Starting point for importing river data. */ public static void main(String [] args) { + // Take paths of GEW files from arguments and system property + List gews = new ArrayList<>(Arrays.asList(args)); + String gewProperty = Config.INSTANCE.getInfoGewFile(); + if (gewProperty != null && gewProperty.length() > 0) { + gews.add(gewProperty); + } + + if (gews.isEmpty()) { + log.error("No info gew files given"); + System.exit(1); + } + InfoGewParser infoGewParser = new InfoGewParser( getAnnotationClassifier()); @@ -140,24 +154,7 @@ File bwastrFile = null; - for (String gew: args) { - log.info("parsing info gew file: " + gew); - File gewFile = new File(gew); - if (bwastrFile == null) { - bwastrFile = new File( - gewFile.getParentFile(), BWASTR_ID_CSV_FILE); - } - try { - infoGewParser.parse(gewFile); - } - catch (IOException ioe) { - log.error("error while parsing gew: " + gew, ioe); - System.exit(1); - } - } - - String gew = Config.INSTANCE.getInfoGewFile(); - if (gew != null && gew.length() > 0) { + for (String gew: gews) { log.info("parsing info gew file: " + gew); File gewFile = new File(gew); if (bwastrFile == null) {