annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefineddepthevol/PredefinedDepthEvolArtifact.java @ 9034:8aa7d9eaaa21

Added bed_height_values section heights height01 to height10
author mschaefer
date Mon, 30 Apr 2018 10:13:15 +0200
parents 384eee4b4135
children
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.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
15
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 import org.apache.log4j.Logger;
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.artifactdatabase.state.DefaultOutput;
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.artifactdatabase.state.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
19 import org.dive4elements.artifactdatabase.state.FacetActivity;
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.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
21 import org.dive4elements.artifacts.ArtifactFactory;
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.artifacts.CallMeta;
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.artifacts.common.utils.XMLUtils;
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.AbstractStaticStateArtifact;
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.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
26 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
27 import org.dive4elements.river.artifacts.sinfo.common.PredefinedDepthEvolPerYearProcessor;
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 import org.dive4elements.river.artifacts.sinfo.common.PredefinedDepthEvolProcessor;
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 import org.dive4elements.river.artifacts.states.StaticState;
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 import org.w3c.dom.Document;
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
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 * Display of a depth evolution data series loaded from 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
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 * @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
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 */
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 public class PredefinedDepthEvolArtifact extends AbstractStaticStateArtifact 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
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 /** The log for this class. */
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 private static Logger log = Logger.getLogger(PredefinedDepthEvolArtifact.class);
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 /** Artifact name. */
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 private static final String NAME = "depth_evol";
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
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 static {
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 // TODO: Move to configuration.
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 FacetActivity.Registry.getInstance().register(NAME, FacetActivity.INACTIVE);
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 }
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
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 public static final String STATIC_STATE_NAME = "state.predefined_depthevol.static";
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
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 /**
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 * Trivial Constructor.
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 */
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 PredefinedDepthEvolArtifact() {
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 log.debug("new PredefinedDepthEvolArtifact");
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 }
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
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 @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
61 public String getName() {
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 return NAME;
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 }
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
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 /**
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 * Gets called from factory, to set things up.
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 */
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 @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
69 public void setup(final String identifier, final ArtifactFactory factory, final Object context, final CallMeta callMeta, final Document data,
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 final List<Class> loadFacets) {
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
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 log.debug("PredefinedDepthEvolArtifact.setup");
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
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 if (log.isDebugEnabled()) {
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 log.debug(XMLUtils.toString(data));
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 }
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
9034
8aa7d9eaaa21 Added bed_height_values section heights height01 to height10
mschaefer
parents: 9033
diff changeset
78 // FIXME Irgendwie muss es doch möglich sein, an das name-Attribut aus meta-data.xml ranzukommen
8aa7d9eaaa21 Added bed_height_values section heights height01 to height10
mschaefer
parents: 9033
diff changeset
79 // (jetzt provisorisch in ids untergebracht)
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
80 final String code = getDatacageIDValue(data);
9034
8aa7d9eaaa21 Added bed_height_values section heights height01 to height10
mschaefer
parents: 9033
diff changeset
81 final String seriesName = (code.split("-").length >= 3) ? code.split("-", 3)[2] : "name?";
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
82
9034
8aa7d9eaaa21 Added bed_height_values section heights height01 to height10
mschaefer
parents: 9033
diff changeset
83 createFacets(callMeta, code, seriesName);
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
84
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
85 super.setup(identifier, factory, context, callMeta, data, loadFacets);
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
86 }
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
87
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
88 private void createFacets(final CallMeta callMeta, final String code, final String seriesName) {
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
89 if (code == null)
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
90 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
91 final String[] parts = code.split("-");
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
92 if (parts.length < 2) {
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
93 log.error("Invalid datacage ID '" + code + "'");
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
94 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
95 }
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
96 addStringData("depthevol_id", parts[1]);
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
97 final ArrayList<Facet> facets = new ArrayList<>(2);
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
98 facets.add(PredefinedDepthEvolProcessor.createFacet(callMeta, seriesName));
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
99 facets.add(PredefinedDepthEvolPerYearProcessor.createFacet(callMeta, seriesName));
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
100 addFacets(STATIC_STATE_NAME, facets);
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
101 }
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
102
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
103 @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
104 protected void initStaticState() {
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
105
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
106 log.debug("initStaticState " + getName() + " " + identifier());
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
107
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
108 final StaticState state = new StaticState(STATIC_STATE_NAME);
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
109 final DefaultOutput output = new DefaultOutput("general", "general", "image/png", "chart");
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
110
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
111 final List<Facet> facets = getFacets(STATIC_STATE_NAME);
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
112 output.addFacets(facets);
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
113 state.addOutput(output);
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
114
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
115 setStaticState(state);
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
116 }
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
117
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
118 @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
119 protected void initialize(final Artifact artifact, final Object context, final CallMeta meta) {
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
120 // do not clone facets, etc. from master 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
121
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
122 log.debug("initialize");
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
123 importData((D4EArtifact) artifact, "river");
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
124 importData((D4EArtifact) artifact, "ld_from");
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
125 importData((D4EArtifact) artifact, "ld_to");
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
126
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
127 log.debug("ld_from " + getDataAsString("ld_from"));
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
128 log.debug("ld_to " + getDataAsString("ld_to"));
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
129 }
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
130 }

http://dive4elements.wald.intevation.org