comparison 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
comparison
equal deleted inserted replaced
9034:8aa7d9eaaa21 9035:c16e90a0baf7
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
2 * Software engineering by
3 * Björnsen Beratende Ingenieure GmbH
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
5 *
6 * This file is Free Software under the GNU AGPL (>=v3)
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
8 * documentation coming with Dive4Elements River for details.
9 */
10
11 package org.dive4elements.river.artifacts.sinfo.predefinedflowdepth;
12
13 import java.util.ArrayList;
14 import java.util.Collection;
15 import java.util.List;
16
17 import org.dive4elements.artifacts.Artifact;
18 import org.dive4elements.artifacts.CallContext;
19 import org.dive4elements.river.artifacts.D4EArtifact;
20 import org.dive4elements.river.artifacts.common.GeneralResultType;
21 import org.dive4elements.river.artifacts.common.ResultRow;
22 import org.dive4elements.river.artifacts.model.BlackboardDataFacet;
23 import org.dive4elements.river.artifacts.model.FacetTypes;
24 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType;
25 import org.dive4elements.river.model.sinfo.FlowDepthColumn;
26 import org.dive4elements.river.model.sinfo.FlowDepthValue;
27
28 /**
29 * Facet for a flow depth value series loaded from the database
30 *
31 * @author Matthias Schäfer
32 */
33 public class PredefinedFlowDepthFacet extends BlackboardDataFacet implements FacetTypes {
34
35 private static final long serialVersionUID = -5314814229001970855L;
36
37 public PredefinedFlowDepthFacet(final String name, final String description) {
38 super(0, name, description);
39
40 this.metaData.put("X", "chart.longitudinal.section.xaxis.label");
41 this.metaData.put("Y", "chart.flow_depth.section.yaxis.label");
42 }
43
44 /**
45 * Returns the data this facet requires.
46 *
47 * @param artifact
48 * the owner artifact.
49 * @param context
50 * the CallContext (ignored).
51 *
52 * @return
53 * the data as PredefinedFlowDepthQueryCalculationResult
54 */
55 @Override
56 public Object getData(final Artifact artifact, final CallContext context) {
57
58 final PredefinedFlowDepthColumnAccess access = new PredefinedFlowDepthColumnAccess((D4EArtifact) artifact);
59 final FlowDepthColumn series = FlowDepthColumn.getColumnById(access.getColumnId());
60 final List<FlowDepthValue> values = FlowDepthValue.getValues(series, access.getFrom(true), access.getTo(true));
61 final Collection<ResultRow> rows = new ArrayList<>();
62 for (final FlowDepthValue value : values) {
63 rows.add(ResultRow.create().putValue(GeneralResultType.station, value.getStation()) //
64 .putValue(SInfoResultType.flowdepth, value.getDepth()));
65 }
66 return new PredefinedFlowDepthQueryCalculationResult(series.getName(), rows);
67 }
68
69 /**
70 * Create a deep copy of this Facet.
71 *
72 * @return a deep copy.
73 */
74 @Override
75 public PredefinedFlowDepthFacet deepCopy() {
76 final PredefinedFlowDepthFacet copy = new PredefinedFlowDepthFacet(this.name, this.description);
77 copy.set(this);
78 return copy;
79 }
80 }

http://dive4elements.wald.intevation.org