[PATCH] Added datacage select and chart display for river infrastructure heights loaded from database

Wald Commits scm-commit at wald.intevation.org
Mon Jun 4 11:55:33 CEST 2018


# HG changeset patch
# User mschaefer
# Date 1528106108 -7200
# Node ID a165cd63099fbd0ebcf2450ef16f68d7f1c34625
# Parent  31b3cae5de0d0c5811ff11068a8a953ffb03dc6f
Added datacage select and chart display for river infrastructure heights loaded from database

diff -r 31b3cae5de0d -r a165cd63099f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/InfrastructureHeightProcessor.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/InfrastructureHeightProcessor.java	Mon Jun 04 11:55:08 2018 +0200
@@ -0,0 +1,87 @@
+/** 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.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifactdatabase.state.Facet;
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.artifacts.CallMeta;
+import org.dive4elements.river.artifacts.resources.Resources;
+import org.dive4elements.river.artifacts.sinfo.flood_duration.InfrastructureFacet;
+import org.dive4elements.river.artifacts.sinfo.flood_duration.InfrastructureQueryCalculationResult;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.jfree.StyledXYSeries;
+import org.dive4elements.river.themes.ThemeDocument;
+
+/**
+ * Processor to generate a data series for infrastructure height data loaded from the database
+ *
+ * @author Matthias Schäfer
+ *
+ */
+public class InfrastructureHeightProcessor extends AbstractSInfoProcessor {
+
+    // private final static Logger log = Logger.getLogger(InfrastructureHeightProcessor.class);
+
+    public static final String FACET_INFRASTRUCTURE_HEIGHT = "sinfo_facet_infrastructure_height";
+
+    private static final String I18N_AXIS_LABEL = "chart.longitudinal.section.yaxis.label";
+
+    private static final String I18N_SERIES_NAME_PATTERN = "infrastructure.height.title";
+
+    private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>();
+
+    static {
+        HANDLED_FACET_TYPES.add(FACET_INFRASTRUCTURE_HEIGHT);
+    }
+
+    public InfrastructureHeightProcessor() {
+        super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES);
+    }
+
+    @Override
+    protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) {
+
+        final CallContext context = generator.getCallContext();
+        final Map<String, String> metaData = bundle.getFacet().getMetaData();
+
+        final Artifact artifact = bundle.getArtifact();
+
+        final StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
+        series.putMetaData(metaData, artifact, context);
+
+        final String facetName = bundle.getFacetName();
+        final InfrastructureQueryCalculationResult data = (InfrastructureQueryCalculationResult) 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 double[][] points = data.getStationPoints(SInfoResultType.infrastructureHeight);
+
+        StyledSeriesBuilder.addPoints(series, points, true);
+        generator.addAxisSeries(series, getAxisName(), visible);
+
+        return metaData.get("Y");
+    }
+
+    public static Facet createFacet(final CallMeta callMeta, final String seriesName) {
+        return new InfrastructureFacet(FACET_INFRASTRUCTURE_HEIGHT,
+                Resources.getMsg(callMeta, I18N_SERIES_NAME_PATTERN, I18N_SERIES_NAME_PATTERN, seriesName), I18N_AXIS_LABEL);
+    }
+}
\ No newline at end of file
diff -r 31b3cae5de0d -r a165cd63099f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoI18NStrings.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoI18NStrings.java	Mon Jun 04 11:25:29 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoI18NStrings.java	Mon Jun 04 11:55:08 2018 +0200
@@ -10,7 +10,7 @@
 package org.dive4elements.river.artifacts.sinfo.common;
 
 /**
- * Some commonly used i10n-strings.
+ * Some commonly used i18n-strings.
  *
  * @author Gernot Belger
  */
@@ -77,4 +77,6 @@
 
     String PREFIX_TKH_KIND = "sinfo.export.tkh.soilkind.";
 
+    String CSV_INFRASTRUCTURE_HEIGHT_HEADER = "sinfo.export.csv.header.infrastructure.height";
+
 }
\ No newline at end of file
diff -r 31b3cae5de0d -r a165cd63099f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java	Mon Jun 04 11:25:29 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java	Mon Jun 04 11:55:08 2018 +0200
@@ -450,4 +450,19 @@
         }
     };
 
+    public static final SInfoResultType infrastructureHeight = new SInfoResultType(I18NStrings.UNIT_M, SInfoI18NStrings.CSV_INFRASTRUCTURE_HEIGHT_HEADER) {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public String exportValue(final CallContext context, final Object value) {
+            final double doubleValue = asDouble(value);
+            return exportDoubleValue(context, doubleValue);
+        }
+
+        @Override
+        protected NumberFormat createFormatter(final CallContext context) {
+            return Formatter.getInfrastructureHeight(context);
+        }
+    };
+
 }
\ No newline at end of file
diff -r 31b3cae5de0d -r a165cd63099f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/InfrastructureAccess.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/InfrastructureAccess.java	Mon Jun 04 11:55:08 2018 +0200
@@ -0,0 +1,52 @@
+/** 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.flood_duration;
+
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.RangeAccess;
+
+/**
+ * Access to the database loaded infrastructure artifact data
+ *
+ * @author Matthias Schäfer
+ */
+final class InfrastructureAccess extends RangeAccess {
+
+    /***** FIELDS *****/
+
+    private Integer id;
+
+    private String name;
+
+
+    /***** CONSTRUCTORS *****/
+
+    public InfrastructureAccess(final D4EArtifact artifact) {
+        super(artifact);
+    }
+
+
+    /***** METHODS *****/
+
+    public Integer getId() {
+        if (this.id == null) {
+            this.id = getInteger("infrastructure_id");
+        }
+        return this.id;
+    }
+
+    public String getName() {
+        if (this.name == null) {
+            this.name = getString("name");
+        }
+        return this.name;
+    }
+}
\ No newline at end of file
diff -r 31b3cae5de0d -r a165cd63099f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/InfrastructureArtifact.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/InfrastructureArtifact.java	Mon Jun 04 11:55:08 2018 +0200
@@ -0,0 +1,126 @@
+/** 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.flood_duration;
+
+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.InfrastructureHeightProcessor;
+import org.dive4elements.river.artifacts.states.StaticState;
+import org.w3c.dom.Document;
+
+/**
+ * Display of a infrastructure height data series loaded from database
+ *
+ * @author Matthias Schäfer
+ *
+ */
+public class InfrastructureArtifact extends AbstractStaticStateArtifact implements FacetTypes {
+
+    /** The log for this class. */
+    private static Logger log = Logger.getLogger(InfrastructureArtifact.class);
+
+    /** Artifact name. */
+    private static final String NAME = "infrastructure";
+
+    static {
+        // TODO: Move to configuration.
+        FacetActivity.Registry.getInstance().register(NAME, FacetActivity.INACTIVE);
+    }
+
+    public static final String STATIC_STATE_NAME = "state.infrastructure.static";
+
+    /**
+     * Trivial Constructor.
+     */
+    public InfrastructureArtifact() {
+        log.debug("new InfrastructureArtifact");
+    }
+
+    @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<Class> loadFacets) {
+
+        log.debug("InfrastructureArtifact.setup");
+
+        if (log.isDebugEnabled()) {
+            log.debug(XMLUtils.toString(data));
+        }
+
+        final String code = getDatacageIDValue(data);
+        final String seriesName = (code.split("-").length >= 3) ? code.split("-", 3)[2] : "name?";
+
+        createFacets(callMeta, code, seriesName);
+
+        super.setup(identifier, factory, context, callMeta, data, loadFacets);
+    }
+
+    private void createFacets(final CallMeta callMeta, final String code, final String seriesName) {
+        if (code == null)
+            return;
+        final String[] parts = code.split("-");
+        if (parts.length < 2) {
+            log.error("Invalid datacage ID '" + code + "'");
+            return;
+        }
+        addStringData("infrastructure_id", parts[1]);
+        final ArrayList<Facet> facets = new ArrayList<>(2);
+        facets.add(InfrastructureHeightProcessor.createFacet(callMeta, seriesName));
+        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<Facet> 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 31b3cae5de0d -r a165cd63099f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/InfrastructureFacet.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/InfrastructureFacet.java	Mon Jun 04 11:55:08 2018 +0200
@@ -0,0 +1,80 @@
+/** 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.flood_duration;
+
+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.FacetTypes;
+import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType;
+import org.dive4elements.river.model.sinfo.Infrastructure;
+import org.dive4elements.river.model.sinfo.InfrastructureValue;
+
+/**
+ * Facet for a infrastructure value series loaded from the database
+ *
+ * @author Matthias Schäfer
+ */
+public class InfrastructureFacet extends BlackboardDataFacet implements FacetTypes {
+
+    private static final long serialVersionUID = 1;
+
+    public InfrastructureFacet(final String name, final String description, final String yAxisLabel) {
+        super(0, name, description);
+
+        this.metaData.put("X", "chart.longitudinal.section.xaxis.label");
+        this.metaData.put("Y", yAxisLabel);
+    }
+
+    /**
+     * Returns the data this facet requires.
+     *
+     * @param artifact
+     *            the owner artifact.
+     * @param context
+     *            the CallContext (ignored).
+     *
+     * @return
+     *         the data as InfrastructureQueryCalculationResult
+     */
+    @Override
+    public Object getData(final Artifact artifact, final CallContext context) {
+
+        final InfrastructureAccess access = new InfrastructureAccess((D4EArtifact) artifact);
+        final Infrastructure series = Infrastructure.getSeries(access.getId());
+        final List<InfrastructureValue> values = InfrastructureValue.getValues(series, access.getFrom(true), access.getTo(true));
+        final Collection<ResultRow> rows = new ArrayList<>();
+        for (final InfrastructureValue value : values) {
+            rows.add(ResultRow.create().putValue(GeneralResultType.station, value.getStation()) //
+                    .putValue(SInfoResultType.infrastructureHeight, value.getHeight()));
+        }
+        return new InfrastructureQueryCalculationResult(series.getFilename(), rows);
+    }
+
+    /**
+     * Create a deep copy of this Facet.
+     *
+     * @return a deep copy.
+     */
+    @Override
+    public InfrastructureFacet deepCopy() {
+        final InfrastructureFacet copy = new InfrastructureFacet(this.name, this.description, this.metaData.get("Y"));
+        copy.set(this);
+        return copy;
+    }
+}
\ No newline at end of file
diff -r 31b3cae5de0d -r a165cd63099f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/InfrastructureQueryCalculationResult.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/InfrastructureQueryCalculationResult.java	Mon Jun 04 11:55:08 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.flood_duration;
+
+import java.util.Collection;
+
+import org.dive4elements.river.artifacts.common.ResultRow;
+import org.dive4elements.river.artifacts.sinfo.common.AbstractSInfoCalculationResult;
+
+/**
+ * Contains the results of a database query of a river channel width series
+ *
+ * @author Matthias Schäfer
+ */
+public final class InfrastructureQueryCalculationResult extends AbstractSInfoCalculationResult {
+
+    private static final long serialVersionUID = 1L;
+
+    public InfrastructureQueryCalculationResult(final String label, final Collection<ResultRow> rows) {
+        super(label, null, rows);
+    }
+}
\ No newline at end of file
diff -r 31b3cae5de0d -r a165cd63099f artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedchannel/PredefinedChannelFacet.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedchannel/PredefinedChannelFacet.java	Mon Jun 04 11:25:29 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedchannel/PredefinedChannelFacet.java	Mon Jun 04 11:55:08 2018 +0200
@@ -50,7 +50,7 @@
      *            the CallContext (ignored).
      *
      * @return
-     *         the data as PredefinedChannelWidthQueryCalculationResult
+     *         the data as PredefinedChannelQueryCalculationResult
      */
     @Override
     public Object getData(final Artifact artifact, final CallContext context) {
diff -r 31b3cae5de0d -r a165cd63099f artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java
--- a/artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java	Mon Jun 04 11:25:29 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java	Mon Jun 04 11:55:08 2018 +0200
@@ -410,4 +410,8 @@
     public static NumberFormat getUeberflutungsdauer(final CallContext context) {
         return Formatter.getFormatter(context, 0, 0);
     }
+
+    public static NumberFormat getInfrastructureHeight(final CallContext context) {
+        return getFormatter(context.getMeta(), 2, 2);
+    }
 }
\ No newline at end of file
diff -r 31b3cae5de0d -r a165cd63099f artifacts/src/main/resources/messages.properties
--- a/artifacts/src/main/resources/messages.properties	Mon Jun 04 11:25:29 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties	Mon Jun 04 11:55:08 2018 +0200
@@ -1086,6 +1086,9 @@
 sinfo.chart.channel_width.section.yaxis.label = Sollbreite Fahrrinne [m]
 sinfo.chart.channel_depth.section.yaxis.label = Solltiefe Fahrrinne [m]
 
+sinfo.export.csv.header.infrastructure.height = Infrastrukturh\u00f6he
+infrastructure.height.title = Geod. H\u00f6he 
+
 bundu_bezugswst = Bezugswasserst\u00e4nde
 bundu_analysis = Fixinganalysis
 bundu_vollmer = relocated Waterlevel Calculation 
diff -r 31b3cae5de0d -r a165cd63099f artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties	Mon Jun 04 11:25:29 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Mon Jun 04 11:55:08 2018 +0200
@@ -1086,6 +1086,9 @@
 predefinedchannel.width.title = Sollbreite Fahrrinne
 predefinedchannel.depth.title = Solltiefe Fahrrinne
 
+sinfo.export.csv.header.infrastructure.height = Infrastrukturh\u00f6he
+infrastructure.height.title = Geod. H\u00f6he 
+
 bundu_bezugswst = Bezugswasserst\u00e4nde
 bundu_analysis = Fixierungsanalyse
 bundu_vollmer = ausgelagerte Wasserspiegellage
diff -r 31b3cae5de0d -r a165cd63099f backend/src/main/java/org/dive4elements/river/model/sinfo/Infrastructure.java
--- a/backend/src/main/java/org/dive4elements/river/model/sinfo/Infrastructure.java	Mon Jun 04 11:25:29 2018 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/Infrastructure.java	Mon Jun 04 11:55:08 2018 +0200
@@ -25,8 +25,11 @@
 import javax.persistence.SequenceGenerator;
 import javax.persistence.Table;
 
+import org.dive4elements.river.backend.SessionHolder;
 import org.dive4elements.river.model.AnnotationType;
 import org.dive4elements.river.model.River;
+import org.hibernate.Query;
+import org.hibernate.Session;
 
 /**
  * Hibernate binding for the DB table infrastructure
@@ -84,6 +87,7 @@
         this.values = new ArrayList<>();
     }
 
+
     /***** METHODS *****/
 
     @Id
@@ -185,4 +189,14 @@
     public void addValue(final InfrastructureValue value) {
         this.values.add(value);
     }
+
+    /**
+     * Get data series by id
+     */
+    public static Infrastructure getSeries(final int id) {
+        final Session session = SessionHolder.HOLDER.get();
+        final Query query = session.createQuery("FROM Infrastructure WHERE (id=:id)");
+        query.setParameter("id", id);
+        return (Infrastructure) query.list().get(0);
+    }
 }
\ No newline at end of file
diff -r 31b3cae5de0d -r a165cd63099f backend/src/main/java/org/dive4elements/river/model/sinfo/InfrastructureValue.java
--- a/backend/src/main/java/org/dive4elements/river/model/sinfo/InfrastructureValue.java	Mon Jun 04 11:25:29 2018 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/InfrastructureValue.java	Mon Jun 04 11:55:08 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,7 +23,10 @@
 import javax.persistence.SequenceGenerator;
 import javax.persistence.Table;
 
+import org.dive4elements.river.backend.SessionHolder;
 import org.dive4elements.river.model.Attribute;
+import org.hibernate.Query;
+import org.hibernate.Session;
 
 
 /**
@@ -121,4 +125,17 @@
     public void setHeight(final Double height) {
         this.height = height;
     }
+
+    /**
+     * Selects the infrastructure values of a data series in a km range from the database
+     */
+    public static List<InfrastructureValue> getValues(final Infrastructure parent, final double kmLo, final double kmHi) {
+        final Session session = SessionHolder.HOLDER.get();
+        final Query query = session.createQuery("FROM InfrastructureValue WHERE (infrastructure=: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 31b3cae5de0d -r a165cd63099f 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	Mon Jun 04 11:25:29 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java	Mon Jun 04 11:55:08 2018 +0200
@@ -1501,6 +1501,8 @@
 
     String sinfo_predefined_flowdepth();
 
+    String sinfo_infrastructure();
+
     String uinfo();
 
     String uinfo_salix_line_export();
diff -r 31b3cae5de0d -r a165cd63099f 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	Mon Jun 04 11:25:29 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties	Mon Jun 04 11:55:08 2018 +0200
@@ -803,6 +803,8 @@
 sinfo_predefined_flowdepths = Modellierte Datens\u00e4tze
 sinfo_predefined_flowdepth = Flie\u00dftiefen
 
+sinfo_infrastructure = Infrastrukturen BWaStr
+
 uinfo = U-INFO
 uinfo_inundation_duration_export = \u00dcberflutungsdauern Export
 uinfo_salix_line_export = Salix-Linie Export
diff -r 31b3cae5de0d -r a165cd63099f 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	Mon Jun 04 11:25:29 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties	Mon Jun 04 11:55:08 2018 +0200
@@ -803,6 +803,8 @@
 sinfo_predefined_flowdepths = Modellierte Datens\u00e4tze
 sinfo_predefined_flowdepth = Flie\u00dftiefen
 
+sinfo_infrastructure = Infrastrukturen BWaStr
+
 uinfo = U-INFO
 uinfo_inundation_duration_export = \u00dcberflutungsdauern Export
 uinfo_salix_line_export = Salix-Linie Export


More information about the Dive4Elements-commits mailing list