Mercurial > dive4elements > river
changeset 8691:bfca77cbf353
(issue1750) There can be only one SQ-relation of a parameter for a time range (given by sq_relation_id) per station and some other attributes might be null.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 17 Apr 2015 14:55:42 +0200 |
parents | 11c88a2f695a |
children | 67e53dbe05d2 |
files | backend/doc/schema/postgresql-minfo.sql backend/src/main/java/org/dive4elements/river/importer/ImportSQRelationValue.java |
diffstat | 2 files changed, 7 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/backend/doc/schema/postgresql-minfo.sql Fri Apr 17 14:50:08 2015 +0200 +++ b/backend/doc/schema/postgresql-minfo.sql Fri Apr 17 14:55:42 2015 +0200 @@ -399,6 +399,7 @@ cferguson NUMERIC, cduan NUMERIC, PRIMARY KEY (id), + UNIQUE(sq_relation_id, measurement_station_id, parameter), CONSTRAINT fk_sqr_id FOREIGN KEY (sq_relation_id) REFERENCES sq_relation(id) ON DELETE CASCADE, CONSTRAINT fk_mstation_id FOREIGN KEY (measurement_station_id)
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportSQRelationValue.java Fri Apr 17 14:50:08 2015 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/ImportSQRelationValue.java Fri Apr 17 14:55:42 2015 +0200 @@ -77,29 +77,17 @@ public SQRelationValue getPeer(SQRelation owner) { if (peer == null) { Session session = ImporterSession.getInstance().getDatabaseSession(); - Query query2 = session.createQuery( + Query query = session.createQuery( "from SQRelationValue " + " where sqRelation=:owner " + - " and parameter=:parameter" + " and measurementStation=:measurementStation" + - " and a=:a" + - " and b=:b" + - " and qMax=:qMax" + - " and rSQ=:rSQ" + - " and cFerguson=:cFerguson" + - " and cDuan=:cDuan"); + " and parameter=:parameter"); - query2.setParameter("owner", owner); - query2.setString("parameter", parameter); - query2.setParameter("measurementStation", station); - query2.setBigDecimal("a", toBigDecimal(a)); - query2.setBigDecimal("b", toBigDecimal(b)); - query2.setBigDecimal("qMax", toBigDecimal(qMax)); - query2.setBigDecimal("rSQ", toBigDecimal(rSQ)); - query2.setBigDecimal("cFerguson", toBigDecimal(cFerguson)); - query2.setBigDecimal("cDuan", toBigDecimal(cDuan)); + query.setParameter("owner", owner); + query.setParameter("measurementStation", station); + query.setString("parameter", parameter); - List<SQRelationValue> values = query2.list(); + List<SQRelationValue> values = query.list(); if (values.isEmpty()) { peer = new SQRelationValue(