Mercurial > dive4elements > river
changeset 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 (2013-03-27) |
parents | 84beabb3897c |
children | 5287440b57b3 |
files | flys-backend/src/main/java/de/intevation/flys/importer/ImportMeasurementStation.java flys-backend/src/main/java/de/intevation/flys/importer/parsers/MeasurementStationsParser.java |
diffstat | 2 files changed, 25 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportMeasurementStation.java Wed Mar 27 11:46:00 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportMeasurementStation.java Wed Mar 27 11:47:56 2013 +0100 @@ -58,10 +58,8 @@ try { gauge = getGaugeFromDB(); if (gauge == null) { - log.warn("Skip measurement station '" + name - + "': unable to find gauge with name '" + this.gauge + log.warn("No gauge found for measurement station '" + name + "'"); - return null; } } catch (Exception e) { @@ -70,28 +68,29 @@ Range range = this.range.getPeer(river); if (range == null) { - log.warn("Skip measurement station '" + name - + "': unable to get range"); - return null; + log.warn("No range found for measurement station'" + name + "'"); } TimeInterval observationTimerange = this.observationTimerange .getPeer(); if (observationTimerange == null) { - log.warn("Skip measurement station '" + name - + "': unable to get time interval for observation time"); - return null; + log.warn("No time range found for measurement station '" + + name + "'"); } Session session = ImporterSession.getInstance() .getDatabaseSession(); org.hibernate.Query query = session - .createQuery("FROM MeasurementStation " - + " WHERE river=:river AND station=:station"); + .createQuery( + "FROM MeasurementStation " + + "WHERE river=:river" + + " AND station=:station " + + " AND measurement_type=:measurement_type "); query.setParameter("river", river); query.setParameter("station", station); + query.setParameter("measurement_type", measurementType); List<MeasurementStation> stations = query.list();
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/MeasurementStationsParser.java Wed Mar 27 11:46:00 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/MeasurementStationsParser.java Wed Mar 27 11:47:56 2013 +0100 @@ -112,16 +112,15 @@ } } - protected ImportRange getRange(String[] cols) - throws MeasurementStationParserException { + protected ImportRange getRange(String[] cols) { if (cols[4] == null || cols[4].length() == 0) { - throw new MeasurementStationParserException("invalid lower range '" - + cols[4] + "'"); + log.warn("No upper value for range found in '" + cols[4] + "'"); + return null; } if (cols[5] == null || cols[5].length() == 0) { - throw new MeasurementStationParserException("invalid lower range '" - + cols[5] + "'"); + log.warn("No upper value for range found in '" + cols[5] + "'"); + return null; } try { @@ -131,8 +130,8 @@ return new ImportRange(new BigDecimal(lower), new BigDecimal(upper)); } catch (ParseException e) { - throw new MeasurementStationParserException( - "unable to parse range: " + e.getMessage()); + log.warn("unable to parse range: " + e.getMessage()); + return null; } } @@ -150,21 +149,17 @@ return cols[3]; } - protected String getGauge(String[] cols) - throws MeasurementStationParserException { + protected String getGauge(String[] cols) { if (cols[6] == null || cols[6].length() == 0) { - throw new MeasurementStationParserException("invalid gauge '" - + cols[6] + "'"); + log.warn("invalid gauge found: '" + cols[6] + "'"); } return cols[6]; } - protected ImportTimeInterval getObservationTimerange(String[] cols) - throws MeasurementStationParserException { + protected ImportTimeInterval getObservationTimerange(String[] cols) { if (cols[8] == null || cols[8].length() == 0) { - throw new MeasurementStationParserException( - "invalid observation time '" + cols[8] + "'"); + log.warn("Found invalid observation time '" + cols[8] + "'"); } try { @@ -173,13 +168,13 @@ if (date != null) { return new ImportTimeInterval(date); } - - throw new MeasurementStationParserException( - "invalid observation time '" + cols[8] + "'"); + log.warn("Observation time date invalid: '" + cols[8] + "'"); } catch (ParseException pe) { - throw new MeasurementStationParserException(pe.getMessage()); + log.warn("Observation time date not parseable: '" + cols[8] + "'"); + return null; } + return null; } protected String getOperator(String[] cols) {