comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/WaterlevelArtifact.java @ 5831:bd047b71ab37

Repaired internal references
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:06:39 +0200
parents flys-artifacts/src/main/java/de/intevation/flys/artifacts/WaterlevelArtifact.java@d440057b36f7
children
comparison
equal deleted inserted replaced
5830:160f53ee0870 5831:bd047b71ab37
1 package org.dive4elements.river.artifacts;
2
3 import org.dive4elements.artifactdatabase.state.DefaultFacet;
4 import org.dive4elements.artifactdatabase.state.Facet;
5 import org.dive4elements.artifactdatabase.state.FacetActivity;
6
7 import org.dive4elements.artifacts.Artifact;
8 import org.dive4elements.artifacts.ArtifactFactory;
9 import org.dive4elements.artifacts.CallMeta;
10
11 import org.dive4elements.river.artifacts.states.DefaultState;
12
13 import java.util.ArrayList;
14 import java.util.List;
15
16 import org.apache.log4j.Logger;
17
18 import org.w3c.dom.Document;
19
20
21 /**
22 * Clone of an WINFOArtifact to expose exactly one waterlevel only.
23 * All Facets of the "longitudinal_section" output will be added to the
24 * "w_differences" output and filterFacets adjusted accordingly.
25 *
26 * @TODO Straighten inheritance-line (waterlevel-WINFO or vice versa).
27 */
28 public class WaterlevelArtifact extends WINFOArtifact {
29
30 /** The logger for this class. */
31 private static Logger logger = Logger.getLogger(WaterlevelArtifact.class);
32
33 /** The name of the artifact. */
34 public static final String ARTIFACT_NAME = "waterlevel";
35
36 static {
37 // TODO: Move to configuration.
38 FacetActivity.Registry.getInstance()
39 .register(ARTIFACT_NAME, FacetActivity.INACTIVE);
40 }
41
42 /**
43 * The default constructor.
44 */
45 public WaterlevelArtifact() {
46 }
47
48
49 /**
50 * Setup and restate longitudinal_section filterfacets to apply to the
51 * w_differences output, too. Also, for w_differences, add respective q-
52 * filter facets.
53 */
54 public void setup(
55 String identifier,
56 ArtifactFactory factory,
57 Object context,
58 CallMeta callMeta,
59 Document data)
60 {
61 super.setup(identifier, factory, context, callMeta, data);
62 // For w_differences, also allow q-facets.
63 if(filterFacets != null) {
64 List<Facet> list = new ArrayList<Facet>();
65 List<Facet> wlist = filterFacets.get(ChartType.LS);
66 if (wlist == null) {
67 logger.warn("No matching filterfacets found");
68 dumpFilterFacets();
69 } else {
70 for (Facet f: wlist) {
71 if (!f.getName().equals(LONGITUDINAL_Q)) {
72 DefaultFacet df = new DefaultFacet(f.getIndex(),
73 "longitudinal_section.q", "");
74 list.add(df);
75 }
76 }
77
78 list.addAll(wlist);
79
80 filterFacets.put("w_differences", list);
81 }
82 }
83 }
84
85
86 /**
87 * Clone important stuff of an WINFOArtifact.
88 * @param artifact the WINFOArtifact to clone stuff from.
89 */
90 protected void initialize(
91 Artifact artifact,
92 Object context,
93 CallMeta meta)
94 {
95 WINFOArtifact winfo = (WINFOArtifact) artifact;
96 setData(winfo.cloneData());
97 logger.debug("Cloned data of winfo artifact.");
98 // Statically add Facets.
99 List<Facet> fs = new ArrayList<Facet>();
100 DefaultState state = (DefaultState) getCurrentState(context);
101 state.computeInit(this, hash(), context, meta, fs);
102 if (!fs.isEmpty()) {
103 logger.debug("Facets to add in WaterlevelArtifact.initialize .");
104 addFacets(getCurrentStateId(), fs);
105 }
106 else {
107 logger.debug("No facets to add in WaterlevelArtifact.initialize ("
108 + state.getID() + ").");
109 }
110 }
111
112
113 /**
114 * Returns the name of the concrete artifact.
115 *
116 * @return the name of the concrete artifact.
117 */
118 public String getName() {
119 return ARTIFACT_NAME;
120 }
121 }
122 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org