Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefineddepthevol/PredefinedDepthEvolFacet.java @ 9033:384eee4b4135
Added datacage select and chart display for flow depth evolution series loaded from database, and a correction for the tkh data
author | mschaefer |
---|---|
date | Fri, 27 Apr 2018 17:41:59 +0200 |
parents | |
children | a4121ec450d6 |
comparison
equal
deleted
inserted
replaced
9032:1f63e9d3b0ec | 9033:384eee4b4135 |
---|---|
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.predefineddepthevol; | |
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.DepthEvolution; | |
26 import org.dive4elements.river.model.sinfo.DepthEvolutionValue; | |
27 | |
28 /** | |
29 * Facet for a depth evolution value series loaded from the database | |
30 * | |
31 * @author Matthias Schäfer | |
32 */ | |
33 public class PredefinedDepthEvolFacet extends BlackboardDataFacet implements FacetTypes { | |
34 | |
35 private static final long serialVersionUID = -4298111901634067027L; | |
36 | |
37 public PredefinedDepthEvolFacet(final String name, final String description, final String yAxisLabel) { | |
38 super(0, name, description); | |
39 | |
40 this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); | |
41 this.metaData.put("Y", yAxisLabel); | |
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 PredefinedDepthEvolQueryCalculationResult | |
54 */ | |
55 @Override | |
56 public Object getData(final Artifact artifact, final CallContext context) { | |
57 | |
58 final PredefinedDepthEvolAccess access = new PredefinedDepthEvolAccess((D4EArtifact) artifact); | |
59 final DepthEvolution series = DepthEvolution.getSeries(access.getId()); | |
60 final List<DepthEvolutionValue> values = DepthEvolutionValue.getValues(series, access.getFrom(true), access.getTo(true)); | |
61 final Collection<ResultRow> rows = new ArrayList<>(); | |
62 for (final DepthEvolutionValue value : values) { | |
63 rows.add(ResultRow.create().putValue(GeneralResultType.station, value.getStation()) // | |
64 .putValue(SInfoResultType.flowdepthDevelopment, value.getTotalChangeCm()) // | |
65 .putValue(SInfoResultType.flowdepthDevelopmentPerYear, value.getPerYearChangeCm())); | |
66 } | |
67 return new PredefinedDepthEvolQueryCalculationResult(series.getFilename(), rows); | |
68 } | |
69 | |
70 /** | |
71 * Create a deep copy of this Facet. | |
72 * | |
73 * @return a deep copy. | |
74 */ | |
75 @Override | |
76 public PredefinedDepthEvolFacet deepCopy() { | |
77 final PredefinedDepthEvolFacet copy = new PredefinedDepthEvolFacet(this.name, this.description, this.metaData.get("Y")); | |
78 copy.set(this); | |
79 return copy; | |
80 } | |
81 } |