Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/SQRelationParser.java @ 8412:17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 15 Oct 2014 19:20:26 +0200 |
parents | 3bb1c62ad732 |
children | 11c88a2f695a |
comparison
equal
deleted
inserted
replaced
8411:b8c6cb36607e | 8412:17db08570637 |
---|---|
17 import java.util.regex.Matcher; | 17 import java.util.regex.Matcher; |
18 import java.util.regex.Pattern; | 18 import java.util.regex.Pattern; |
19 | 19 |
20 import org.apache.log4j.Logger; | 20 import org.apache.log4j.Logger; |
21 | 21 |
22 import org.dive4elements.river.model.River; | |
23 import org.dive4elements.river.model.MeasurementStation; | |
24 | |
25 import org.dive4elements.river.importer.ImporterSession; | |
22 import org.dive4elements.river.importer.ImportSQRelation; | 26 import org.dive4elements.river.importer.ImportSQRelation; |
23 import org.dive4elements.river.importer.ImportSQRelationValue; | 27 import org.dive4elements.river.importer.ImportSQRelationValue; |
24 import org.dive4elements.river.importer.ImportTimeInterval; | 28 import org.dive4elements.river.importer.ImportTimeInterval; |
25 import org.dive4elements.river.backend.utils.DateUtil; | 29 import org.dive4elements.river.backend.utils.DateUtil; |
26 | 30 |
34 Pattern.compile(".*Zeitraum.*\\s(\\w*)-(\\w*).*"); | 38 Pattern.compile(".*Zeitraum.*\\s(\\w*)-(\\w*).*"); |
35 | 39 |
36 private static final NumberFormat nf = | 40 private static final NumberFormat nf = |
37 NumberFormat.getInstance(DEFAULT_LOCALE); | 41 NumberFormat.getInstance(DEFAULT_LOCALE); |
38 | 42 |
39 | |
40 private List<ImportSQRelation> relations; | 43 private List<ImportSQRelation> relations; |
41 | 44 |
42 private ImportSQRelation current; | 45 private ImportSQRelation current; |
43 | 46 |
44 private String currentDescription; | 47 private String currentDescription; |
45 | 48 |
49 protected River river; | |
46 | 50 |
47 public SQRelationParser() { | 51 public SQRelationParser(River river) { |
48 relations = new ArrayList<ImportSQRelation>(); | 52 relations = new ArrayList<ImportSQRelation>(); |
53 this.river = river; | |
49 } | 54 } |
50 | 55 |
51 | 56 |
52 public List<ImportSQRelation> getSQRelations() { | 57 public List<ImportSQRelation> getSQRelations() { |
53 return relations; | 58 return relations; |
142 log.error("Incomplete SQ-relation row (missing a, b, Qmax or parameter): " | 147 log.error("Incomplete SQ-relation row (missing a, b, Qmax or parameter): " |
143 + line); | 148 + line); |
144 } | 149 } |
145 return; | 150 return; |
146 } | 151 } |
147 current.addValue(new ImportSQRelationValue( | 152 |
148 cols[1], | 153 List<MeasurementStation> ms = |
149 km, | 154 ImporterSession.getInstance().getMeasurementStations( |
150 a, | 155 river, km); |
151 b, | 156 |
152 qMax, | 157 if (ms != null && !ms.isEmpty()) { |
153 rSq, | 158 current.addValue(new ImportSQRelationValue( |
154 nTot, | 159 cols[1], |
155 nOutlier, | 160 ms.get(0), |
156 cFer, | 161 a, |
157 cDuan)); | 162 b, |
163 qMax, | |
164 rSq, | |
165 nTot, | |
166 nOutlier, | |
167 cFer, | |
168 cDuan | |
169 )); | |
170 } | |
158 } | 171 } |
159 | 172 |
160 private Double parseDouble(String value, String line) { | 173 private Double parseDouble(String value, String line) { |
161 Double result = null; | 174 Double result = null; |
162 try { | 175 try { |