Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java @ 2302:300d50f74dab
Handle manual points in discharge curve generator.
flys-artifacts/trunk@3970 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 08 Feb 2012 14:45:53 +0000 |
parents | baefcfba97aa |
children | 64dc2997b2dd |
rev | line source |
---|---|
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
1969
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
3 import java.util.Collection; |
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import org.apache.log4j.Logger; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import org.w3c.dom.Document; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.Element; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifacts.ArtifactNamespaceContext; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.CallContext; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
1969
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
14 import de.intevation.artifactdatabase.data.StateData; |
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.artifactdatabase.ProtocolUtils; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.artifactdatabase.state.Facet; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.artifactdatabase.state.Output; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.artifactdatabase.state.State; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.artifacts.common.utils.XMLUtils; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
1969
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
23 /** |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
24 * A basic FLYSArtifact. |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
25 */ |
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 public abstract class StaticFLYSArtifact extends FLYSArtifact { |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 private static final Logger logger = |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 Logger.getLogger(StaticFLYSArtifact.class); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
1969
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
32 /** |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
33 * Create description document which includes outputmodes. |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
34 * @param data ignored. |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
35 */ |
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 @Override |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 public Document describe(Document data, CallContext cc) { |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 logger.debug("Describe artifact: " + identifier()); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 Document desc = XMLUtils.newDocument(); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 ElementCreator creator = new ElementCreator( |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 desc, |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 ArtifactNamespaceContext.NAMESPACE_URI, |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 Element root = ProtocolUtils.createRootNode(creator); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 desc.appendChild(root); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 ProtocolUtils.appendDescribeHeader(creator, root, identifier(), hash()); |
943
5de90b0cff8e
The WMSLayerFacet now writes the WMS URL and layernames to its XML representation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
51 root.appendChild(createOutputModes(cc, desc, creator)); |
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
1969
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
53 // Add the data to an anonymous state. |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
54 Collection<StateData> datas = this.data.values(); |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
55 if (datas.size() > 0) { |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
56 Element ui = creator.create("ui"); |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
57 Element staticE = creator.create("static"); |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
58 Element state = creator.create("state"); |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
59 ui.appendChild(staticE); |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
60 staticE.appendChild(state); |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
61 root.appendChild(ui); |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
62 |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
63 for (StateData dataItem : datas) { |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
64 Element itemelent = creator.create("data"); |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
65 creator.addAttr(itemelent, "name", dataItem.getName(), true); |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
66 creator.addAttr(itemelent, "type", dataItem.getType(), true); |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
67 state.appendChild(itemelent); |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
68 Element valuement = creator.create("item"); |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
69 creator.addAttr(valuement, "label", dataItem.getDescription(), true); |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
70 creator.addAttr(valuement, "value", dataItem.getValue().toString(), true); |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
71 itemelent.appendChild(valuement); |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
72 } |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
73 } |
baefcfba97aa
Add data items to StaticFLYSArtifacts description document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
74 |
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 return desc; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 |
943
5de90b0cff8e
The WMSLayerFacet now writes the WMS URL and layernames to its XML representation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
79 protected Element createOutputModes( |
5de90b0cff8e
The WMSLayerFacet now writes the WMS URL and layernames to its XML representation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
80 CallContext cc, |
5de90b0cff8e
The WMSLayerFacet now writes the WMS URL and layernames to its XML representation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
81 Document doc, |
5de90b0cff8e
The WMSLayerFacet now writes the WMS URL and layernames to its XML representation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
82 ElementCreator creator) |
5de90b0cff8e
The WMSLayerFacet now writes the WMS URL and layernames to its XML representation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
83 { |
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 Element outs = ProtocolUtils.createArtNode( |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 creator, "outputmodes", null, null); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 State state = getCurrentState(cc); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 List<Output> list = state.getOutputs(); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 if (list != null && list.size() > 0) { |
1771
c62ff9e72cea
Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1765
diff
changeset
|
91 List<Facet> fs = facets.get(state.getID()); |
c62ff9e72cea
Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1765
diff
changeset
|
92 if (fs != null && fs.size() > 0) { |
c62ff9e72cea
Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1765
diff
changeset
|
93 List<Output> generated = generateOutputs(list, fs); |
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 |
1771
c62ff9e72cea
Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1765
diff
changeset
|
95 logger.debug("Found " + fs.size() + " current facets."); |
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 if (!generated.isEmpty()) { |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 ProtocolUtils.appendOutputModes( |
943
5de90b0cff8e
The WMSLayerFacet now writes the WMS URL and layernames to its XML representation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
937
diff
changeset
|
98 doc, outs, generated); |
937
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 else { |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 logger.debug("No facets found for the current state."); |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 return outs; |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 } |
9e813e9137a5
Added a monitor that creates new artifacts for default themes in charts and maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |