diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedflowdepth/PredefinedFlowDepthFacet.java @ 9035:c16e90a0baf7

Added datacage select and chart display for modelled flow depth series loaded from database
author mschaefer
date Mon, 30 Apr 2018 16:00:12 +0200
parents
children a4121ec450d6
line wrap: on
line diff
--- /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 16:00:12 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

http://dive4elements.wald.intevation.org