annotate flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeParser.java @ 4488:5041105d2edd

Check if response code from GGInA is 200 OK Only parse the GGInA response if the status code is 200 OK. This improves the error message if GGInA is not available and shows the real reason instead of a JDOM error while parsing the response.
author Björn Ricks <bjoern.ricks@intevation.de>
date Wed, 14 Nov 2012 10:36:21 +0100
parents ef0db530c341
children
rev   line source
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.collections;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
1779
2fe270661b20 Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
3 import java.util.List;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.util.Map;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import javax.xml.xpath.XPathConstants;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import org.apache.log4j.Logger;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import org.w3c.dom.Document;
694
68c6c75a6f7c Add index and description of facets to collections describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 638
diff changeset
11 import org.w3c.dom.Element;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import org.w3c.dom.Node;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import org.w3c.dom.NodeList;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import de.intevation.artifacts.ArtifactNamespaceContext;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import de.intevation.artifactdatabase.state.DefaultOutput;
1779
2fe270661b20 Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
18 import de.intevation.artifactdatabase.state.Facet;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import de.intevation.artifactdatabase.state.Output;
1994
3e703d134bbe Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1976
diff changeset
20 import de.intevation.artifactdatabase.state.Settings;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import de.intevation.artifacts.common.utils.XMLUtils;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
945
59ae2a823e73 Use the Facet.toXML() method to write facet elements into the DESCRIBE document of the Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 694
diff changeset
24 import de.intevation.flys.artifacts.model.ManagedDomFacet;
1994
3e703d134bbe Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1976
diff changeset
25 import de.intevation.flys.exports.ChartSettings;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
1779
2fe270661b20 Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
27 /**
2fe270661b20 Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
28 * Access parts of the Attribute parts of a FLYSCollections description
2fe270661b20 Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
29 * document.
2fe270661b20 Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
30 */
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 public class AttributeParser {
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
1624
238145ef67da Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 945
diff changeset
33 /** Constant XPath that points to the outputmodes of an artifact. */
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 public static final String XPATH_ARTIFACT_OUTPUTMODES =
638
9c565eb46f06 Fixed the process of creating and storing the attribute of a collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 349
diff changeset
35 "/art:attribute/art:outputs/art:output";
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
37
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 private static Logger logger = Logger.getLogger(AttributeParser.class);
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
41 protected Document attributeDocument;
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
42
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
43 protected CollectionAttribute attribute;
1779
2fe270661b20 Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
44
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
46 public AttributeParser(Document attributeDocument) {
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
47 this.attributeDocument = attributeDocument;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
51 public void parse() {
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 logger.debug("AttributeParser.parse");
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
54 attribute = new CollectionAttribute();
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
55
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 NodeList outs = (NodeList) XMLUtils.xpath(
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
57 attributeDocument,
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 XPATH_ARTIFACT_OUTPUTMODES,
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 XPathConstants.NODESET,
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 ArtifactNamespaceContext.INSTANCE);
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 int num = outs != null ? outs.getLength() : 0;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 logger.debug("Attribute has " + num + " outputs.");
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 for (int i = 0; i < num; i++) {
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 Node out = outs.item(i);
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 parseOutput(out);
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
74 public CollectionAttribute getCollectionAttribute() {
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
75 if (attribute == null) {
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
76 parse();
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
77 }
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
78
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
79 return attribute;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
83 public Document getAttributeDocument() {
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
84 return attributeDocument;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
88 public Map<String, Output> getOuts() {
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
89 return attribute.getOutputs();
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92
1779
2fe270661b20 Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
93 /**
2fe270661b20 Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
94 * Access all facets.
2fe270661b20 Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
95 * @return list of all facets.
2fe270661b20 Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
96 */
2fe270661b20 Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
97 public List<Facet> getFacets() {
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
98 return attribute.getFacets();
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
99 }
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
100
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
101
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
102 protected void parseOutput(Node out) {
2779
e57816cf41d5 Replaced another silly "@attribute" XPATH with direct getAttribute() call.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1994
diff changeset
103 String name = ((Element)out).getAttribute("name");
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
104
2779
e57816cf41d5 Replaced another silly "@attribute" XPATH with direct getAttribute() call.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1994
diff changeset
105 if (name.length() == 0) {
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
106 logger.warn("No Output name specified. Cancel parsing!");
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
107 return;
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
108 }
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
109
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
110 Output o = attribute.getOutput(name);
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
111
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
112 if (o == null) {
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
113 logger.debug("Create new output: " + name);
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
114
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
115 o = new DefaultOutput(name, null, null);
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
116 attribute.addOutput(name, o);
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
117 }
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
118
1994
3e703d134bbe Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1976
diff changeset
119 parseSettings(out, name);
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1779
diff changeset
120 parseItems(out, name);
1779
2fe270661b20 Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
121 }
2fe270661b20 Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
122
3191
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
123 private static final Node getChild(Element element, String name) {
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
124 NodeList children = element.getChildNodes();
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
125 for (int i = 0, N = children.getLength(); i < N; ++i) {
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
126 Node child = children.item(i);
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
127 if (child.getNodeType() == Node.ELEMENT_NODE
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
128 && child.getLocalName().equals(name)) {
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
129 return child;
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
130 }
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
131 }
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
132 return null;
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
133 }
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
134
1779
2fe270661b20 Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
135
1994
3e703d134bbe Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1976
diff changeset
136 protected void parseSettings(Node out, String outname) {
3191
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
137 Node settingsNode = getChild((Element)out, "settings");
1994
3e703d134bbe Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1976
diff changeset
138
3e703d134bbe Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1976
diff changeset
139 if (settingsNode == null) {
3e703d134bbe Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1976
diff changeset
140 logger.debug("No Settings found for Output '" + outname + "'");
3e703d134bbe Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1976
diff changeset
141 return;
3e703d134bbe Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1976
diff changeset
142 }
3e703d134bbe Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1976
diff changeset
143
3e703d134bbe Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1976
diff changeset
144 Settings settings = ChartSettings.parse(settingsNode);
3e703d134bbe Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1976
diff changeset
145 attribute.setSettings(outname, settings);
3e703d134bbe Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1976
diff changeset
146 }
3e703d134bbe Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1976
diff changeset
147
3e703d134bbe Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1976
diff changeset
148
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 protected void parseItems(Node out, String outname) {
3191
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
150 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
151 Element element = (Element)out;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152
3191
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
153 NodeList themes = element.getElementsByTagNameNS(uri, "facet");
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
154
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
155 int num = themes.getLength();
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 logger.debug("Output has " + num + " themes.");
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158
694
68c6c75a6f7c Add index and description of facets to collections describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 638
diff changeset
159 for (int i = 0; i < num; i++) {
68c6c75a6f7c Add index and description of facets to collections describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 638
diff changeset
160 Element theme = (Element) themes.item(i);
3191
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
161 if (theme.getParentNode() == out) {
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
162 attribute.addFacet(outname, new ManagedDomFacet(theme));
ef0db530c341 Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2779
diff changeset
163 }
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
166 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org