annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/HYKArtifact.java @ 5273:db196abd16ca

Use lookup table from bedd_height from database in importer.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 13 Mar 2013 16:39:08 +0100
parents a2735a4bf75e
children
rev   line source
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
3 import java.util.ArrayList;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
4 import java.util.List;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
6 import org.apache.log4j.Logger;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
8 import org.w3c.dom.Document;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
9
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10 import de.intevation.artifacts.Artifact;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 import de.intevation.artifacts.ArtifactFactory;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12 import de.intevation.artifacts.CallMeta;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 import de.intevation.flys.artifacts.states.DefaultState;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 import de.intevation.artifactdatabase.state.Facet;
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
18 import de.intevation.artifactdatabase.state.FacetActivity;
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21 /**
2147
79044646f4eb Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2139
diff changeset
22 * Artifact to get hydr zones (HYKs).
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
23 */
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
24 public class HYKArtifact extends StaticFLYSArtifact {
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 /** Name of Artifact. */
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 public static final String HYK_ARTIFACT_NAME = "hyk";
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28
2139
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
29 /** Name of data item keeping the hyk id to load formations from. */
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
30 public static final String HYK_ID = "hyk_artifact.data.id";
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
31
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32 /** Name of data item keeping the km of cs master. */
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33 public static final String HYK_KM = "hyk_artifact.data.km";
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35 /** Own logger. */
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 private static final Logger logger =
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 Logger.getLogger(HYKArtifact.class);
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
39 static {
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
40 // TODO: Move to configuration.
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
41 FacetActivity.Registry.getInstance()
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
42 .register(HYK_ARTIFACT_NAME, FacetActivity.INACTIVE);
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
43 }
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 /** Return given name. */
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 @Override
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 public String getName() {
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 return HYK_ARTIFACT_NAME;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52 /** Store ids, do super.setup. */
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
53 @Override
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54 public void setup(
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 String identifier,
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 ArtifactFactory factory,
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 Object context,
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 CallMeta callMeta,
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 Document data)
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 {
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 logger.info("HYKArtifact.setup");
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62
2741
0251393f037c Refactor usage of now static xpath, other artifacts will follow in later commits.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2740
diff changeset
63 String ids = getDatacageIDValue(data);
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64
2139
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
65 logger.info("HYKArtifact.setup: id is " + ids);
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
66
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
67 addStringData(HYK_ID, ids);
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
68
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
69 super.setup(identifier, factory, context, callMeta, data);
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 /** Set km as Data. */
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74 public void setKm(double km) {
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 addStringData(HYK_KM, Double.toString(km));
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78
2701
c553d4fa3957 Moved the implementation of getDataAsDouble() from concrete Artifacts into FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2147
diff changeset
79 /** Get km from state data. */
c553d4fa3957 Moved the implementation of getDataAsDouble() from concrete Artifacts into FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2147
diff changeset
80 public double getKm() {
c553d4fa3957 Moved the implementation of getDataAsDouble() from concrete Artifacts into FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2147
diff changeset
81 Double km = getDataAsDouble(HYK_KM);
c553d4fa3957 Moved the implementation of getDataAsDouble() from concrete Artifacts into FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2147
diff changeset
82 if (km == null) {
c553d4fa3957 Moved the implementation of getDataAsDouble() from concrete Artifacts into FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2147
diff changeset
83 // XXX returning 0 is to be compatible to older versions that had an
c553d4fa3957 Moved the implementation of getDataAsDouble() from concrete Artifacts into FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2147
diff changeset
84 // own method getDataAsDouble that returned 0 if parsing the
c553d4fa3957 Moved the implementation of getDataAsDouble() from concrete Artifacts into FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2147
diff changeset
85 // parameter failed.
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
86 return 0;
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87 }
2701
c553d4fa3957 Moved the implementation of getDataAsDouble() from concrete Artifacts into FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2147
diff changeset
88 else {
c553d4fa3957 Moved the implementation of getDataAsDouble() from concrete Artifacts into FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2147
diff changeset
89 return km;
c553d4fa3957 Moved the implementation of getDataAsDouble() from concrete Artifacts into FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2147
diff changeset
90 }
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
91 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
92
2147
79044646f4eb Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2139
diff changeset
93
2139
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
94 /** Get hyk-id from state data. */
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
95 public int getHykId() {
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
96 return getDataAsInteger(HYK_ID);
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
97 }
923256599afe Somewhat improved hyk handling and rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2131
diff changeset
98
2147
79044646f4eb Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2139
diff changeset
99
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
100 /** Do not copy data from daddyfact. */
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
101 @Override
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
102 protected void initialize(
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
103 Artifact artifact,
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
104 Object context,
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
105 CallMeta callMeta)
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
106 {
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
107 logger.debug("HYKArtifact.initialize");
3894
4aadcb90dc77 fix issue887 (hyk in new chart).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
108 importData((FLYSArtifact)artifact, "river");
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
109
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
110 List<Facet> fs = new ArrayList<Facet>();
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
111
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
112 DefaultState state = (DefaultState) getCurrentState(context);
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
113 state.computeInit(this, hash(), context, callMeta, fs);
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2763
diff changeset
114 if (!fs.isEmpty()) {
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2763
diff changeset
115 logger.debug("Facets to add in HYKArtifact.initialize .");
4497
a2735a4bf75e Change facets member variable to private
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3894
diff changeset
116 addFacets(getCurrentStateId(), fs);
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2763
diff changeset
117 }
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2763
diff changeset
118 else {
2131
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
119 logger.debug("No facets to add in HYKArtifact.initialize ("
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
120 + state.getID() + ").");
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
121 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
122 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
123 }
e50a928187cd Added stubby hyk infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
124 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org