Mercurial > dive4elements > river
changeset 9729:7e767c0c9a6d 3.2.x
Improve importer start
_ Consider no given info gew files as error instead of starting to
process an empty list.
_ Reduce code duplication.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 07 Jul 2022 11:19:08 +0200 |
parents | ca1319d5816d |
children | 7f8110eed9a3 |
files | backend/src/main/java/org/dive4elements/river/importer/Importer.java |
diffstat | 1 files changed, 15 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- 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<String> 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) {