# HG changeset patch # User mschaefer # Date 1524489528 -7200 # Node ID 6e5ff436febe65672d53ac7cd3c1bfb038983d12 # Parent baef34f54ee216fae0ef959e96e30088172b4818 Added datacage select and chart display for TKH series loaded from database diff -r baef34f54ee2 -r 6e5ff436febe artifacts/doc/conf/conf.xml --- a/artifacts/doc/conf/conf.xml Fri Apr 20 16:04:34 2018 +0200 +++ b/artifacts/doc/conf/conf.xml Mon Apr 23 15:18:48 2018 +0200 @@ -181,6 +181,10 @@ ttl="3600000" artifact="org.dive4elements.river.artifacts.uinfo.UINFOArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory + org.dive4elements.artifactdatabase.DefaultArtifactFactory + org.dive4elements.artifactdatabase.DefaultUserFactory diff -r baef34f54ee2 -r 6e5ff436febe artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml --- a/artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml Fri Apr 20 16:04:34 2018 +0200 +++ b/artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml Mon Apr 23 15:18:48 2018 +0200 @@ -55,6 +55,8 @@ + + \ No newline at end of file diff -r baef34f54ee2 -r 6e5ff436febe artifacts/doc/conf/meta-data.xml --- a/artifacts/doc/conf/meta-data.xml Fri Apr 20 16:04:34 2018 +0200 +++ b/artifacts/doc/conf/meta-data.xml Mon Apr 23 15:18:48 2018 +0200 @@ -279,14 +279,14 @@ - + - - + + @@ -1307,50 +1307,50 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1626,6 +1626,10 @@ + + + + @@ -3460,5 +3464,30 @@ + + + + + SELECT tc.tkh_id AS tkh_id, tc.id AS tkh_col_id, tc.name AS tkh_col_name, + MIN(t.filename) AS tkh_name, MIN(tv.station) AS km_min, MAX(tv.station) AS km_max, + MIN(t.filename) || '<br />' || MIN(t.sounding_info) || '<br />' || MIN(t.evaluation_by) AS info + FROM tkh_column tc INNER JOIN tkh t ON tc.tkh_id=t.id + INNER JOIN tkh_values tv ON tc.id=tv.tkh_column_id + WHERE t.river_id=${river_id} + GROUP BY tc.tkh_id, tc.id + ORDER BY tc.id + + + + + + + + + + + + + \ No newline at end of file diff -r baef34f54ee2 -r 6e5ff436febe artifacts/doc/conf/themes.xml --- a/artifacts/doc/conf/themes.xml Fri Apr 20 16:04:34 2018 +0200 +++ b/artifacts/doc/conf/themes.xml Mon Apr 23 15:18:48 2018 +0200 @@ -440,5 +440,7 @@ + + \ No newline at end of file diff -r baef34f54ee2 -r 6e5ff436febe artifacts/doc/conf/themes/default.xml --- a/artifacts/doc/conf/themes/default.xml Fri Apr 20 16:04:34 2018 +0200 +++ b/artifacts/doc/conf/themes/default.xml Mon Apr 23 15:18:48 2018 +0200 @@ -2956,7 +2956,7 @@ - + @@ -2992,5 +2992,16 @@ - + + + + + + + + + + + + \ No newline at end of file diff -r baef34f54ee2 -r 6e5ff436febe artifacts/doc/conf/themes/second.xml --- a/artifacts/doc/conf/themes/second.xml Fri Apr 20 16:04:34 2018 +0200 +++ b/artifacts/doc/conf/themes/second.xml Mon Apr 23 15:18:48 2018 +0200 @@ -2981,4 +2981,15 @@ + + + + + + + + + + + \ No newline at end of file diff -r baef34f54ee2 -r 6e5ff436febe artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/PredefinedTkhProcessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/PredefinedTkhProcessor.java Mon Apr 23 15:18:48 2018 +0200 @@ -0,0 +1,118 @@ +/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.artifacts.sinfo.common; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.log4j.Logger; +import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; +import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.exports.DiagramGenerator; +import org.dive4elements.river.exports.StyledSeriesBuilder; +import org.dive4elements.river.jfree.StyledAreaSeriesCollection; +import org.dive4elements.river.jfree.StyledXYSeries; +import org.dive4elements.river.themes.ThemeDocument; + +/** + * Processor to generate a data series for tkh data loaded from the database + * + * @author Matthias Schäfer + * + */ +public class PredefinedTkhProcessor extends AbstractSInfoProcessor { + + private final static Logger log = Logger.getLogger(PredefinedTkhProcessor.class); + + public static final String FACET_PREDEFINED_TKH = "sinfo_facet_predefined_tkh"; + + private static final String I18N_AXIS_LABEL = "sinfo.chart.tkh.section.yaxis.label"; + + private static final String I18N_FACET_TKH_DESCRIPTION = "sinfo.facet.tkh.description"; + + private static final String SINFO_CHART_TKH_YAXIS_LABEL = "sinfo.chart.tkh.yaxis.label"; + + private static final Set HANDLED_FACET_TYPES = new HashSet<>(); + + static { + HANDLED_FACET_TYPES.add(FACET_PREDEFINED_TKH); + } + + public PredefinedTkhProcessor() { + super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES); + } + + protected String generateSeries1(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { + final CallContext context = generator.getCallContext(); + final Map metaData = bundle.getFacet().getMetaData(bundle.getArtifact(), context); + final StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); + series.putMetaData(metaData, bundle.getArtifact(), context); + + final Object raw = bundle.getData(context); + if (raw == null) { + return null; + } + if (!(raw instanceof double[][])) { + log.error("Unkown datatype: " + raw.getClass().getName()); + return null; + } + final double[][] data = (double[][]) raw; + StyledSeriesBuilder.addPoints(series, data, true); + + // REMARK: we add " " because the description is misused as id, which must be unique. + final StyledXYSeries seriesDown = new StyledXYSeries(bundle.getFacetDescription() + " ", theme); + // final double[][] pointsDown = data.getTkhDownPoints(); + final double[][] datadown = (double[][]) raw; + for (int i = 0; i <= datadown[0].length - 1; i++) + datadown[1][i] = 0; + StyledSeriesBuilder.addPoints(seriesDown, datadown, true); + + final StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(theme); + area.setMode(StyledAreaSeriesCollection.FILL_MODE.BETWEEN); + area.addSeries(series); + area.addSeries(seriesDown); + generator.addAreaSeries(area, getAxisName(), visible); + // generator.addAxisSeries(series, getAxisName(), visible); + return null; + } + + @Override + protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { + final CallContext context = generator.getCallContext(); + + final String facetName = bundle.getFacetName(); + final AbstractTkhCalculationResult data = (AbstractTkhCalculationResult) bundle.getData(context); + if (data == null) { + // Check has been here before so we keep it for security reasons + // this should never happen though. + throw new IllegalStateException("Data is null for facet: " + facetName); + } + + final StyledXYSeries seriesUp = new StyledXYSeries(bundle.getFacetDescription(), theme); + final double[][] pointsUp = data.getTkhUpPoints(); + StyledSeriesBuilder.addPoints(seriesUp, pointsUp, true); + + // REMARK: we add " " because the description is misused as id, which must be unique. + final StyledXYSeries seriesDown = new StyledXYSeries(bundle.getFacetDescription() + " ", theme); + final double[][] pointsDown = data.getTkhDownPoints(); + StyledSeriesBuilder.addPoints(seriesDown, pointsDown, true); + + final StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(theme); + area.setMode(StyledAreaSeriesCollection.FILL_MODE.BETWEEN); + area.addSeries(seriesUp); + area.addSeries(seriesDown); + + generator.addAreaSeries(area, getAxisName(), visible); + + return null; + } +} \ No newline at end of file diff -r baef34f54ee2 -r 6e5ff436febe artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedtkh/PredefinedTkhArtifact.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedtkh/PredefinedTkhArtifact.java Mon Apr 23 15:18:48 2018 +0200 @@ -0,0 +1,129 @@ +/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.artifacts.sinfo.predefinedtkh; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; +import org.dive4elements.artifactdatabase.state.DefaultOutput; +import org.dive4elements.artifactdatabase.state.Facet; +import org.dive4elements.artifactdatabase.state.FacetActivity; +import org.dive4elements.artifacts.Artifact; +import org.dive4elements.artifacts.ArtifactFactory; +import org.dive4elements.artifacts.CallMeta; +import org.dive4elements.artifacts.common.utils.XMLUtils; +import org.dive4elements.river.artifacts.AbstractStaticStateArtifact; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.model.FacetTypes; +import org.dive4elements.river.artifacts.sinfo.common.PredefinedTkhProcessor; +import org.dive4elements.river.artifacts.states.StaticState; +import org.dive4elements.river.model.sinfo.TkhColumn; +import org.w3c.dom.Document; + +/** + * Display of a tkh data series loaded from database + * + * @author Matthias Schäfer + * + */ +public class PredefinedTkhArtifact extends AbstractStaticStateArtifact implements FacetTypes { + + /** The log for this class. */ + private static Logger log = Logger.getLogger(PredefinedTkhArtifact.class); + + /** Artifact name. */ + private static final String NAME = "tkhx"; + + static { + // TODO: Move to configuration. + FacetActivity.Registry.getInstance().register(NAME, FacetActivity.INACTIVE); + } + + public static final String STATIC_STATE_NAME = "state.predefined_tkh.static"; + + /** + * Trivial Constructor. + */ + public PredefinedTkhArtifact() { + log.debug("new PredefinedTkhArtifact"); + } + + @Override + public String getName() { + return NAME; + } + + /** + * Gets called from factory, to set things up. + */ + @Override + public void setup(final String identifier, final ArtifactFactory factory, final Object context, final CallMeta callMeta, final Document data, + final List loadFacets) { + + log.debug("PredefinedTkhArtifact.setup"); + + if (log.isDebugEnabled()) { + log.debug(XMLUtils.toString(data)); + } + + final String code = getDatacageIDValue(data); + + createFacets(callMeta, code); + + super.setup(identifier, factory, context, callMeta, data, loadFacets); + } + + private void createFacets(final CallMeta callMeta, final String code) { + if (code == null) + return; + final String[] parts = code.split("-"); + if (parts.length < 3) { + log.error("Invalid datacage ID '" + code + "'"); + return; + } + addStringData("tkh_col_id", parts[1]); + addStringData("tkh_id", parts[2]); + final TkhColumn tkhcol = TkhColumn.getTkhColumnById(Integer.parseInt(parts[1])); + + final ArrayList facets = new ArrayList<>(1); + facets.add(new PredefinedTkhFacet(PredefinedTkhProcessor.FACET_PREDEFINED_TKH, tkhcol.getName() + " (" + tkhcol.getTkh().getFilename() + ")")); + addFacets(STATIC_STATE_NAME, facets); + } + + @Override + protected void initStaticState() { + + log.debug("initStaticState " + getName() + " " + identifier()); + + final StaticState state = new StaticState(STATIC_STATE_NAME); + final DefaultOutput output = new DefaultOutput("general", "general", "image/png", "chart"); + + final List facets = getFacets(STATIC_STATE_NAME); + output.addFacets(facets); + state.addOutput(output); + + setStaticState(state); + } + + @Override + protected void initialize(final Artifact artifact, final Object context, final CallMeta meta) { + // do not clone facets, etc. from master artifact + + log.debug("initialize"); + importData((D4EArtifact) artifact, "river"); + importData((D4EArtifact) artifact, "ld_from"); + importData((D4EArtifact) artifact, "ld_to"); + + log.debug("ld_from " + getDataAsString("ld_from")); + log.debug("ld_to " + getDataAsString("ld_to")); + } +} \ No newline at end of file diff -r baef34f54ee2 -r 6e5ff436febe artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedtkh/PredefinedTkhColumnAccess.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedtkh/PredefinedTkhColumnAccess.java Mon Apr 23 15:18:48 2018 +0200 @@ -0,0 +1,68 @@ +/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.artifacts.sinfo.predefinedtkh; + +import org.apache.commons.lang.math.DoubleRange; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.RangeAccess; + +/** + * Access to the database loaded tkh column artifact data + * + * @author Matthias Schäfer + */ +final class PredefinedTkhColumnAccess extends RangeAccess { + + /***** FIELDS *****/ + + private Integer columnId; + + private Integer tkhId; + + private String name; + + + /***** CONSTRUCTORS *****/ + + public PredefinedTkhColumnAccess(final D4EArtifact artifact) { + super(artifact); + } + + + /***** METHDOS *****/ + + public DoubleRange getRange() { + final double from = getFrom(); + final double to = getTo(); + return new DoubleRange(from, to); + } + + public Integer getTkhId() { + if (this.tkhId == null) { + this.tkhId = getInteger("tkh_id"); + } + return this.columnId; + } + + public Integer getColumnId() { + if (this.columnId == null) { + this.columnId = getInteger("tkh_col_id"); + } + return this.columnId; + } + + public String getName() { + if (this.name == null) { + this.name = getString("name"); + } + return this.name; + } +} \ No newline at end of file diff -r baef34f54ee2 -r 6e5ff436febe artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedtkh/PredefinedTkhFacet.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedtkh/PredefinedTkhFacet.java Mon Apr 23 15:18:48 2018 +0200 @@ -0,0 +1,111 @@ +/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.artifacts.sinfo.predefinedtkh; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.dive4elements.artifacts.Artifact; +import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.common.GeneralResultType; +import org.dive4elements.river.artifacts.common.ResultRow; +import org.dive4elements.river.artifacts.model.BlackboardDataFacet; +import org.dive4elements.river.artifacts.model.Calculation; +import org.dive4elements.river.artifacts.model.FacetTypes; +import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; +import org.dive4elements.river.artifacts.sinfo.tkhcalculation.SoilKind; +import org.dive4elements.river.artifacts.sinfo.tkhcalculation.SoilKindKmValueFinder; +import org.dive4elements.river.model.sinfo.TkhColumn; +import org.dive4elements.river.model.sinfo.TkhValue; + +/** + * Facet for a tkh value series loaded from the database + * + * @author Matthias Schäfer + */ +public class PredefinedTkhFacet extends BlackboardDataFacet implements FacetTypes { + + private static final long serialVersionUID = 5508868967789155306L; + + public PredefinedTkhFacet(final String name, final String description) { + super(0, name, description); + + this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); + this.metaData.put("Y", "chart.tkh.section.yaxis.label"); + } + + /** + * Returns the data this facet requires. + * + * @param artifact + * the owner artifact. + * @param context + * the CallContext (ignored). + * + * @return + * the data as PredefinedTkhQueryCalculationResult + */ + @Override + public Object getData(final Artifact artifact, final CallContext context) { + + final PredefinedTkhColumnAccess access = new PredefinedTkhColumnAccess((D4EArtifact) artifact); + final TkhColumn series = TkhColumn.getTkhColumnById(access.getColumnId()); + final List tkhValues = TkhValue.getTkhValues(series, access.getFrom(true), access.getTo(true)); + final Calculation problems = new Calculation(); + final SoilKindKmValueFinder soilKindFinder = SoilKindKmValueFinder.loadValues(problems, access.getRiver(), access.getRange()); + + final Collection rows = new ArrayList<>(); + SoilKind bedMobility = SoilKind.mobil; + for (final TkhValue tkhValue : tkhValues) { + final ResultRow row = ResultRow.create(); + row.putValue(GeneralResultType.station, tkhValue.getStation().doubleValue()); + if (soilKindFinder != null) + bedMobility = soilKindFinder.findSoilKind(tkhValue.getStation().doubleValue()); + row.putValue(SInfoResultType.soilkind, bedMobility); + final double tkh = tkhValue(tkhValue.getTkheight()) * 100; + row.putValue(SInfoResultType.tkh, tkh); + switch (bedMobility) { + case starr: + row.putValue(SInfoResultType.tkhup, tkh); + row.putValue(SInfoResultType.tkhdown, 0.0); + break; + case mobil: + default: + row.putValue(SInfoResultType.tkhup, tkh / 2); + row.putValue(SInfoResultType.tkhdown, -tkh / 2); + break; + } + rows.add(row); + } + return new PredefinedTkhQueryCalculationResult(series.getName(), rows); + } + + private double tkhValue(final Double value) { + if (value != null) + return value.doubleValue(); + else + return Double.NaN; + } + + /** + * Create a deep copy of this Facet. + * + * @return a deep copy. + */ + @Override + public PredefinedTkhFacet deepCopy() { + final PredefinedTkhFacet copy = new PredefinedTkhFacet(this.name, this.description); + copy.set(this); + return copy; + } +} \ No newline at end of file diff -r baef34f54ee2 -r 6e5ff436febe artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedtkh/PredefinedTkhQueryCalculationResult.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedtkh/PredefinedTkhQueryCalculationResult.java Mon Apr 23 15:18:48 2018 +0200 @@ -0,0 +1,29 @@ +/* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ +package org.dive4elements.river.artifacts.sinfo.predefinedtkh; + +import java.util.Collection; + +import org.dive4elements.river.artifacts.common.ResultRow; +import org.dive4elements.river.artifacts.sinfo.common.AbstractTkhCalculationResult; + +/** + * Contains the results of a database query of a tkh series + * + * @author Matthias Schäfer + */ +final class PredefinedTkhQueryCalculationResult extends AbstractTkhCalculationResult { + + private static final long serialVersionUID = 1L; + + public PredefinedTkhQueryCalculationResult(final String label, final Collection rows) { + super(label, null, true, rows); + } +} \ No newline at end of file diff -r baef34f54ee2 -r 6e5ff436febe artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/SoilKindKmValueFinder.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/SoilKindKmValueFinder.java Fri Apr 20 16:04:34 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/SoilKindKmValueFinder.java Mon Apr 23 15:18:48 2018 +0200 @@ -26,7 +26,7 @@ /** * @author Matthias Schäfer */ -final class SoilKindKmValueFinder { +public final class SoilKindKmValueFinder { /***** FIELDS *****/ diff -r baef34f54ee2 -r 6e5ff436febe backend/src/main/java/org/dive4elements/river/model/sinfo/BedMobility.java --- a/backend/src/main/java/org/dive4elements/river/model/sinfo/BedMobility.java Fri Apr 20 16:04:34 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/BedMobility.java Mon Apr 23 15:18:48 2018 +0200 @@ -25,7 +25,10 @@ import javax.persistence.SequenceGenerator; import javax.persistence.Table; +import org.dive4elements.river.backend.SessionHolder; import org.dive4elements.river.model.River; +import org.hibernate.Query; +import org.hibernate.Session; /** * Hibernate binding for the DB table bed_mobility @@ -134,4 +137,18 @@ public void addValue(final BedMobilityValue value) { this.values.add(value); } + + /** + * Selects a bed mobility series of a river from the database + */ + public static BedMobility queryForRiver(final River river) { + final Session session = SessionHolder.HOLDER.get(); + final Query query = session.createQuery("FROM BedMobilty WHERE river=:river"); + query.setParameter("river", river); + final List rows = query.list(); + if (rows != null) + return rows.get(0); + else + return null; + } } \ No newline at end of file diff -r baef34f54ee2 -r 6e5ff436febe backend/src/main/java/org/dive4elements/river/model/sinfo/BedMobilityValue.java --- a/backend/src/main/java/org/dive4elements/river/model/sinfo/BedMobilityValue.java Fri Apr 20 16:04:34 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/BedMobilityValue.java Mon Apr 23 15:18:48 2018 +0200 @@ -11,6 +11,7 @@ package org.dive4elements.river.model.sinfo; import java.io.Serializable; +import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; @@ -22,6 +23,10 @@ import javax.persistence.SequenceGenerator; import javax.persistence.Table; +import org.dive4elements.river.backend.SessionHolder; +import org.hibernate.Query; +import org.hibernate.Session; + /** * Hibernate binding for the DB table bed_mobility_values @@ -106,4 +111,17 @@ public void setMoving(final int bedMoving) { this.moving = bedMoving; } + + /** + * Selects the bed mobility of a series in a km range from the database + */ + public static List getValues(final BedMobility parent, final double kmLo, final double kmHi) { + final Session session = SessionHolder.HOLDER.get(); + final Query query = session.createQuery("FROM BedMobilityValue WHERE (bedMobility=:parent)" + + " AND (station >= :kmLo - 0.0001) AND (station <= :kmHi + 0.0001)"); + query.setParameter("parent", parent); + query.setParameter("kmLo", new Double(kmLo)); + query.setParameter("kmHi", new Double(kmHi)); + return query.list(); + } } diff -r baef34f54ee2 -r 6e5ff436febe backend/src/main/java/org/dive4elements/river/model/sinfo/Tkh.java --- a/backend/src/main/java/org/dive4elements/river/model/sinfo/Tkh.java Fri Apr 20 16:04:34 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/Tkh.java Mon Apr 23 15:18:48 2018 +0200 @@ -26,7 +26,10 @@ import javax.persistence.SequenceGenerator; import javax.persistence.Table; +import org.dive4elements.river.backend.SessionHolder; import org.dive4elements.river.model.River; +import org.hibernate.Query; +import org.hibernate.Session; /** * Hibernate binding for the DB table tkh @@ -171,4 +174,15 @@ public void addColumn(final TkhColumn value) { this.columns.add(value); } + + /** + * Selects a tkh series by id from the database + */ + public static Tkh getTkhById(final int id) { + final Session session = SessionHolder.HOLDER.get(); + final Query query = session.createQuery("FROM Tkh WHERE id=:id"); + query.setParameter("id", id); + final List rows = query.list(); + return (rows != null) ? rows.get(0) : null; + } } \ No newline at end of file diff -r baef34f54ee2 -r 6e5ff436febe backend/src/main/java/org/dive4elements/river/model/sinfo/TkhColumn.java --- a/backend/src/main/java/org/dive4elements/river/model/sinfo/TkhColumn.java Fri Apr 20 16:04:34 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/TkhColumn.java Mon Apr 23 15:18:48 2018 +0200 @@ -24,6 +24,10 @@ import javax.persistence.SequenceGenerator; import javax.persistence.Table; +import org.dive4elements.river.backend.SessionHolder; +import org.hibernate.Query; +import org.hibernate.Session; + /** * Hibernate binding for the DB table tkh_column * @@ -103,4 +107,15 @@ public void addValue(final TkhValue value) { this.values.add(value); } + + /** + * Selects a tkh series column by id from the database + */ + public static TkhColumn getTkhColumnById(final int id) { + final Session session = SessionHolder.HOLDER.get(); + final Query query = session.createQuery("FROM TkhColumn WHERE id=:id"); + query.setParameter("id", id); + final List rows = query.list(); + return (rows != null) ? rows.get(0) : null; + } } diff -r baef34f54ee2 -r 6e5ff436febe backend/src/main/java/org/dive4elements/river/model/sinfo/TkhValue.java --- a/backend/src/main/java/org/dive4elements/river/model/sinfo/TkhValue.java Fri Apr 20 16:04:34 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/TkhValue.java Mon Apr 23 15:18:48 2018 +0200 @@ -11,6 +11,7 @@ package org.dive4elements.river.model.sinfo; import java.io.Serializable; +import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; @@ -22,6 +23,9 @@ import javax.persistence.SequenceGenerator; import javax.persistence.Table; +import org.dive4elements.river.backend.SessionHolder; +import org.hibernate.Query; +import org.hibernate.Session; /** * Hibernate binding for the DB table tkh_values @@ -109,4 +113,17 @@ public void setTkheight(final Double tkheight) { this.tkheight = tkheight; } + + /** + * Selects the tkh values of a tkh series column in a km range from the database + */ + public static List getTkhValues(final TkhColumn parent, final double kmLo, final double kmHi) { + final Session session = SessionHolder.HOLDER.get(); + final Query query = session.createQuery("FROM TkhValue WHERE (tkhColumn=:parent)" + + " AND (station >= :kmLo - 0.0001) AND (station <= :kmHi + 0.0001)"); + query.setParameter("parent", parent); + query.setParameter("kmLo", new Double(kmLo)); + query.setParameter("kmHi", new Double(kmHi)); + return query.list(); + } } diff -r baef34f54ee2 -r 6e5ff436febe gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java --- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Fri Apr 20 16:04:34 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Mon Apr 23 15:18:48 2018 +0200 @@ -1485,12 +1485,14 @@ String sinfo_additional_ls_withQ(); String sinfo_additional_ls_withoutQ(); - + + String sinfo_predefined_tkh(); + String uinfo(); - + String uinfo_salix_line_export(); String uinfo_vegetation_zones_export(); - + String uinfo_inundation_duration_export(); } \ No newline at end of file diff -r baef34f54ee2 -r 6e5ff436febe gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties --- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Fri Apr 20 16:04:34 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Mon Apr 23 15:18:48 2018 +0200 @@ -792,6 +792,8 @@ sinfo_additional_ls_withQ = mit Abfluss sinfo_additional_ls_withoutQ = ohne Abfluss +sinfo_predefined_tkh = Transportk\u00f6rperh\u00f6hen + uinfo = U-INFO uinfo_inundation_duration_export = \u00dcberflutungsdauern Export uinfo_salix_line_export = Salix-Linie Export diff -r baef34f54ee2 -r 6e5ff436febe gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties --- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Fri Apr 20 16:04:34 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Mon Apr 23 15:18:48 2018 +0200 @@ -792,6 +792,8 @@ sinfo_additional_ls_withQ = mit Abfluss sinfo_additional_ls_withoutQ = ohne Abfluss +sinfo_predefined_tkh = Transportk\u00f6rperh\u00f6hen + uinfo = U-INFO uinfo_inundation_duration_export = \u00dcberflutungsdauern Export uinfo_salix_line_export = Salix-Linie Export