annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/WaterlevelArtifact.java @ 1745:4ae7df2a74ed

Fix NPE in WDiff-diagram because no ranges present in masterartifact. flys-artifacts/trunk@3039 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 19 Oct 2011 16:06:01 +0000
parents f643ea084213
children 5d8b3880a553
rev   line source
1629
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts;
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
3 import de.intevation.artifactdatabase.state.Facet;
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
4
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5 import de.intevation.artifacts.Artifact;
1703
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
6 import de.intevation.artifacts.ArtifactFactory;
1629
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7 import de.intevation.artifacts.CallMeta;
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
8
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
9 import de.intevation.flys.artifacts.states.DefaultState;
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 import java.util.ArrayList;
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12 import java.util.List;
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 import org.apache.log4j.Logger;
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15
1703
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
16 import org.w3c.dom.Document;
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
17
1629
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19 /**
1703
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
20 * Clone of an WINFOArtifact to expose exactly one waterlevel only.
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
21 * All Facets of the "longitudinal_section" output will be added to the
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
22 * "w_differences" output and filterFacets adjusted accordingly.
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
23 *
1629
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
24 * @TODO Straighten inheritance-line (waterlevel-WINFO or vice versa).
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25 */
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 public class WaterlevelArtifact extends WINFOArtifact {
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28 /** The logger for this class. */
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29 private static Logger logger = Logger.getLogger(WaterlevelArtifact.class);
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31 /** The name of the artifact. */
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32 public static final String ARTIFACT_NAME = "waterlevel";
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35 /**
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 * The default constructor.
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 */
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 public WaterlevelArtifact() {
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 }
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 /**
1703
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
43 * Setup and restate longitudinal_section filterfacets to apply to the
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
44 * w_differences output, too.
1629
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 */
1703
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
46 public void setup(
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
47 String identifier,
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
48 ArtifactFactory factory,
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
49 Object context,
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
50 CallMeta callMeta,
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
51 Document data)
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
52 {
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
53 super.setup(identifier, factory, context, callMeta, data);
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
54 filterFacets.put(
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
55 "w_differences",
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
56 filterFacets.get("longitudinal_section"));
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
57 }
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
58
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
59 /**
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
60 * Clone important stuff of an WINFOArtifact.
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
61 * @param artifact the WINFOArtifact to clone stuff from.
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
62 */
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
63 protected void initialize(
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
64 Artifact artifact,
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
65 Object context,
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
66 CallMeta meta)
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
67 {
1629
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68 WINFOArtifact winfo = (WINFOArtifact) artifact;
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 this.data = winfo.cloneData();
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 logger.debug("Cloned data of winfo artifact.");
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71 // Statically add Facets.
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 List<Facet> fs = new ArrayList<Facet>();
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 DefaultState state = (DefaultState) getCurrentState(context);
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74 state.computeInit(this, hash(), context, meta, fs);
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 if (!fs.isEmpty()) {
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76 logger.debug("Facets to add in WaterlevelArtifact.initialize .");
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77 facets.put(getCurrentStateId(), fs);
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 }
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79 else {
1703
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
80 logger.debug("No facets to add in WaterlevelArtifact.initialize ("
71d369ab789d Fix remainder of flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1629
diff changeset
81 + state.getID() + ").");
1629
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82 }
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83 }
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
84
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
85
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
86 /**
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87 * Returns the name of the concrete artifact.
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
88 *
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
89 * @return the name of the concrete artifact.
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
90 */
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
91 public String getName() {
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
92 return ARTIFACT_NAME;
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
93 }
1709
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
94
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
95 /**
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
96 * Determines Facets initial disposition regarding activity (think of
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
97 * selection in Client ThemeList GUI).
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
98 * WaterlevelArtifact Facets should come to live "inactive" (always
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
99 * return 0).
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
100 *
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
101 * @param facetName name of the facet.
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
102 * @param index index of the facet.
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
103 *
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
104 * @return Always 0 to have Facets initial predisposition to "inactive".
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
105 */
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
106 @Override
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
107 public int getInitialFacetActivity(String facetName, int index) {
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
108 return 0;
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1708
diff changeset
109 }
1629
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
110 }
4aec853a2f85 Added WaterlevelArtifact and respective infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
111 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org