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

http://dive4elements.wald.intevation.org