Mercurial > dive4elements > river
changeset 9033:384eee4b4135
Added datacage select and chart display for flow depth evolution series loaded from database, and a correction for the tkh data
line wrap: on
line diff
--- a/artifacts/doc/conf/conf.xml Fri Apr 27 17:35:12 2018 +0200 +++ b/artifacts/doc/conf/conf.xml Fri Apr 27 17:41:59 2018 +0200 @@ -193,6 +193,9 @@ <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-factories>
--- a/artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml Fri Apr 27 17:35:12 2018 +0200 +++ b/artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml Fri Apr 27 17:41:59 2018 +0200 @@ -57,6 +57,8 @@ <processor class="org.dive4elements.river.artifacts.sinfo.common.FlowDepthDevelopmentPerYearProcessor" axis="flowdepthDevelopmentPerYearAxis"/> <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"/> <chartextender class="org.dive4elements.river.artifacts.sinfo.flowdepth.FlowDepthChartExtender" /> </longitudinal-defaults> \ No newline at end of file
--- a/artifacts/doc/conf/meta-data.xml Fri Apr 27 17:35:12 2018 +0200 +++ b/artifacts/doc/conf/meta-data.xml Fri Apr 27 17:41:59 2018 +0200 @@ -1628,8 +1628,14 @@ </bed_heights_minmax> <sinfo_predefined_tkh> - <dc:call-macro name="sinfo_predefined_tkh"/> + <dc:call-macro name="sinfo_predefined_tkh-berechnung"/> + <dc:call-macro name="sinfo_predefined_tkh-messung"/> </sinfo_predefined_tkh> + + <sinfo_predefined_depthevol> + <dc:call-macro name="sinfo_predefined_depthevol-aktuell"/> + <dc:call-macro name="sinfo_predefined_depthevol-etappe"/> + </sinfo_predefined_depthevol> </sinfo> </dc:macro> @@ -3464,7 +3470,21 @@ </dc:filter> </dc:macro> - <!-- tkh imported from CSV-files for S-INFO --> + <!-- tkh imported from CSV-files for S-INFO --> + <dc:macro name="sinfo_predefined_tkh-berechnung"> + <predefined_tkh_berechnung> + <dc:variable name="tkh_groupname" expr="'berechnung'"/> + <dc:call-macro name="sinfo_predefined_tkh"/> + </predefined_tkh_berechnung> + </dc:macro> + + <dc:macro name="sinfo_predefined_tkh-messung"> + <predefined_tkh_messung> + <dc:variable name="tkh_groupname" expr="'messung'"/> + <dc:call-macro name="sinfo_predefined_tkh"/> + </predefined_tkh_messung> + </dc:macro> + <dc:macro name="sinfo_predefined_tkh"> <dc:context> <dc:statement> @@ -3473,7 +3493,8 @@ 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} + WHERE (t.river_id=${river_id}) + AND (lower(t.groupname)=${tkh_groupname}) GROUP BY tc.tkh_id, tc.id ORDER BY tc.id </dc:statement> @@ -3489,5 +3510,40 @@ </dc:context> </dc:macro> + <!-- depth_evolution imported from CSV-files for S-INFO --> + <dc:macro name="sinfo_predefined_depthevol-aktuell"> + <predefined_depthevol_aktuell> + <dc:variable name="depthevol_groupname" expr="'aktuell'"/> + <dc:call-macro name="sinfo_predefined_depthevol"/> + </predefined_depthevol_aktuell> + </dc:macro> + + <dc:macro name="sinfo_predefined_depthevol-etappe"> + <predefined_depthevol_etappe> + <dc:variable name="depthevol_groupname" expr="'etappe'"/> + <dc:call-macro name="sinfo_predefined_depthevol"/> + </predefined_depthevol_etappe> + </dc:macro> + + <dc:macro name="sinfo_predefined_depthevol"> + <dc:context> + <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 />' + || 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 + 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}) + GROUP BY s.id + 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}]"/> + </dc:for-each> + </dc:context> + </dc:macro> + </datacage> </dc:template> \ No newline at end of file
--- a/artifacts/doc/conf/themes.xml Fri Apr 27 17:35:12 2018 +0200 +++ b/artifacts/doc/conf/themes.xml Fri Apr 27 17:41:59 2018 +0200 @@ -442,5 +442,7 @@ <mapping from="sinfo_facet_bedheight_difference.filtered" to="SInfoBedHeightDifference" /> <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" /> </mappings> </themes> \ No newline at end of file
--- a/artifacts/doc/conf/themes/default.xml Fri Apr 27 17:35:12 2018 +0200 +++ b/artifacts/doc/conf/themes/default.xml Fri Apr 27 17:41:59 2018 +0200 @@ -3004,4 +3004,20 @@ <field name="areatransparency" type="int" default="20" /> </fields> </theme> + <theme name="SInfoPredefinedDepthEvol"> + <inherits> + <inherit from="LongitudinalSectionW" /> + </inherits> + <fields> + <field name="linecolor" type="Color" display="Linienfarbe" default="0, 128, 192" /> + </fields> + </theme> + <theme name="SInfoPredefinedDepthEvolPerYear"> + <inherits> + <inherit from="LongitudinalSectionW" /> + </inherits> + <fields> + <field name="linecolor" type="Color" display="Linienfarbe" default="0, 128, 128" /> + </fields> + </theme> </themegroup> \ No newline at end of file
--- a/artifacts/doc/conf/themes/second.xml Fri Apr 27 17:35:12 2018 +0200 +++ b/artifacts/doc/conf/themes/second.xml Fri Apr 27 17:41:59 2018 +0200 @@ -2992,4 +2992,20 @@ <field name="areatransparency" type="int" default="20" /> </fields> </theme> + <theme name="SInfoPredefinedDepthEvol"> + <inherits> + <inherit from="LongitudinalSectionW" /> + </inherits> + <fields> + <field name="linecolor" type="Color" display="Linienfarbe" default="0, 128, 192" /> + </fields> + </theme> + <theme name="SInfoPredefinedDepthEvolPerYear"> + <inherits> + <inherit from="LongitudinalSectionW" /> + </inherits> + <fields> + <field name="linecolor" type="Color" display="Linienfarbe" default="0, 128, 128" /> + </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/PredefinedDepthEvolPerYearProcessor.java Fri Apr 27 17:41:59 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.predefineddepthevol.PredefinedDepthEvolFacet; +import org.dive4elements.river.artifacts.sinfo.predefineddepthevol.PredefinedDepthEvolQueryCalculationResult; +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 depth evolution per year data loaded from the database + * + * @author Matthias Schäfer + * + */ +public class PredefinedDepthEvolPerYearProcessor extends AbstractSInfoProcessor { + + // private final static Logger log = Logger.getLogger(PredefinedDepthEvolPerYearProcessor.class); + + public static final String FACET_PREDEFINED_DEPTHEVOL_PER_YEAR = "sinfo_facet_predefined_depthevol_per_year"; + + private static final String I18N_AXIS_LABEL = "sinfo.chart.flow_depth_development_per_year.section.yaxis.label"; + + private static final String I18N_SERIES_NAME_PATTERN = "predefineddepthevol.peryear.title"; + + private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); + + static { + HANDLED_FACET_TYPES.add(FACET_PREDEFINED_DEPTHEVOL_PER_YEAR); + } + + public PredefinedDepthEvolPerYearProcessor() { + 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 PredefinedDepthEvolQueryCalculationResult data = (PredefinedDepthEvolQueryCalculationResult) 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.flowdepthDevelopmentPerYear); + + 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 PredefinedDepthEvolFacet(FACET_PREDEFINED_DEPTHEVOL_PER_YEAR, + Resources.getMsg(callMeta, I18N_SERIES_NAME_PATTERN, I18N_SERIES_NAME_PATTERN, seriesName), I18N_AXIS_LABEL); + } +} \ 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/PredefinedDepthEvolProcessor.java Fri Apr 27 17:41:59 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.predefineddepthevol.PredefinedDepthEvolFacet; +import org.dive4elements.river.artifacts.sinfo.predefineddepthevol.PredefinedDepthEvolQueryCalculationResult; +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 depth evolution data loaded from the database + * + * @author Matthias Schäfer + * + */ +public class PredefinedDepthEvolProcessor extends AbstractSInfoProcessor { + + // private final static Logger log = Logger.getLogger(PredefinedDepthEvolProcessor.class); + + public static final String FACET_PREDEFINED_DEPTHEVOL = "sinfo_facet_predefined_depthevol"; + + private static final String I18N_AXIS_LABEL = "sinfo.chart.flow_depth_development.section.yaxis.label"; + + private static final String I18N_SERIES_NAME_PATTERN = "predefineddepthevol.total.title"; + + private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); + + static { + HANDLED_FACET_TYPES.add(FACET_PREDEFINED_DEPTHEVOL); + } + + public PredefinedDepthEvolProcessor() { + 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 PredefinedDepthEvolQueryCalculationResult data = (PredefinedDepthEvolQueryCalculationResult) 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.flowdepthDevelopment); + + 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 PredefinedDepthEvolFacet(FACET_PREDEFINED_DEPTHEVOL, + Resources.getMsg(callMeta, I18N_SERIES_NAME_PATTERN, I18N_SERIES_NAME_PATTERN, seriesName), I18N_AXIS_LABEL); + } +} \ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/PredefinedTkhProcessor.java Fri Apr 27 17:35:12 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/PredefinedTkhProcessor.java Fri Apr 27 17:41:59 2018 +0200 @@ -11,7 +11,6 @@ package org.dive4elements.river.artifacts.sinfo.common; import java.util.HashSet; -import java.util.Map; import java.util.Set; import org.apache.log4j.Logger; @@ -37,10 +36,6 @@ 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<String> HANDLED_FACET_TYPES = new HashSet<>(); static { @@ -51,40 +46,6 @@ 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<String, String> 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();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefineddepthevol/PredefinedDepthEvolAccess.java Fri Apr 27 17:41:59 2018 +0200 @@ -0,0 +1,59 @@ +/** 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.predefineddepthevol; + +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 depth evolution artifact data + * + * @author Matthias Schäfer + */ +final class PredefinedDepthEvolAccess extends RangeAccess { + + /***** FIELDS *****/ + + private Integer id; + + private String name; + + + /***** CONSTRUCTORS *****/ + + public PredefinedDepthEvolAccess(final D4EArtifact artifact) { + super(artifact); + } + + + /***** METHDOS *****/ + + public DoubleRange getRange() { + final double from = getFrom(); + final double to = getTo(); + return new DoubleRange(from, to); + } + + public Integer getId() { + if (this.id == null) { + this.id = getInteger("depthevol_id"); + } + return this.id; + } + + 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/predefineddepthevol/PredefinedDepthEvolArtifact.java Fri Apr 27 17:41:59 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.predefineddepthevol; + +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.PredefinedDepthEvolPerYearProcessor; +import org.dive4elements.river.artifacts.sinfo.common.PredefinedDepthEvolProcessor; +import org.dive4elements.river.artifacts.states.StaticState; +import org.w3c.dom.Document; + +/** + * Display of a depth evolution data series loaded from database + * + * @author Matthias Schäfer + * + */ +public class PredefinedDepthEvolArtifact extends AbstractStaticStateArtifact implements FacetTypes { + + /** The log for this class. */ + private static Logger log = Logger.getLogger(PredefinedDepthEvolArtifact.class); + + /** Artifact name. */ + private static final String NAME = "depth_evol"; + + static { + // TODO: Move to configuration. + FacetActivity.Registry.getInstance().register(NAME, FacetActivity.INACTIVE); + } + + public static final String STATIC_STATE_NAME = "state.predefined_depthevol.static"; + + /** + * Trivial Constructor. + */ + public PredefinedDepthEvolArtifact() { + log.debug("new PredefinedDepthEvolArtifact"); + } + + @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("PredefinedDepthEvolArtifact.setup"); + + if (log.isDebugEnabled()) { + log.debug(XMLUtils.toString(data)); + } + + // FIXME Irgendwie muss es doch möglich sein, an das name-Attribut aus meta-data.xml ranzukommen (jetzt provisorisch in + // ids untergebracht) + // final String seriesName = getDataAsString(NAME); - so geht's nicht + final String code = getDatacageIDValue(data); + + createFacets(callMeta, code, (code.split("-").length >= 3) ? code.split("-", 3)[2] : "name?"); + + 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("depthevol_id", parts[1]); + final ArrayList<Facet> facets = new ArrayList<>(2); + facets.add(PredefinedDepthEvolProcessor.createFacet(callMeta, seriesName)); + facets.add(PredefinedDepthEvolPerYearProcessor.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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefineddepthevol/PredefinedDepthEvolFacet.java Fri Apr 27 17:41:59 2018 +0200 @@ -0,0 +1,81 @@ +/** 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.predefineddepthevol; + +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.DepthEvolution; +import org.dive4elements.river.model.sinfo.DepthEvolutionValue; + +/** + * Facet for a depth evolution value series loaded from the database + * + * @author Matthias Schäfer + */ +public class PredefinedDepthEvolFacet extends BlackboardDataFacet implements FacetTypes { + + private static final long serialVersionUID = -4298111901634067027L; + + public PredefinedDepthEvolFacet(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 PredefinedDepthEvolQueryCalculationResult + */ + @Override + public Object getData(final Artifact artifact, final CallContext context) { + + final PredefinedDepthEvolAccess access = new PredefinedDepthEvolAccess((D4EArtifact) artifact); + final DepthEvolution series = DepthEvolution.getSeries(access.getId()); + final List<DepthEvolutionValue> values = DepthEvolutionValue.getValues(series, access.getFrom(true), access.getTo(true)); + final Collection<ResultRow> rows = new ArrayList<>(); + for (final DepthEvolutionValue value : values) { + rows.add(ResultRow.create().putValue(GeneralResultType.station, value.getStation()) // + .putValue(SInfoResultType.flowdepthDevelopment, value.getTotalChangeCm()) // + .putValue(SInfoResultType.flowdepthDevelopmentPerYear, value.getPerYearChangeCm())); + } + return new PredefinedDepthEvolQueryCalculationResult(series.getFilename(), rows); + } + + /** + * Create a deep copy of this Facet. + * + * @return a deep copy. + */ + @Override + public PredefinedDepthEvolFacet deepCopy() { + final PredefinedDepthEvolFacet copy = new PredefinedDepthEvolFacet(this.name, this.description, this.metaData.get("Y")); + 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/predefineddepthevol/PredefinedDepthEvolQueryCalculationResult.java Fri Apr 27 17:41:59 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.predefineddepthevol; + +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 depth evolution series + * + * @author Matthias Schäfer + */ +public final class PredefinedDepthEvolQueryCalculationResult extends AbstractSInfoCalculationResult { + + private static final long serialVersionUID = 1L; + + public PredefinedDepthEvolQueryCalculationResult(final String label, final Collection<ResultRow> rows) { + super(label, null, rows); + } +} \ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedtkh/PredefinedTkhFacet.java Fri Apr 27 17:35:12 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedtkh/PredefinedTkhFacet.java Fri Apr 27 17:41:59 2018 +0200 @@ -68,35 +68,21 @@ SoilKind bedMobility = SoilKind.mobil; for (final TkhValue tkhValue : tkhValues) { final ResultRow row = ResultRow.create(); - row.putValue(GeneralResultType.station, tkhValue.getStation().doubleValue()); - if (soilKindFinder != null) + row.putValue(GeneralResultType.station, tkhValue.getStation()); + 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; + row.putValue(SInfoResultType.soilkind, bedMobility); } + else + row.putValue(SInfoResultType.soilkind, null); + row.putValue(SInfoResultType.tkh, tkhValue.getTkhCm()); + row.putValue(SInfoResultType.tkhup, tkhValue.getTkhUpCm(bedMobility == SoilKind.mobil)); + row.putValue(SInfoResultType.tkhdown, tkhValue.getTkhDownCm(bedMobility == SoilKind.mobil)); 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. *
--- a/artifacts/src/main/resources/messages.properties Fri Apr 27 17:35:12 2018 +0200 +++ b/artifacts/src/main/resources/messages.properties Fri Apr 27 17:41:59 2018 +0200 @@ -1018,4 +1018,6 @@ uinfo.export.csv.meta.header.veg.name = Vegetationszonen uinfo.export.csv.meta.header.veg.dauervon = \u00dcberflutungsdauer von [d/a] uinfo.export.csv.meta.header.veg.dauerbis = \u00dcberflutungsdauer bis [d/a] - \ No newline at end of file + +predefineddepthevol.total.title = Gesamt: {0} +predefineddepthevol.peryear.title = J\u00e4hrlich: {0}
--- a/artifacts/src/main/resources/messages_de.properties Fri Apr 27 17:35:12 2018 +0200 +++ b/artifacts/src/main/resources/messages_de.properties Fri Apr 27 17:41:59 2018 +0200 @@ -1017,4 +1017,7 @@ uinfo.export.csv.meta.header.veg.name = Vegetationszonen uinfo.export.csv.meta.header.veg.dauervon = \u00dcberflutungsdauer von [d/a] -uinfo.export.csv.meta.header.veg.dauerbis = \u00dcberflutungsdauer bis [d/a] \ No newline at end of file +uinfo.export.csv.meta.header.veg.dauerbis = \u00dcberflutungsdauer bis [d/a] + +predefineddepthevol.total.title = Gesamt: {0} +predefineddepthevol.peryear.title = J\u00e4hrlich: {0}
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Fri Apr 27 17:35:12 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Fri Apr 27 17:41:59 2018 +0200 @@ -1488,6 +1488,16 @@ String sinfo_predefined_tkh(); + String predefined_tkh_berechnung(); + + String predefined_tkh_messung(); + + String sinfo_predefined_depthevol(); + + String predefined_depthevol_aktuell(); + + String predefined_depthevol_etappe(); + String uinfo(); String uinfo_salix_line_export();
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Fri Apr 27 17:35:12 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Fri Apr 27 17:41:59 2018 +0200 @@ -793,6 +793,12 @@ sinfo_additional_ls_withoutQ = ohne Abfluss sinfo_predefined_tkh = Transportk\u00f6rperh\u00f6hen +predefined_tkh_berechnung = Berechnungsergebnisse +predefined_tkh_messung = Naturmessungen + +sinfo_predefined_depthevol = Flie\u00dftiefenentwicklung +predefined_depthevol_aktuell = Bezug aktueller GlW +predefined_depthevol_etappe = GlW-Etappen uinfo = U-INFO uinfo_inundation_duration_export = \u00dcberflutungsdauern Export
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Fri Apr 27 17:35:12 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Fri Apr 27 17:41:59 2018 +0200 @@ -793,6 +793,12 @@ sinfo_additional_ls_withoutQ = ohne Abfluss sinfo_predefined_tkh = Transportk\u00f6rperh\u00f6hen +predefined_tkh_berechnung = Berechnungsergebnisse +predefined_tkh_messung = Naturmessungen + +sinfo_predefined_depthevol = Flie\u00dftiefenentwicklung +predefined_depthevol_aktuell = Bezug aktueller GlW +predefined_depthevol_etappe = GlW-Etappen uinfo = U-INFO uinfo_inundation_duration_export = \u00dcberflutungsdauern Export