Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeCurveArtifact.java @ 3974:22cd60315e08
dummy merge for repo head
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:15:45 +0200 |
parents | 4e1b3b4ef132 |
children | a4930c43b806 |
rev | line source |
---|---|
3936
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
2 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
5 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
6 import org.apache.log4j.Logger; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
7 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
8 import org.w3c.dom.Document; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
9 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifactdatabase.state.DefaultOutput; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifactdatabase.state.Facet; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
12 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.artifacts.ArtifactFactory; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.artifacts.CallMeta; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
15 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.artifacts.common.utils.XMLUtils; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
18 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.flys.artifacts.states.StaticState; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.flys.artifacts.StaticFLYSArtifact; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.flys.artifacts.model.GaugeDischargeCurveFacet; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
22 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.flys.model.Gauge; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
24 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
25 import de.intevation.flys.utils.FLYSUtils; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
26 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
27 /** |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
28 * Artifact to calculate a discharge curve from a gauge overview info |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
29 * |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
30 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
31 */ |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
32 public class GaugeDischargeCurveArtifact |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
33 extends AbstractStaticStateArtifact |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
34 { |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
35 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
36 private static final Logger logger = |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
37 Logger.getLogger(GaugeDischargeCurveArtifact.class); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
38 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
39 public static final String XPATH_RIVER = "/art:action/art:river/@name"; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
40 public static final String XPATH_GAUGE = "/art:action/art:gauge/@reference"; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
41 public static final String NAME = "gaugedischargecurve"; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
42 public static final String STATIC_STATE_NAME = "state.gaugedischargecurve.static"; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
43 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
44 /** |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
45 * Setup initializes the data by extracting the river and gauge from |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
46 * the XML Document. |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
47 */ |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
48 @Override |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
49 public void setup( |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
50 String identifier, |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
51 ArtifactFactory factory, |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
52 Object context, |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
53 CallMeta callmeta, |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
54 Document data) |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
55 { |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
56 logger.debug("GaugeDischargeCurveArtifact.setup"); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
57 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
58 if (logger.isDebugEnabled()) { |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
59 logger.debug("GaugeDischargeCurveState.setup" + XMLUtils.toString(data)); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
60 } |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
61 String gaugeref = XMLUtils.xpathString(data, XPATH_GAUGE, |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
62 ArtifactNamespaceContext.INSTANCE); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
63 String rivername = XMLUtils.xpathString(data, XPATH_RIVER, |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
64 ArtifactNamespaceContext.INSTANCE); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
65 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
66 addStringData("river", rivername); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
67 addStringData("reference_gauge", gaugeref); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
68 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
69 Gauge gauge = FLYSUtils.getReferenceGauge(this); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
70 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
71 Facet gfacet = new GaugeDischargeCurveFacet(rivername, gauge); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
72 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
73 List<Facet> fs = new ArrayList<Facet>(1); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
74 fs.add(gfacet); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
75 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
76 addFacets(STATIC_STATE_NAME, fs); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
77 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
78 super.setup(identifier, factory, context, callmeta, data); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
79 } |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
80 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
81 @Override |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
82 public String getName() { |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
83 return NAME; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
84 } |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
85 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
86 @Override |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
87 protected void initStaticState() { |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
88 StaticState state = new StaticState(STATIC_STATE_NAME); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
89 List<Facet> fs = facets.get(STATIC_STATE_NAME); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
90 DefaultOutput output = new DefaultOutput( |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
91 "discharge_curve", |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
92 "output.discharge_curve", "image/png", |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
93 fs, |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
94 "chart"); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
95 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
96 state.addOutput(output); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
97 setStaticState(state); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
98 } |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
99 } |