Mercurial > dive4elements > river
annotate backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentDensityParser.java @ 8989:2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
author | mschaefer |
---|---|
date | Mon, 09 Apr 2018 09:07:00 +0200 |
parents | 5e38e2924c07 |
children | c43d8c1a4455 |
rev | line source |
---|---|
5844
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5992
4c3ccf2b0304
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5844
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5844
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5992
4c3ccf2b0304
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5844
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5844
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5829
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
9 package org.dive4elements.river.importer.parsers; |
2815
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
2817
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2816
diff
changeset
|
11 import java.io.File; |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2816
diff
changeset
|
12 import java.io.IOException; |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
13 import java.math.BigDecimal; |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
14 import java.text.NumberFormat; |
2815
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import java.util.ArrayList; |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import java.util.List; |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
17 import java.util.regex.Matcher; |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
18 import java.util.regex.Pattern; |
2815
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import org.apache.log4j.Logger; |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
21 import org.dive4elements.river.importer.ImportDepth; |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
22 import org.dive4elements.river.importer.ImportSedimentDensity; |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
23 import org.dive4elements.river.importer.ImportSedimentDensityValue; |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
24 import org.dive4elements.river.importer.common.AbstractParser; |
2815
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 public class SedimentDensityParser extends LineParser { |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 private static final Logger log = |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
29 Logger.getLogger(SedimentDensityParser.class); |
2815
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
5565
a44a3f997ec8
Cleanup whitespace. Removed unused variable.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5564
diff
changeset
|
31 public static final NumberFormat nf = |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
32 NumberFormat.getInstance(DEFAULT_LOCALE); |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
33 |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
34 public static final Pattern META_DEPTH = |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
35 Pattern.compile("^Tiefe: (\\d++)-(\\d++).*"); |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
36 |
6745
bd437771ea00
Sediment density parser: fetch year from metaline and parse
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5992
diff
changeset
|
37 public static final Pattern META_YEAR = |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
38 Pattern.compile("^Jahr: (\\d{4}).*"); |
6745
bd437771ea00
Sediment density parser: fetch year from metaline and parse
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5992
diff
changeset
|
39 |
2815
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 protected List<ImportSedimentDensity> sedimentDensities; |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 protected ImportSedimentDensity current; |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 |
2817
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2816
diff
changeset
|
44 protected String currentDescription; |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2816
diff
changeset
|
45 |
6745
bd437771ea00
Sediment density parser: fetch year from metaline and parse
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5992
diff
changeset
|
46 protected String yearString; |
2815
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 public SedimentDensityParser() { |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
49 this.sedimentDensities = new ArrayList<>(); |
2815
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 } |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 @Override |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
54 public void parse(final File file) throws IOException { |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
55 this.currentDescription = file.getName(); |
2817
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2816
diff
changeset
|
56 |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2816
diff
changeset
|
57 super.parse(file); |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2816
diff
changeset
|
58 } |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2816
diff
changeset
|
59 |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2816
diff
changeset
|
60 |
8979f2294af9
Finished parsing MINFO specific sediment density.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2816
diff
changeset
|
61 @Override |
2815
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 protected void reset() { |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
63 this.current = new ImportSedimentDensity(this.currentDescription); |
2815
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 } |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 @Override |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 protected void finish() { |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
69 if (this.current != null) { |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
70 this.sedimentDensities.add(this.current); |
2815
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 } |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 } |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 @Override |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
76 protected void handleLine(final int lineNum, final String line) { |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
77 if (line.startsWith(START_META_CHAR)) { |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
78 handleMetaLine(stripMetaLine(line)); |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
79 } |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
80 else { |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
81 handleDataLine(line); |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
82 } |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
83 } |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
84 |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
85 |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
86 protected void handleMetaLine(final String line) { |
5441
7c1dd9c3f6bd
remove unit from sediment density and depths (always t/m3 respectively cm, otherwise a typo)
Tom Gottfried <tom.gottfried@intevation.de>
parents:
4550
diff
changeset
|
87 if (handleMetaDepth(line)) { |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
88 return; |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
89 } |
7376
4b26fd60105f
Replaced more tabs with spaces + minor cosmetics (removed out commented code from double precision branch).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6746
diff
changeset
|
90 if (handleMetaYear(line)) { |
4b26fd60105f
Replaced more tabs with spaces + minor cosmetics (removed out commented code from double precision branch).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6746
diff
changeset
|
91 return; |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
92 } |
7376
4b26fd60105f
Replaced more tabs with spaces + minor cosmetics (removed out commented code from double precision branch).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6746
diff
changeset
|
93 log.warn("Unknown meta line: '" + line + "'"); |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
94 } |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
95 |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
96 |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
97 protected boolean handleMetaDepth(final String line) { |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
98 final Matcher m = META_DEPTH.matcher(line); |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
99 |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
100 if (m.matches()) { |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
101 final String lo = m.group(1); |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
102 final String up = m.group(2); |
3942
43aa1ac8614b
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3940
diff
changeset
|
103 |
8856 | 104 log.info("Found sediment density depth: " |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
105 + lo + " - " + up + " cm"); |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
106 |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
107 try { |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
108 final ImportDepth depth = new ImportDepth( |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
109 AbstractParser.parseDecimal(lo), |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
110 AbstractParser.parseDecimal(up)); |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
111 |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
112 this.current.setDepth(depth); |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
113 |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
114 return true; |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
115 } |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
116 catch (final NumberFormatException pe) { |
5490
b3dd14fc13a6
Parsers: do not call warnings error
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5441
diff
changeset
|
117 log.warn("Unparseable numbers in: '" + line + "'"); |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
118 } |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
119 } |
3940
aed7aba93718
Improved logging and stabilized minfo import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2835
diff
changeset
|
120 else { |
aed7aba93718
Improved logging and stabilized minfo import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2835
diff
changeset
|
121 log.debug("Meta line doesn't contain depth information: " + line); |
aed7aba93718
Improved logging and stabilized minfo import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2835
diff
changeset
|
122 } |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
123 |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
124 return false; |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
125 } |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
126 |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
127 protected boolean handleMetaYear(final String line) { |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
128 final Matcher m = META_YEAR.matcher(line); |
6745
bd437771ea00
Sediment density parser: fetch year from metaline and parse
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5992
diff
changeset
|
129 |
bd437771ea00
Sediment density parser: fetch year from metaline and parse
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5992
diff
changeset
|
130 if (m.matches()) { |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
131 this.yearString = m.group(1); |
6745
bd437771ea00
Sediment density parser: fetch year from metaline and parse
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5992
diff
changeset
|
132 |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
133 log.info("Found sediment density year: " + this.yearString); |
6745
bd437771ea00
Sediment density parser: fetch year from metaline and parse
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5992
diff
changeset
|
134 |
7376
4b26fd60105f
Replaced more tabs with spaces + minor cosmetics (removed out commented code from double precision branch).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6746
diff
changeset
|
135 return true; |
6745
bd437771ea00
Sediment density parser: fetch year from metaline and parse
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5992
diff
changeset
|
136 } |
7376
4b26fd60105f
Replaced more tabs with spaces + minor cosmetics (removed out commented code from double precision branch).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6746
diff
changeset
|
137 |
4b26fd60105f
Replaced more tabs with spaces + minor cosmetics (removed out commented code from double precision branch).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6746
diff
changeset
|
138 log.debug("Meta line doesn't contain year: " + line); |
6745
bd437771ea00
Sediment density parser: fetch year from metaline and parse
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5992
diff
changeset
|
139 |
bd437771ea00
Sediment density parser: fetch year from metaline and parse
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5992
diff
changeset
|
140 return false; |
bd437771ea00
Sediment density parser: fetch year from metaline and parse
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5992
diff
changeset
|
141 } |
bd437771ea00
Sediment density parser: fetch year from metaline and parse
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5992
diff
changeset
|
142 |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
143 |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
144 protected void handleDataLine(final String line) { |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
145 final String[] vals = line.split(SEPERATOR_CHAR); |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
146 |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
147 if (vals == null || vals.length < 3) { |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
148 log.warn("skip invalid data line: '" + line + "'"); |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
149 return; |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
150 } |
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
151 |
5507
db6c7268b08e
Schema change: add shore offset to sediment density values and be more rigid with input files in parser
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5505
diff
changeset
|
152 BigDecimal km = null; |
db6c7268b08e
Schema change: add shore offset to sediment density values and be more rigid with input files in parser
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5505
diff
changeset
|
153 BigDecimal shoreOffset = null; |
db6c7268b08e
Schema change: add shore offset to sediment density values and be more rigid with input files in parser
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5505
diff
changeset
|
154 BigDecimal density = null; |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
155 try { |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
156 km = AbstractParser.parseDecimal(vals[0]); |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
157 density = AbstractParser.parseDecimal(vals[2]); |
5565
a44a3f997ec8
Cleanup whitespace. Removed unused variable.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5564
diff
changeset
|
158 if (!vals[1].isEmpty()) { |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
159 shoreOffset = AbstractParser.parseDecimal(vals[1]); |
5565
a44a3f997ec8
Cleanup whitespace. Removed unused variable.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5564
diff
changeset
|
160 } |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
161 } |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
162 catch (final NumberFormatException pe) { |
5490
b3dd14fc13a6
Parsers: do not call warnings error
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5441
diff
changeset
|
163 log.warn("Unparseable numbers in '" + line + "'"); |
2816
70b4a31a3306
Implemented the method stubs of the parser for sediment density and made some db schema adaptions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2815
diff
changeset
|
164 } |
4524
be9e28cff0c4
Parse and store year in sediment densities.
Raimund Renkert <rrenkert@intevation.de>
parents:
4193
diff
changeset
|
165 |
5565
a44a3f997ec8
Cleanup whitespace. Removed unused variable.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5564
diff
changeset
|
166 if (km == null || density == null) { |
a44a3f997ec8
Cleanup whitespace. Removed unused variable.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5564
diff
changeset
|
167 log.warn("SDP: No km nor density given. Skip line"); |
a44a3f997ec8
Cleanup whitespace. Removed unused variable.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5564
diff
changeset
|
168 return; |
a44a3f997ec8
Cleanup whitespace. Removed unused variable.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5564
diff
changeset
|
169 } |
5507
db6c7268b08e
Schema change: add shore offset to sediment density values and be more rigid with input files in parser
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5505
diff
changeset
|
170 |
4524
be9e28cff0c4
Parse and store year in sediment densities.
Raimund Renkert <rrenkert@intevation.de>
parents:
4193
diff
changeset
|
171 BigDecimal year = null; |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
172 if (this.yearString != null) { |
7376
4b26fd60105f
Replaced more tabs with spaces + minor cosmetics (removed out commented code from double precision branch).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6746
diff
changeset
|
173 try { |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
174 year = AbstractParser.parseDecimal(this.yearString); |
7376
4b26fd60105f
Replaced more tabs with spaces + minor cosmetics (removed out commented code from double precision branch).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6746
diff
changeset
|
175 } |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
176 catch (final NumberFormatException pe) { |
7376
4b26fd60105f
Replaced more tabs with spaces + minor cosmetics (removed out commented code from double precision branch).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6746
diff
changeset
|
177 log.warn("Unparseable year string"); |
4b26fd60105f
Replaced more tabs with spaces + minor cosmetics (removed out commented code from double precision branch).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6746
diff
changeset
|
178 } |
4b26fd60105f
Replaced more tabs with spaces + minor cosmetics (removed out commented code from double precision branch).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6746
diff
changeset
|
179 } |
4524
be9e28cff0c4
Parse and store year in sediment densities.
Raimund Renkert <rrenkert@intevation.de>
parents:
4193
diff
changeset
|
180 |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
181 this.current.addValue(new ImportSedimentDensityValue( |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
182 km, |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
183 shoreOffset, |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
184 density, |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
185 year, |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
186 this.currentDescription)); |
2815
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 } |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
189 |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
190 public List<ImportSedimentDensity> getSedimentDensities() { |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8856
diff
changeset
|
191 return this.sedimentDensities; |
2815
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
192 } |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
193 } |
3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
194 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |