Mercurial > dive4elements > river
changeset 5228:8320427ecd5c
ImportWaterlevel*: Remove connection to orm-based waterlevels (WIP).
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 11 Mar 2013 15:07:19 +0100 (2013-03-11) |
parents | a981222b6260 |
children | 016616df35dc |
files | flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevel.java flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelDifference.java flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelDifferenceColumn.java flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelDifferenceValue.java |
diffstat | 4 files changed, 37 insertions(+), 100 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevel.java Mon Mar 11 15:01:05 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevel.java Mon Mar 11 15:07:19 2013 +0100 @@ -12,7 +12,7 @@ import de.intevation.flys.model.Unit; import de.intevation.flys.model.Waterlevel; - +/** Model-class in transition: no hibernated representative. */ public class ImportWaterlevel { private static final Logger log = Logger.getLogger(ImportWaterlevel.class); @@ -50,53 +50,5 @@ public List<ImportWaterlevelQRange> getQRanges() { return this.qRanges; } - - public void storeDependencies(River river) { - log.info("store dependencies"); - - Waterlevel peer = getPeer(river); - - if (peer != null) { - int i = 0; - - for (ImportWaterlevelQRange qRange : qRanges) { - qRange.storeDependencies(peer); - i++; - } - - log.info("stored " + i + " waterlevel q ranges"); - } - } - - public Waterlevel getPeer(River river) { - Unit u = unit != null ? unit.getPeer() : null; - if (u == null) { - log.warn("skip invalid waterlevel - no unit set!"); - return null; - } - - if (peer == null) { - Session session = ImporterSession.getInstance() - .getDatabaseSession(); - Query query = session.createQuery("from Waterlevel where " - + " river=:river and " + " unit=:unit and " - + " description=:description"); - - query.setParameter("river", river); - query.setParameter("unit", u); - query.setParameter("description", description); - - List<Waterlevel> wsts = query.list(); - if (wsts.isEmpty()) { - peer = new Waterlevel(river, u, description); - session.save(peer); - } - else { - peer = wsts.get(0); - } - } - - return peer; - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelDifference.java Mon Mar 11 15:01:05 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelDifference.java Mon Mar 11 15:07:19 2013 +0100 @@ -14,7 +14,10 @@ import de.intevation.flys.model.Unit; import de.intevation.flys.model.WaterlevelDifference; - +/** + * This Model class does not have a representive hibernated version, + * as it is in transition to be remoed. + */ public class ImportWaterlevelDifference { private static final Logger log = Logger @@ -38,58 +41,20 @@ this.unit = unit; } + public ImportUnit getUnit() { + return unit; + } + + public String getDescription() { + return description; + } + + public List<ImportWaterlevelDifferenceColumn> getColumns() { + return columns; + } + public void addValue(ImportWaterlevelDifferenceColumn column) { this.columns.add(column); } - - public void storeDependencies(River river) throws SQLException, - ConstraintViolationException { - log.info("store dependencies"); - - WaterlevelDifference peer = getPeer(river); - - if (peer != null) { - int i = 0; - - for (ImportWaterlevelDifferenceColumn column : columns) { - column.storeDependencies(peer); - i++; - } - - log.info("stored " + i + " waterlevel difference columns"); - } - } - - public WaterlevelDifference getPeer(River river) { - Unit u = unit != null ? unit.getPeer() : null; - if (u == null) { - log.warn("IWD: skip invalid waterlevel difference - no unit set!"); - return null; - } - - if (peer == null) { - Session session = ImporterSession.getInstance() - .getDatabaseSession(); - Query query = session - .createQuery("from WaterlevelDifference where " - + " river=:river and " + " unit=:unit and " - + " description=:description"); - - query.setParameter("river", river); - query.setParameter("unit", u); - query.setParameter("description", description); - - List<WaterlevelDifference> diffs = query.list(); - if (diffs.isEmpty()) { - peer = new WaterlevelDifference(river, u, description); - session.save(peer); - } - else { - peer = diffs.get(0); - } - } - - return peer; - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelDifferenceColumn.java Mon Mar 11 15:01:05 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelDifferenceColumn.java Mon Mar 11 15:07:19 2013 +0100 @@ -32,10 +32,18 @@ } + public String getDescription() { + return description; + } + + public void addValue(ImportWaterlevelDifferenceValue value) { this.values.add(value); } + public List<ImportWaterlevelDifferenceValue> getValues() { + return values; + } public void storeDependencies(WaterlevelDifference difference) { log.info("store dependencies");
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelDifferenceValue.java Mon Mar 11 15:01:05 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelDifferenceValue.java Mon Mar 11 15:07:19 2013 +0100 @@ -34,6 +34,18 @@ } + /** Get the (usually W/cm) value. */ + public Double getValue() { + return value; + } + + + /** Get the (km) station. */ + public Double getStation() { + return station; + } + + public WaterlevelDifferenceValue getPeer(WaterlevelDifferenceColumn column) { if (peer == null) { Session session = ImporterSession.getInstance().getDatabaseSession();