changeset 9447:3f4215ddd6b4

Changed bundu bzws soundings selection to single select, added bed height query variant for field bed heights
author mschaefer
date Wed, 22 Aug 2018 09:00:54 +0200
parents e60584f2a531
children d32b11d585cd
files artifacts/doc/conf/artifacts/bundu.xml backend/src/main/java/org/dive4elements/river/model/BedHeight.java
diffstat 2 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/artifacts/bundu.xml	Tue Aug 21 18:19:35 2018 +0200
+++ b/artifacts/doc/conf/artifacts/bundu.xml	Wed Aug 22 09:00:54 2018 +0200
@@ -491,7 +491,7 @@
       <condition data="calculation_mode" value="bundu_bezugswst" operator="equal"/>
     </transition>
 
-    <state id="state.bundu.wst.soundings" description="state.bundu.wst.soundings" state="org.dive4elements.river.artifacts.states.SoundingsSelectMultiple" helpText="help.state.bundu.wst.soundings">
+    <state id="state.bundu.wst.soundings" description="state.bundu.wst.soundings" state="org.dive4elements.river.artifacts.states.SoundingsSelectSingle" helpText="help.state.bundu.wst.soundings">
       <data name="soundings" type="multiattribute"/>
     </state>
 
--- a/backend/src/main/java/org/dive4elements/river/model/BedHeight.java	Tue Aug 21 18:19:35 2018 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/BedHeight.java	Wed Aug 22 09:00:54 2018 +0200
@@ -206,18 +206,30 @@
     }
 
     public static List<BedHeight> getBedHeights(final River river, final double kmLo, final double kmHi) {
+        return getBedHeights(river, kmLo, kmHi, false);
+    }
+
+    /**
+     * Fetch the soundings with values in a river km range, optionally only those that also have field 01 etc. values
+     */
+    public static List<BedHeight> getBedHeights(final River river, final double startKm, final double endKm, final boolean withHeightFieldsOnly) {
+
         final Session session = SessionHolder.HOLDER.get();
 
-        final Query query = session.createQuery("from BedHeight" + " where river=:river" + " and id in (select bedHeight.id from BedHeightValue"
-                + " where station between :kmfrom and :kmto" + " group by bedHeight.id)");
-
+        final String fieldsClause = withHeightFieldsOnly ? " AND (height01 IS NOT NULL)" : "";
+        final Query query = session.createQuery("FROM BedHeight"
+                + " WHERE (river=:river)"
+                + " AND (id IN (SELECT bedHeight.id FROM BedHeightValue"
+                + " WHERE (station BETWEEN :kmfrom - 0.0001 AND :kmto + 0.0001)"
+                + fieldsClause
+                + " GROUP BY bed_height_id))");
         query.setParameter("river", river);
-        query.setParameter("kmfrom", kmLo);
-        query.setParameter("kmto", kmHi);
+        query.setParameter("kmfrom", startKm);
+        query.setParameter("kmto", endKm);
 
         final List<BedHeight> singles = query.list();
 
-        return singles;
+        return ((singles != null) && !singles.isEmpty()) ? singles : null;
     }
 
     public static BedHeight getBedHeightById(final int id) {

http://dive4elements.wald.intevation.org