[Dive4elements-commits] [PATCH 2 of 8] ImportWaterlevel*: Remove connection to orm-based waterlevels (WIP)

Wald Commits scm-commit at wald.intevation.org
Tue Mar 12 09:34:31 CET 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1363010839 -3600
# Node ID 8320427ecd5c3ba1e474a7da9ee1ff6e775c949c
# Parent  a981222b626047280c02a352eb6400c2e4ad14e3
ImportWaterlevel*: Remove connection to orm-based waterlevels (WIP).

diff -r a981222b6260 -r 8320427ecd5c flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevel.java
--- 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 :
diff -r a981222b6260 -r 8320427ecd5c flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelDifference.java
--- 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 :
diff -r a981222b6260 -r 8320427ecd5c flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelDifferenceColumn.java
--- 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");
diff -r a981222b6260 -r 8320427ecd5c flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelDifferenceValue.java
--- 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();


More information about the Dive4elements-commits mailing list