Mercurial > dive4elements > river
annotate backend/src/main/java/org/dive4elements/river/importer/uinfo/parsers/SalixParser.java @ 9661:9b8ba3b83a15
Importer (s/u-info) vegetation zones: new database column in vegetation_type table for german type name,
localized vegetation type names by querying the database instead of translating by resource property,
detecting and cancelling the import of a second vegetation zone file for a river,
detecting, logging, cancelling in case of wrong column titles,
detecting, logging and ignoring lines with missing (color) values,
comparing vegetation zone name and class with the database and logging+ignoring in case of inconsistencies,
starting the most elevated zone with 0 instead of -1 overflow days
author | mschaefer |
---|---|
date | Mon, 23 Mar 2020 16:38:12 +0100 |
parents | f0cad5212f49 |
children |
rev | line source |
---|---|
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
2 * Software engineering by |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
3 * Björnsen Beratende Ingenieure GmbH |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
5 * |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
6 * This file is Free Software under the GNU AGPL (>=v3) |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
8 * documentation coming with Dive4Elements River for details. |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
9 */ |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
10 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
11 package org.dive4elements.river.importer.uinfo.parsers; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
12 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
13 import java.io.File; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
14 import java.util.ArrayList; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
15 import java.util.EnumMap; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
16 import java.util.List; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
17 import java.util.regex.Matcher; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
18 import java.util.regex.Pattern; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
19 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
20 import org.apache.log4j.Logger; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
21 import org.dive4elements.river.importer.Config; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
22 import org.dive4elements.river.importer.ImportRiver; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
23 import org.dive4elements.river.importer.common.AbstractParser; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
24 import org.dive4elements.river.importer.common.ParsingState; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
25 import org.dive4elements.river.importer.uinfo.importitem.SalixKmLineImport; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
26 import org.dive4elements.river.importer.uinfo.importitem.SalixSeriesImport; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
27 import org.dive4elements.river.model.uinfo.Salix; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
28 import org.dive4elements.river.model.uinfo.SalixValue; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
29 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
30 /** |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
31 * Reads and parses a salix file |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
32 * |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
33 * @author Matthias Schäfer |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
34 * |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
35 */ |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
36 public class SalixParser extends AbstractParser<Salix, SalixValue, SalixKmLineImport, SalixSeriesImport> { |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
37 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
38 /***** FIELDS *****/ |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
39 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
40 private static final Logger log = Logger.getLogger(SalixParser.class); |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
41 |
9389 | 42 private static final String IMPORT_FILENAME = "Iota.csv"; |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
43 |
9660
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
44 private static final Pattern META_FIRST = Pattern.compile("^#\\sIota.*", Pattern.CASE_INSENSITIVE); |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
45 |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
46 private static final Pattern META_EVALUATOR = Pattern.compile("^#\\sAuswerter:\\s*([^;]*).*", Pattern.CASE_INSENSITIVE); |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
47 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
48 private enum ColTitlePattern { |
9408 | 49 FACTOR("Iota\\s*\\[(.*)\\].*"), // |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
50 MWMNW("\\(MW-MNW\\).*\\[(.*)\\].*"); |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
51 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
52 private final Pattern pattern; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
53 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
54 ColTitlePattern(final String regexp) { |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
55 this.pattern = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE); |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
56 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
57 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
58 public Pattern getPattern() { |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
59 return this.pattern; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
60 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
61 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
62 |
9660
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
63 private final EnumMap<ColTitlePattern, Integer> cols; |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
64 |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
65 private final EnumMap<ColTitlePattern, String> units; |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
66 |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
67 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
68 /***** CONSTRUCTORS *****/ |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
69 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
70 public SalixParser(final File importPath, final File rootRelativePath, final ImportRiver river) { |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
71 super(importPath, rootRelativePath, river); |
9660
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
72 this.cols = new EnumMap<>(ColTitlePattern.class); |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
73 this.units = new EnumMap<>(ColTitlePattern.class); |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
74 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
75 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
76 /***** METHODS *****/ |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
77 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
78 @Override |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
79 protected Logger getLog() { |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
80 return log; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
81 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
82 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
83 /** |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
84 * Whether this import type shall be skipped |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
85 */ |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
86 public static boolean shallSkip() { |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
87 return Config.INSTANCE.skipUInfoSalix(); |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
88 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
89 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
90 /** |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
91 * Creates a list of parsers for all salix import files in a directory |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
92 */ |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
93 public static List<SalixParser> createParsers(final File importDir, final File relativeDir, final ImportRiver river) { |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
94 final List<SalixParser> parsers = new ArrayList<>(); |
8988 | 95 final File importFile = new File(importDir, IMPORT_FILENAME); |
96 if (importFile.exists()) | |
97 parsers.add(new SalixParser(importFile, new File(relativeDir, IMPORT_FILENAME), river)); | |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
98 return parsers; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
99 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
100 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
101 @Override |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
102 protected SalixSeriesImport createSeriesImport(final String filename) { |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
103 return new SalixSeriesImport(filename); |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
104 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
105 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
106 @Override |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
107 protected boolean handleMetaOther() { |
9660
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
108 if (handleMetaFirst()) |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
109 return true; |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
110 else if (handleMetaEvaluator()) |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
111 return true; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
112 else |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
113 return false; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
114 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
115 |
9660
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
116 private boolean handleMetaFirst() { |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
117 final Matcher m = META_FIRST.matcher(this.currentLine); |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
118 if (m.matches()) { |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
119 this.metaPatternsMatched.add(META_FIRST); |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
120 return true; |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
121 } |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
122 return false; |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
123 } |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
124 |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
125 private boolean handleMetaEvaluator() { |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
126 final Matcher m = META_EVALUATOR.matcher(this.currentLine); |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
127 if (m.matches()) { |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
128 this.metaPatternsMatched.add(META_EVALUATOR); |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
129 this.seriesHeader.setEvaluationBy(parseMetaInfo(m.group(1).trim())); |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
130 return true; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
131 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
132 return false; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
133 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
134 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
135 @Override |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
136 protected boolean handleMetaColumnTitles() { |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
137 if (!super.handleMetaColumnTitles()) |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
138 return false; |
9660
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
139 for (final ColTitlePattern col : ColTitlePattern.values()) { |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
140 this.cols.put(col, -1); |
9660
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
141 this.units.put(col, ""); |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
142 } |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
143 for (int i = 1; i <= this.columnTitles.size() - 1; i++) { |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
144 for (final ColTitlePattern col : ColTitlePattern.values()) { |
9660
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
145 final Matcher m = col.getPattern().matcher(this.columnTitles.get(i)); |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
146 if (m.matches()) { |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
147 this.cols.put(col, i); |
9660
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
148 this.units.put(col, m.group(1)); |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
149 break; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
150 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
151 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
152 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
153 if ((this.cols.get(ColTitlePattern.FACTOR) < 0) || (this.cols.get(ColTitlePattern.MWMNW) < 0)) { |
9660
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
154 logLineError("Column of the iota value and/or mnw-mw-diff could not be identified"); |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
155 this.headerParsingState = ParsingState.STOP; |
9660
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
156 return true; |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
157 } |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
158 if (!this.units.get(ColTitlePattern.FACTOR).equals("m") || !this.units.get(ColTitlePattern.MWMNW).equals("m")) { |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
159 logLineError("Column of the iota value and/or mnw-mw-diff have unsupported units"); |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
160 this.headerParsingState = ParsingState.STOP; |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
161 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
162 return true; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
163 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
164 |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
165 @Override |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
166 protected SalixKmLineImport createKmLineImport(final Double km, final String[] values) { |
9660
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
167 final Number factor = parseDoubleCheckNull(values, this.cols.get(ColTitlePattern.FACTOR)); |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
168 if ((factor == null) || Double.isNaN(factor.doubleValue())) { |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
169 logLineWarning(INVALID_VALUE_ERROR_FORMAT, "iota"); |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
170 return null; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
171 } |
9660
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
172 final Number mnwmw = parseDoubleCheckNull(values, this.cols.get(ColTitlePattern.MWMNW)); |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
173 if ((mnwmw == null) || Double.isNaN(mnwmw.doubleValue())) { |
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
174 logLineWarning(INVALID_VALUE_ERROR_FORMAT, "MNW-MW-diff"); |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
175 return null; |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
176 } |
9660
f0cad5212f49
Importer (s/u-info) extensions: iota (salix): detecting, logging, cancelling in case of wrong column titles/units,
mschaefer
parents:
9408
diff
changeset
|
177 return new SalixKmLineImport(km, factor.doubleValue(), mnwmw.doubleValue()); |
8971
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
178 } |
50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
mschaefer
parents:
diff
changeset
|
179 } |