[PATCH] Sediment load: Fetch kind of sediment load from database to tell if it is official or not

Wald Commits scm-commit at wald.intevation.org
Fri Jul 18 17:43:32 CEST 2014


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1405698207 -7200
# Node ID fbe3ba5a480ebc100a54106fba7809ceadef00e6
# Parent  555dc5a9b28291447f0c0051375249b0b284b096
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.

diff -r 555dc5a9b282 -r fbe3ba5a480e artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Fri Jul 18 16:05:21 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Fri Jul 18 17:43:27 2014 +0200
@@ -102,6 +102,7 @@
     public static class Load implements Serializable {
 
         private int id;
+        private int kind;
 
         private String description;
 
@@ -111,8 +112,15 @@
         public Load() {
         }
 
-        public Load(int id, String description, Date startTime, Date stopTime) {
+        public Load(
+            int    id, 
+            int    kind,
+            String description,
+            Date   startTime,
+            Date   stopTime
+        ) {
             this.id          = id;
+            this.kind        = kind;
             this.description = description;
             this.startTime   = startTime;
             this.stopTime    = stopTime;
@@ -122,6 +130,10 @@
             return id;
         }
 
+        public int getKind() {
+            return kind;
+        }
+
         public String getDescription() {
             return description;
         }
diff -r 555dc5a9b282 -r fbe3ba5a480e artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFactory.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFactory.java	Fri Jul 18 16:05:21 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFactory.java	Fri Jul 18 17:43:27 2014 +0200
@@ -32,6 +32,7 @@
     public static final String SQL_LOAD_RIVER_SEDIMENT_LOADS =
         "SELECT " +
           "sl.id AS sl_id, " +
+          "sl.kind AS sl_kind, " +
           "sl.description AS sl_description, " +
           "ti.start_time AS ti_start_time, " +
           "ti.stop_time AS ti_stoptime, " +
@@ -45,8 +46,7 @@
           "JOIN time_intervals ti ON sl.time_interval_id = ti.id " +
           "JOIN grain_fraction gf ON sl.grain_fraction_id = gf.id " +
           "JOIN measurement_station ms ON slv.measurement_station_id = ms.id " +
-          "JOIN ranges rng ON ms.range_id = rng.id " +
-          "JOIN rivers r ON rng.river_id = r.id " +
+          "JOIN rivers r ON ms.river_id = r.id " +
         "WHERE r.name = :river " +
         "ORDER BY sl.id";
 
@@ -102,6 +102,7 @@
 
         SQLQuery sqlQuery = session.createSQLQuery(SQL_LOAD_RIVER_SEDIMENT_LOADS)
             .addScalar("sl_id",          StandardBasicTypes.INTEGER)
+            .addScalar("sl_kind",        StandardBasicTypes.INTEGER)
             .addScalar("sl_description", StandardBasicTypes.STRING)
             .addScalar("ti_start_time",  StandardBasicTypes.TIMESTAMP)
             .addScalar("ti_stop_time",   StandardBasicTypes.TIMESTAMP)
@@ -123,18 +124,20 @@
             Object [] row = (Object [])iter.next();
 
             Integer   sl_id            = (Integer)row[0];
-            String    sl_description   = (String)row[1];
-            Timestamp ti_start_time    = (Timestamp)row[2];
-            Timestamp ti_stop_time     = (Timestamp)row[3];
-            Double    slv_value        = (Double)row[4];
-            String    gf_name          = (String)row[5];
-            Integer   ms_id            = (Integer)row[6];
-            Double    ms_station       = (Double)row[7];
-            String    ms_type          = (String)row[8];
+            Integer   sl_kind          = (Integer)row[1];
+            String    sl_description   = (String)row[2];
+            Timestamp ti_start_time    = (Timestamp)row[3];
+            Timestamp ti_stop_time     = (Timestamp)row[4];
+            Double    slv_value        = (Double)row[5];
+            String    gf_name          = (String)row[6];
+            Integer   ms_id            = (Integer)row[7];
+            Double    ms_station       = (Double)row[8];
+            String    ms_type          = (String)row[9];
 
             if (load == null || load.getId() != sl_id) {
                 load = new SedimentLoadData.Load(
-                    sl_id, sl_description, ti_start_time, ti_stop_time);
+                    sl_id, sl_kind, sl_description,
+                    ti_start_time, ti_stop_time);
 
                 // Grain fractions only change when a new sediment load starts.
                 grainFractionIndex =


More information about the Dive4Elements-commits mailing list