[PATCH] Changed bundu bzws soundings selection to single select, added bed height query variant for field bed heights
Wald Commits
scm-commit at wald.intevation.org
Wed Aug 22 09:01:14 CEST 2018
# HG changeset patch
# User mschaefer
# Date 1534921254 -7200
# Node ID 3f4215ddd6b47191b6b7dfee9ae60ab4070d3c85
# Parent e60584f2a531ea61ebf369ec3cbe17868d356bdf
Changed bundu bzws soundings selection to single select, added bed height query variant for field bed heights
diff -r e60584f2a531 -r 3f4215ddd6b4 artifacts/doc/conf/artifacts/bundu.xml
--- 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>
diff -r e60584f2a531 -r 3f4215ddd6b4 backend/src/main/java/org/dive4elements/river/model/BedHeight.java
--- 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) {
More information about the Dive4Elements-commits
mailing list