comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WaterlevelArtifact.java @ 3786:4adc35aa655c

merged flys-artifacts/2.9.1
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:47 +0200
parents afc7bfb4800b
children 8483d190b2e7
comparison
equal deleted inserted replaced
3719:e82acd5c86f7 3786:4adc35aa655c
1 package de.intevation.flys.artifacts;
2
3 import de.intevation.artifactdatabase.state.DefaultFacet;
4 import de.intevation.artifactdatabase.state.Facet;
5 import de.intevation.artifactdatabase.state.FacetActivity;
6
7 import de.intevation.artifacts.Artifact;
8 import de.intevation.artifacts.ArtifactFactory;
9 import de.intevation.artifacts.CallMeta;
10
11 import de.intevation.flys.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("longitudinal_section");
66 for (Facet f: wlist) {
67 if (!f.getName().equals("longitudinal_section.q")) {
68 DefaultFacet df = new DefaultFacet(f.getIndex(),
69 "longitudinal_section.q", "");
70 list.add(df);
71 }
72 }
73
74 list.addAll(wlist);
75
76 filterFacets.put("w_differences", list);
77 }
78 }
79
80
81 /**
82 * Clone important stuff of an WINFOArtifact.
83 * @param artifact the WINFOArtifact to clone stuff from.
84 */
85 protected void initialize(
86 Artifact artifact,
87 Object context,
88 CallMeta meta)
89 {
90 WINFOArtifact winfo = (WINFOArtifact) artifact;
91 this.data = winfo.cloneData();
92 logger.debug("Cloned data of winfo artifact.");
93 // Statically add Facets.
94 List<Facet> fs = new ArrayList<Facet>();
95 DefaultState state = (DefaultState) getCurrentState(context);
96 state.computeInit(this, hash(), context, meta, fs);
97 if (!fs.isEmpty()) {
98 logger.debug("Facets to add in WaterlevelArtifact.initialize .");
99 facets.put(getCurrentStateId(), fs);
100 }
101 else {
102 logger.debug("No facets to add in WaterlevelArtifact.initialize ("
103 + state.getID() + ").");
104 }
105 }
106
107
108 /**
109 * Returns the name of the concrete artifact.
110 *
111 * @return the name of the concrete artifact.
112 */
113 public String getName() {
114 return ARTIFACT_NAME;
115 }
116 }
117 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org