Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/AbstractSedimentLoadParser.java @ 8059:bde5f5ec7c72
SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 18 Jul 2014 18:01:49 +0200 |
parents | d86cc6a17b7a |
children | 3ae11daff343 |
comparison
equal
deleted
inserted
replaced
8058:fbe3ba5a480e | 8059:bde5f5ec7c72 |
---|---|
50 Pattern.compile("^Fraktion: (.*)"); | 50 Pattern.compile("^Fraktion: (.*)"); |
51 | 51 |
52 public static final Pattern META_FRACTION_NAME = | 52 public static final Pattern META_FRACTION_NAME = |
53 Pattern.compile("^Fraktionsname: (.*)"); | 53 Pattern.compile("^Fraktionsname: (.*)"); |
54 | 54 |
55 public static final Pattern META_SQ_TIMEINTERVAL = | |
56 Pattern.compile("^S-Q-Beziehung: (.*)"); | |
57 | |
55 public static final Pattern META_COLUMN_NAMES = | 58 public static final Pattern META_COLUMN_NAMES = |
56 Pattern.compile("^Fluss-km.*"); | 59 Pattern.compile("^Fluss-km.*"); |
57 | 60 |
58 public static final Pattern META_GRAIN_SIZE = | 61 public static final Pattern META_GRAIN_SIZE = |
59 Pattern.compile("([0-9]*,*[0-9]+)-([0-9]*,*[0-9]+) *mm"); | 62 Pattern.compile("([0-9]*,*[0-9]+)-([0-9]*,*[0-9]+) *mm"); |
68 protected abstract void handleMetaLine(String line) | 71 protected abstract void handleMetaLine(String line) |
69 throws LineParserException; | 72 throws LineParserException; |
70 | 73 |
71 | 74 |
72 protected ImportGrainFraction grainFraction; | 75 protected ImportGrainFraction grainFraction; |
76 | |
77 protected ImportTimeInterval sqTimeInterval; | |
73 | 78 |
74 protected String description; | 79 protected String description; |
75 | 80 |
76 protected String[] columnNames; | 81 protected String[] columnNames; |
77 | 82 |
162 | 167 |
163 return false; | 168 return false; |
164 } | 169 } |
165 | 170 |
166 | 171 |
172 public boolean handleMetaSQTimeInterval(String line) { | |
173 Matcher m = META_SQ_TIMEINTERVAL.matcher(line); | |
174 | |
175 if (m.matches()) { | |
176 String interval = m.group(1); | |
177 | |
178 try { | |
179 Matcher a = TIMEINTERVAL_EPOCH.matcher(interval); | |
180 if (a.matches()) { | |
181 int yearA = nf.parse(a.group(1)).intValue(); | |
182 int yearB = nf.parse(a.group(2)).intValue(); | |
183 | |
184 sqTimeInterval = new ImportTimeInterval( | |
185 DateUtil.getStartDateFromYear(yearA), | |
186 DateUtil.getEndDateFromYear(yearB) | |
187 ); | |
188 } | |
189 else { | |
190 log.warn("ASLP: Unknown SQ-time string: '" + interval + | |
191 "'. Ignored."); | |
192 } | |
193 } | |
194 catch (ParseException pe) { | |
195 log.error("ASLP: Could not parse SQ-time string: '" + | |
196 interval + "'. Ignored.", pe); | |
197 } | |
198 | |
199 return true; | |
200 | |
201 } | |
202 | |
203 return false; | |
204 } | |
205 | |
206 | |
167 public boolean handleColumnNames(String line) throws LineParserException { | 207 public boolean handleColumnNames(String line) throws LineParserException { |
168 Matcher m = META_COLUMN_NAMES.matcher(line); | 208 Matcher m = META_COLUMN_NAMES.matcher(line); |
169 | 209 |
170 if (m.matches()) { | 210 if (m.matches()) { |
171 columnNames = line.split(SEPERATOR_CHAR); | 211 columnNames = line.split(SEPERATOR_CHAR); |