Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/parsers/MeasurementStationsParser.java @ 5451:278d8759c92b
Allow null values in measurement_station columns without 'not null' constraints.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 27 Mar 2013 11:47:56 +0100 |
parents | f63b39799d2d |
children | de3c77d35fef |
comparison
equal
deleted
inserted
replaced
5450:84beabb3897c | 5451:278d8759c92b |
---|---|
110 throw new MeasurementStationParserException( | 110 throw new MeasurementStationParserException( |
111 "unable to parse station: " + e.getMessage()); | 111 "unable to parse station: " + e.getMessage()); |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 protected ImportRange getRange(String[] cols) | 115 protected ImportRange getRange(String[] cols) { |
116 throws MeasurementStationParserException { | |
117 if (cols[4] == null || cols[4].length() == 0) { | 116 if (cols[4] == null || cols[4].length() == 0) { |
118 throw new MeasurementStationParserException("invalid lower range '" | 117 log.warn("No upper value for range found in '" + cols[4] + "'"); |
119 + cols[4] + "'"); | 118 return null; |
120 } | 119 } |
121 | 120 |
122 if (cols[5] == null || cols[5].length() == 0) { | 121 if (cols[5] == null || cols[5].length() == 0) { |
123 throw new MeasurementStationParserException("invalid lower range '" | 122 log.warn("No upper value for range found in '" + cols[5] + "'"); |
124 + cols[5] + "'"); | 123 return null; |
125 } | 124 } |
126 | 125 |
127 try { | 126 try { |
128 double lower = getDouble(cols[4]); | 127 double lower = getDouble(cols[4]); |
129 double upper = getDouble(cols[5]); | 128 double upper = getDouble(cols[5]); |
130 | 129 |
131 return new ImportRange(new BigDecimal(lower), new BigDecimal(upper)); | 130 return new ImportRange(new BigDecimal(lower), new BigDecimal(upper)); |
132 } | 131 } |
133 catch (ParseException e) { | 132 catch (ParseException e) { |
134 throw new MeasurementStationParserException( | 133 log.warn("unable to parse range: " + e.getMessage()); |
135 "unable to parse range: " + e.getMessage()); | 134 return null; |
136 } | 135 } |
137 } | 136 } |
138 | 137 |
139 protected String getMeasurementType(String[] cols) | 138 protected String getMeasurementType(String[] cols) |
140 throws MeasurementStationParserException { | 139 throws MeasurementStationParserException { |
148 | 147 |
149 protected String getRiverside(String[] cols) { | 148 protected String getRiverside(String[] cols) { |
150 return cols[3]; | 149 return cols[3]; |
151 } | 150 } |
152 | 151 |
153 protected String getGauge(String[] cols) | 152 protected String getGauge(String[] cols) { |
154 throws MeasurementStationParserException { | |
155 if (cols[6] == null || cols[6].length() == 0) { | 153 if (cols[6] == null || cols[6].length() == 0) { |
156 throw new MeasurementStationParserException("invalid gauge '" | 154 log.warn("invalid gauge found: '" + cols[6] + "'"); |
157 + cols[6] + "'"); | |
158 } | 155 } |
159 | 156 |
160 return cols[6]; | 157 return cols[6]; |
161 } | 158 } |
162 | 159 |
163 protected ImportTimeInterval getObservationTimerange(String[] cols) | 160 protected ImportTimeInterval getObservationTimerange(String[] cols) { |
164 throws MeasurementStationParserException { | |
165 if (cols[8] == null || cols[8].length() == 0) { | 161 if (cols[8] == null || cols[8].length() == 0) { |
166 throw new MeasurementStationParserException( | 162 log.warn("Found invalid observation time '" + cols[8] + "'"); |
167 "invalid observation time '" + cols[8] + "'"); | |
168 } | 163 } |
169 | 164 |
170 try { | 165 try { |
171 Date date = getDate(cols[8]); | 166 Date date = getDate(cols[8]); |
172 | 167 |
173 if (date != null) { | 168 if (date != null) { |
174 return new ImportTimeInterval(date); | 169 return new ImportTimeInterval(date); |
175 } | 170 } |
176 | 171 log.warn("Observation time date invalid: '" + cols[8] + "'"); |
177 throw new MeasurementStationParserException( | |
178 "invalid observation time '" + cols[8] + "'"); | |
179 } | 172 } |
180 catch (ParseException pe) { | 173 catch (ParseException pe) { |
181 throw new MeasurementStationParserException(pe.getMessage()); | 174 log.warn("Observation time date not parseable: '" + cols[8] + "'"); |
175 return null; | |
182 } | 176 } |
177 return null; | |
183 } | 178 } |
184 | 179 |
185 protected String getOperator(String[] cols) { | 180 protected String getOperator(String[] cols) { |
186 return cols[9]; | 181 return cols[9]; |
187 } | 182 } |