Mercurial > dive4elements > river
changeset 9037:1574ce45c98d
Merge
author | gernotbelger |
---|---|
date | Mon, 30 Apr 2018 18:06:31 +0200 |
parents | c265c9fc915c (current diff) c16e90a0baf7 (diff) |
children | 4c5eeaff554c |
files | artifacts/doc/conf/backend-db.xml artifacts/doc/conf/seddb-db.xml gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties |
diffstat | 18 files changed, 505 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/doc/conf/backend-db.xml Mon Apr 30 18:03:02 2018 +0200 +++ b/artifacts/doc/conf/backend-db.xml Mon Apr 30 18:06:31 2018 +0200 @@ -5,7 +5,7 @@ <password>d4e</password> <dialect>org.hibernate.dialect.PostgreSQLDialect</dialect> <driver>org.postgresql.Driver</driver> - <url>jdbc:postgresql://localhost:5432/d4e</url> + <url>jdbc:postgresql://localhost:63333/d4e</url> <validation-query>select 1 from rivers</validation-query> <max-wait>30000</max-wait> </backend-database>
--- a/artifacts/doc/conf/conf.xml Mon Apr 30 18:03:02 2018 +0200 +++ b/artifacts/doc/conf/conf.xml Mon Apr 30 18:06:31 2018 +0200 @@ -181,21 +181,19 @@ ttl="3600000" artifact="org.dive4elements.river.artifacts.uinfo.UINFOArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory</artifact-factory> - - - - - <artifact-factory name="uinfo" description="Factory to create an artifact to be used in module uinfo." + <artifact-factory name="uinfo" description="Factory to create an artifact to be used in module uinfo." ttl="3600000" artifact="org.dive4elements.river.artifacts.uinfo.UINFOArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory</artifact-factory> - <artifact-factory name="tkhxf" description="Factory to create an artifact used in sinfo datacage." ttl="3600000" artifact="org.dive4elements.river.artifacts.sinfo.predefinedtkh.PredefinedTkhArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory</artifact-factory> <artifact-factory name="depthevolxf" description="Factory to create an artifact used in sinfo datacage." ttl="3600000" artifact="org.dive4elements.river.artifacts.sinfo.predefineddepthevol.PredefinedDepthEvolArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory</artifact-factory> + <artifact-factory name="flowdepthxf" description="Factory to create an artifact used in sinfo datacage." + ttl="3600000" + artifact="org.dive4elements.river.artifacts.sinfo.predefinedflowdepth.PredefinedFlowDepthArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory</artifact-factory> </artifact-factories>
--- a/artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml Mon Apr 30 18:03:02 2018 +0200 +++ b/artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml Mon Apr 30 18:06:31 2018 +0200 @@ -59,6 +59,7 @@ <processor class="org.dive4elements.river.artifacts.sinfo.common.PredefinedTkhProcessor" axis="tkhAxis"/> <processor class="org.dive4elements.river.artifacts.sinfo.common.PredefinedDepthEvolProcessor" axis="flowdepthDevelopmentAxis"/> <processor class="org.dive4elements.river.artifacts.sinfo.common.PredefinedDepthEvolPerYearProcessor" axis="flowdepthDevelopmentPerYearAxis"/> + <processor class="org.dive4elements.river.artifacts.sinfo.common.PredefinedFlowDepthProcessor" axis="flowdepthAxis"/> <chartextender class="org.dive4elements.river.artifacts.sinfo.flowdepth.FlowDepthChartExtender" /> </longitudinal-defaults> \ No newline at end of file
--- a/artifacts/doc/conf/meta-data.xml Mon Apr 30 18:03:02 2018 +0200 +++ b/artifacts/doc/conf/meta-data.xml Mon Apr 30 18:06:31 2018 +0200 @@ -1636,6 +1636,10 @@ <dc:call-macro name="sinfo_predefined_depthevol-aktuell"/> <dc:call-macro name="sinfo_predefined_depthevol-etappe"/> </sinfo_predefined_depthevol> + + <sinfo_predefined_flowdepth> + <dc:call-macro name="sinfo_predefined_flowdepth-m"/> + </sinfo_predefined_flowdepth> </sinfo> </dc:macro> @@ -3488,21 +3492,24 @@ <dc:macro name="sinfo_predefined_tkh"> <dc:context> <dc:statement> - 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}) - AND (lower(t.groupname)=${tkh_groupname}) - GROUP BY tc.tkh_id, tc.id - ORDER BY tc.id + SELECT sc.tkh_id AS tkh_id, sc.id AS tkh_col_id, sc.name AS tkh_col_name, + MIN(s.filename) AS tkh_name, MIN(v.station) AS km_min, MAX(v.station) AS km_max, + MIN(s.filename) || '<br />' + || '[km ' || MIN(v.station) || ' - ' || MAX(v.station) || ']<br />' + || MIN(s.sounding_info) || '<br />' + || MIN(s.evaluation_by) AS info + FROM tkh_column sc INNER JOIN tkh s ON sc.tkh_id=s.id + INNER JOIN tkh_values v ON sc.id=v.tkh_column_id + WHERE (s.river_id=${river_id}) + AND (lower(s.groupname)=${tkh_groupname}) + GROUP BY sc.tkh_id, sc.id + ORDER BY sc.id </dc:statement> <dc:if test="dc:has-result()"> <dc:group expr="$tkh_name"> <tkhx name="{dc:group-key()}"> <dc:for-each> - <tkhcolumn name="{$tkh_col_name}" ids="tkhx-{$tkh_col_id}-{$tkh_id}" factory="tkhxf" target_out="{$out}" info="{$tkh_name}<br />[km {$km_min} - {$km_max}]"/> + <tkhcolumn name="{$tkh_col_name}" ids="tkhx-{$tkh_col_id}-{$tkh_id}" factory="tkhxf" target_out="{$out}" info="{$info}"/> </dc:for-each> </tkhx> </dc:group> @@ -3530,9 +3537,10 @@ <dc:statement> SELECT s.id AS depthevol_id, s.filename AS depthevol_name, MIN(v.station) AS km_min, MAX(v.station) AS km_max, s.filename || '<br />' + || '[km ' || MIN(v.station) || ' - ' || MAX(v.station) || ']<br />' || MIN(s.start_year) || ' - ' || MIN(s.reference_year) || '<br />' || MIN(s.old_sounding) || ' - ' || MIN(s.curr_sounding) || '<br />' - || MIN(s.old_glw) || ' - ' || MIN(s.curr_glw) AS info + || MIN(s.old_glw) || ' - ' || MIN(s.curr_glw) AS info FROM depth_evolution s INNER JOIN depth_evolution_values v ON s.id=v.depth_evolution_id WHERE (s.river_id=${river_id}) AND (lower(s.groupname)=${depthevol_groupname}) @@ -3540,10 +3548,42 @@ ORDER BY s.id </dc:statement> <dc:for-each> - <depth_evol name="{$depthevol_name}" ids="depthevolx-{$depthevol_id}-{$depthevol_name}" factory="depthevolxf" target_out="{$out}" info="{$depthevol_name}<br />[km {$km_min} - {$km_max}]"/> + <depth_evol name="{$depthevol_name}" ids="depthevolx-{$depthevol_id}-{$depthevol_name}" factory="depthevolxf" target_out="{$out}" info="{$info}"/> </dc:for-each> </dc:context> </dc:macro> + <!-- flow depth imported from CSV-files for S-INFO --> + <dc:macro name="sinfo_predefined_flowdepth-m"> + <dc:call-macro name="sinfo_predefined_flowdepth-m1"/> + </dc:macro> + + <dc:macro name="sinfo_predefined_flowdepth-m1"> + <dc:context> + <dc:statement> + SELECT sc.flow_depth_id AS flowdepth_id, sc.id AS flowdepth_col_id, sc.name AS flowdepth_col_name, + MIN(s.filename) AS flowdepth_name, MIN(v.station) AS km_min, MAX(v.station) AS km_max, + MIN(s.filename) || '<br />' + || '[km ' || MIN(v.station) || ' - ' || MAX(v.station) || ']<br />' + || MIN(s.sounding_info) || '<br />' + || MIN(s.evaluation_by) AS info + FROM flow_depth_column sc INNER JOIN flow_depth s ON sc.flow_depth_id=s.id + INNER JOIN flow_depth_values v ON sc.id=v.flow_depth_column_id + WHERE (s.river_id=${river_id}) + GROUP BY sc.flow_depth_id, sc.id + ORDER BY sc.id + </dc:statement> + <dc:if test="dc:has-result()"> + <dc:group expr="$flowdepth_name"> + <flowdepthx name="{dc:group-key()}"> + <dc:for-each> + <flowdepthcolumn name="{$flowdepth_col_name}" ids="flowdepthx-{$flowdepth_col_id}-{$flowdepth_id}" factory="flowdepthxf" target_out="{$out}" info="{$info}"/> + </dc:for-each> + </flowdepthx> + </dc:group> + </dc:if> + </dc:context> + </dc:macro> + </datacage> </dc:template> \ No newline at end of file
--- a/artifacts/doc/conf/seddb-db.xml Mon Apr 30 18:03:02 2018 +0200 +++ b/artifacts/doc/conf/seddb-db.xml Mon Apr 30 18:06:31 2018 +0200 @@ -5,7 +5,7 @@ <password>seddb</password> <dialect>org.hibernate.dialect.PostgreSQLDialect</dialect> <driver>org.postgresql.Driver</driver> - <url>jdbc:postgresql://localhost:5432/seddb</url> + <url>jdbc:postgresql://localhost:63333/seddb</url> <validation-query>select 1 from gewaesser</validation-query> <max-wait>30000</max-wait> <!--
--- a/artifacts/doc/conf/themes.xml Mon Apr 30 18:03:02 2018 +0200 +++ b/artifacts/doc/conf/themes.xml Mon Apr 30 18:06:31 2018 +0200 @@ -444,5 +444,6 @@ <mapping from="sinfo_facet_predefined_tkh" to="SInfoPredefinedTkh" /> <mapping from="sinfo_facet_predefined_depthevol" to="SInfoPredefinedDepthEvol" /> <mapping from="sinfo_facet_predefined_depthevol_per_year" to="SInfoPredefinedDepthEvolPerYear" /> + <mapping from="sinfo_facet_predefined_flowdepth" to="SInfoPredefinedFlowDepth" /> </mappings> </themes> \ No newline at end of file
--- a/artifacts/doc/conf/themes/default.xml Mon Apr 30 18:03:02 2018 +0200 +++ b/artifacts/doc/conf/themes/default.xml Mon Apr 30 18:06:31 2018 +0200 @@ -3020,4 +3020,12 @@ <field name="linecolor" type="Color" display="Linienfarbe" default="0, 128, 128" /> </fields> </theme> + <theme name="SInfoPredefinedFlowDepth"> + <inherits> + <inherit from="LongitudinalSectionW" /> + </inherits> + <fields> + <field name="linecolor" type="Color" display="Linienfarbe" default="96, 128, 192" /> + </fields> + </theme> </themegroup> \ No newline at end of file
--- a/artifacts/doc/conf/themes/second.xml Mon Apr 30 18:03:02 2018 +0200 +++ b/artifacts/doc/conf/themes/second.xml Mon Apr 30 18:06:31 2018 +0200 @@ -3008,4 +3008,12 @@ <field name="linecolor" type="Color" display="Linienfarbe" default="0, 128, 128" /> </fields> </theme> + <theme name="SInfoPredefinedFlowDepth"> + <inherits> + <inherit from="LongitudinalSectionW" /> + </inherits> + <fields> + <field name="linecolor" type="Color" display="Linienfarbe" default="96, 128, 192" /> + </fields> + </theme> </themegroup> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/PredefinedFlowDepthProcessor.java Mon Apr 30 18:06:31 2018 +0200 @@ -0,0 +1,77 @@ +/** 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.Artifact; +import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.artifacts.sinfo.predefinedflowdepth.PredefinedFlowDepthQueryCalculationResult; +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 flow depth data loaded from the database + * + * @author Matthias Schäfer + * + */ +public class PredefinedFlowDepthProcessor extends AbstractSInfoProcessor { + + private final static Logger log = Logger.getLogger(PredefinedFlowDepthProcessor.class); + + public static final String FACET_PREDEFINED_FLOW_DEPTH = "sinfo_facet_predefined_flowdepth"; + + private static final String I18N_AXIS_LABEL = "sinfo.chart.flow_depth.section.yaxis.label"; + + private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); + + static { + HANDLED_FACET_TYPES.add(FACET_PREDEFINED_FLOW_DEPTH); + } + + public PredefinedFlowDepthProcessor() { + 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 PredefinedFlowDepthQueryCalculationResult data = (PredefinedFlowDepthQueryCalculationResult) 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.flowdepth); + + StyledSeriesBuilder.addPoints(series, points, true); + generator.addAxisSeries(series, getAxisName(), visible); + + return null; + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedflowdepth/PredefinedFlowDepthArtifact.java Mon Apr 30 18:06:31 2018 +0200 @@ -0,0 +1,130 @@ +/** 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.predefinedflowdepth; + +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.PredefinedFlowDepthProcessor; +import org.dive4elements.river.artifacts.states.StaticState; +import org.dive4elements.river.model.sinfo.FlowDepthColumn; +import org.w3c.dom.Document; + +/** + * Display of a flow depth data series loaded from database + * + * @author Matthias Schäfer + * + */ +public class PredefinedFlowDepthArtifact extends AbstractStaticStateArtifact implements FacetTypes { + + /** The log for this class. */ + private static Logger log = Logger.getLogger(PredefinedFlowDepthArtifact.class); + + /** Artifact name. */ + private static final String NAME = "flowdepthx"; + + static { + // TODO: Move to configuration. + FacetActivity.Registry.getInstance().register(NAME, FacetActivity.INACTIVE); + } + + public static final String STATIC_STATE_NAME = "state.predefined_flowdepth.static"; + + /** + * Trivial Constructor. + */ + public PredefinedFlowDepthArtifact() { + log.debug("new PredefinedFLowDepthArtifact"); + } + + @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("PredefinedFlowDepthArtifact.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("flowdepth_col_id", parts[1]); + addStringData("flowdepth_id", parts[2]); + final FlowDepthColumn col = FlowDepthColumn.getColumnById(Integer.parseInt(parts[1])); + + final ArrayList<Facet> facets = new ArrayList<>(1); + facets.add(new PredefinedFlowDepthFacet(PredefinedFlowDepthProcessor.FACET_PREDEFINED_FLOW_DEPTH, + col.getName() + " (" + col.getSeries().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<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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedflowdepth/PredefinedFlowDepthColumnAccess.java Mon Apr 30 18:06:31 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.predefinedflowdepth; + +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 flow depth column artifact data + * + * @author Matthias Schäfer + */ +final class PredefinedFlowDepthColumnAccess extends RangeAccess { + + /***** FIELDS *****/ + + private Integer columnId; + + private Integer seriesId; + + private String name; + + + /***** CONSTRUCTORS *****/ + + public PredefinedFlowDepthColumnAccess(final D4EArtifact artifact) { + super(artifact); + } + + + /***** METHDOS *****/ + + public DoubleRange getRange() { + final double from = getFrom(); + final double to = getTo(); + return new DoubleRange(from, to); + } + + public Integer getSeriesId() { + if (this.seriesId == null) { + this.seriesId = getInteger("flowdepth_id"); + } + return this.columnId; + } + + public Integer getColumnId() { + if (this.columnId == null) { + this.columnId = getInteger("flowdepth_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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedflowdepth/PredefinedFlowDepthFacet.java Mon Apr 30 18:06:31 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.predefinedflowdepth; + +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.FlowDepthColumn; +import org.dive4elements.river.model.sinfo.FlowDepthValue; + +/** + * Facet for a flow depth value series loaded from the database + * + * @author Matthias Schäfer + */ +public class PredefinedFlowDepthFacet extends BlackboardDataFacet implements FacetTypes { + + private static final long serialVersionUID = -5314814229001970855L; + + public PredefinedFlowDepthFacet(final String name, final String description) { + super(0, name, description); + + this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); + this.metaData.put("Y", "chart.flow_depth.section.yaxis.label"); + } + + /** + * Returns the data this facet requires. + * + * @param artifact + * the owner artifact. + * @param context + * the CallContext (ignored). + * + * @return + * the data as PredefinedFlowDepthQueryCalculationResult + */ + @Override + public Object getData(final Artifact artifact, final CallContext context) { + + final PredefinedFlowDepthColumnAccess access = new PredefinedFlowDepthColumnAccess((D4EArtifact) artifact); + final FlowDepthColumn series = FlowDepthColumn.getColumnById(access.getColumnId()); + final List<FlowDepthValue> values = FlowDepthValue.getValues(series, access.getFrom(true), access.getTo(true)); + final Collection<ResultRow> rows = new ArrayList<>(); + for (final FlowDepthValue value : values) { + rows.add(ResultRow.create().putValue(GeneralResultType.station, value.getStation()) // + .putValue(SInfoResultType.flowdepth, value.getDepth())); + } + return new PredefinedFlowDepthQueryCalculationResult(series.getName(), rows); + } + + /** + * Create a deep copy of this Facet. + * + * @return a deep copy. + */ + @Override + public PredefinedFlowDepthFacet deepCopy() { + final PredefinedFlowDepthFacet copy = new PredefinedFlowDepthFacet(this.name, this.description); + copy.set(this); + return copy; + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedflowdepth/PredefinedFlowDepthQueryCalculationResult.java Mon Apr 30 18:06:31 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.predefinedflowdepth; + +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 tkh series + * + * @author Matthias Schäfer + */ +public final class PredefinedFlowDepthQueryCalculationResult extends AbstractSInfoCalculationResult { + + private static final long serialVersionUID = 1L; + + public PredefinedFlowDepthQueryCalculationResult(final String label, final Collection<ResultRow> rows) { + super(label, null, rows); + } +} \ No newline at end of file
--- a/backend/src/main/java/org/dive4elements/river/model/sinfo/FlowDepthColumn.java Mon Apr 30 18:03:02 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/FlowDepthColumn.java Mon Apr 30 18:06:31 2018 +0200 @@ -23,6 +23,11 @@ import javax.persistence.OneToOne; import javax.persistence.SequenceGenerator; import javax.persistence.Table; +import javax.persistence.Transient; + +import org.dive4elements.river.backend.SessionHolder; +import org.hibernate.Query; +import org.hibernate.Session; /** * Hibernate binding for the DB table flow_depth_column @@ -77,6 +82,11 @@ return this.parent; } + @Transient + public FlowDepth getSeries() { + return getFlowDepth(); + } + public void setFlowDepth(final FlowDepth flow_depth) { this.parent = flow_depth; } @@ -103,4 +113,15 @@ public void addValue(final FlowDepthValue value) { this.values.add(value); } + + /** + * Selects a flow depth series column by id from the database + */ + public static FlowDepthColumn getColumnById(final int id) { + final Session session = SessionHolder.HOLDER.get(); + final Query query = session.createQuery("FROM FlowDepthColumn WHERE id=:id"); + query.setParameter("id", id); + final List<FlowDepthColumn> rows = query.list(); + return (rows != null) ? rows.get(0) : null; + } }
--- a/backend/src/main/java/org/dive4elements/river/model/sinfo/FlowDepthValue.java Mon Apr 30 18:03:02 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/FlowDepthValue.java Mon Apr 30 18:06:31 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 flow_depth_values @@ -109,4 +114,17 @@ public void setDepth(final Double depth) { this.depth = depth; } + + /** + * Selects the flow depth values of a flow depth series column in a km range from the database + */ + public static List<FlowDepthValue> getValues(final FlowDepthColumn parent, final double kmLo, final double kmHi) { + final Session session = SessionHolder.HOLDER.get(); + final Query query = session.createQuery("FROM FlowDepthValue WHERE (flowDepthColumn=: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(); + } }
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Mon Apr 30 18:03:02 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Mon Apr 30 18:06:31 2018 +0200 @@ -1498,6 +1498,8 @@ String predefined_depthevol_etappe(); + String sinfo_predefined_flowdepth(); + String uinfo(); String uinfo_salix_line_export();
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Mon Apr 30 18:03:02 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Mon Apr 30 18:06:31 2018 +0200 @@ -800,6 +800,8 @@ predefined_depthevol_aktuell = Bezug aktueller GlW predefined_depthevol_etappe = GlW-Etappen +sinfo_predefined_flowdepth = Modellierte Flie\u00dftiefen + uinfo = U-INFO uinfo_inundation_duration_export = \u00dcberflutungsdauern Export uinfo_salix_line_export = Salix-Linie Export
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Mon Apr 30 18:03:02 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Mon Apr 30 18:06:31 2018 +0200 @@ -800,6 +800,8 @@ predefined_depthevol_aktuell = Bezug aktueller GlW predefined_depthevol_etappe = GlW-Etappen +sinfo_predefined_flowdepth = Modellierte Flie\u00dftiefen + uinfo = U-INFO uinfo_inundation_duration_export = \u00dcberflutungsdauern Export uinfo_salix_line_export = Salix-Linie Export