Mercurial > dive4elements > river
diff backend/src/main/java/org/dive4elements/river/importer/ImportSedimentLoadValue.java @ 8056:d86cc6a17b7a
Importer: Import sediment load at measurement stations.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 18 Jul 2014 15:37:26 +0200 |
parents | aa054f72e887 |
children | e8d2042c9639 |
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportSedimentLoadValue.java Fri Jul 18 13:03:28 2014 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/ImportSedimentLoadValue.java Fri Jul 18 15:37:26 2014 +0200 @@ -3,7 +3,6 @@ import java.util.List; import org.dive4elements.river.model.MeasurementStation; -import org.dive4elements.river.model.River; import org.dive4elements.river.model.SedimentLoad; import org.dive4elements.river.model.SedimentLoadValue; import org.hibernate.Query; @@ -13,43 +12,37 @@ private SedimentLoadValue peer; - private ImportMeasurementStation station; - private ImportSedimentLoad sedimentLoad; - private Double value; + private MeasurementStation station; + private Double value; public ImportSedimentLoadValue() { } public ImportSedimentLoadValue( - ImportMeasurementStation station, - ImportSedimentLoad sedimentLoad, - Double value + MeasurementStation station, + Double value ) { this.station = station; - this.sedimentLoad = sedimentLoad; this.value = value; } - protected SedimentLoadValue getPeer(River river) { + protected SedimentLoadValue getPeer(SedimentLoad sedimentLoad) { if (peer == null) { Session session = ImporterSession.getInstance().getDatabaseSession(); Query query = session.createQuery( "from SedimentLoadValue where " + - " station = :station and " + + " measurementStation = :station and " + " sedimentLoad = :sedimentLoad and " + " value = :value"); - MeasurementStation ms = station.getPeer(river); - SedimentLoad sl = sedimentLoad.getPeer(); - - query.setParameter("station", ms); - query.setParameter("sedimentLoad", sl); + query.setParameter("station", station); + query.setParameter("sedimentLoad", sedimentLoad); query.setParameter("value", value); List<SedimentLoadValue> values = query.list(); if (values.isEmpty()) { - peer = new SedimentLoadValue(sl, ms, value); + peer = new SedimentLoadValue(sedimentLoad, station, value); session.save(peer); } else { @@ -60,10 +53,8 @@ return peer; } - public void storeDependencies(River river) { - station.storeDependencies(river); - sedimentLoad.storeDependencies(); - getPeer(river); + public void storeDependencies(SedimentLoad sedimentLoad) { + getPeer(sedimentLoad); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :