Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/collections/AttributeParser.java @ 5865:73da40528cf2
River artifacts: Renamed FLYSUtils to RiverUtils.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sun, 28 Apr 2013 15:09:31 +0200 |
parents | 4897a58c8746 |
children | af13ceeba52a |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3191
diff
changeset
|
9 package org.dive4elements.river.collections; |
346
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
1779
2fe270661b20
Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
11 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
|
12 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
|
13 |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 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
|
15 |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 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
|
17 |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 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
|
19 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
|
20 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
|
21 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
|
22 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3191
diff
changeset
|
23 import org.dive4elements.artifacts.ArtifactNamespaceContext; |
346
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3191
diff
changeset
|
25 import org.dive4elements.artifactdatabase.state.DefaultOutput; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3191
diff
changeset
|
26 import org.dive4elements.artifactdatabase.state.Facet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3191
diff
changeset
|
27 import org.dive4elements.artifactdatabase.state.Output; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3191
diff
changeset
|
28 import org.dive4elements.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
|
29 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3191
diff
changeset
|
30 import org.dive4elements.artifacts.common.utils.XMLUtils; |
346
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3191
diff
changeset
|
32 import org.dive4elements.river.artifacts.model.ManagedDomFacet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3191
diff
changeset
|
33 import org.dive4elements.river.exports.ChartSettings; |
346
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
1779
2fe270661b20
Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
35 /** |
2fe270661b20
Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
36 * 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
|
37 * document. |
2fe270661b20
Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
38 */ |
346
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 public class AttributeParser { |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
1624
238145ef67da
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
945
diff
changeset
|
41 /** 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
|
42 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
|
43 "/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
|
44 |
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
|
45 |
346
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 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
|
47 |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 |
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
|
49 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
|
50 |
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 protected CollectionAttribute attribute; |
1779
2fe270661b20
Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
52 |
346
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 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
|
55 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
|
56 } |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
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
|
59 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
|
60 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
|
61 |
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
|
62 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
|
63 |
346
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 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
|
65 attributeDocument, |
346
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 XPATH_ARTIFACT_OUTPUTMODES, |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 XPathConstants.NODESET, |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 ArtifactNamespaceContext.INSTANCE); |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 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
|
71 |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 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
|
73 |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 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
|
75 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
|
76 |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 parseOutput(out); |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 } |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 } |
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 |
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
|
82 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
|
83 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
|
84 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
|
85 } |
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
|
86 |
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
|
87 return attribute; |
346
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 } |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 |
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
|
91 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
|
92 return attributeDocument; |
346
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 } |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 |
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
|
96 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
|
97 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
|
98 } |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 |
1779
2fe270661b20
Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
101 /** |
2fe270661b20
Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
102 * Access all facets. |
2fe270661b20
Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
103 * @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
|
104 */ |
2fe270661b20
Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
105 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
|
106 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
|
107 } |
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 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
|
111 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
|
112 |
2779
e57816cf41d5
Replaced another silly "@attribute" XPATH with direct getAttribute() call.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1994
diff
changeset
|
113 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
|
114 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
|
115 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
|
116 } |
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 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
|
119 |
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 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
|
121 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
|
122 |
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
|
123 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
|
124 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
|
125 } |
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
|
126 |
1994
3e703d134bbe
Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1976
diff
changeset
|
127 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
|
128 parseItems(out, name); |
1779
2fe270661b20
Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
129 } |
2fe270661b20
Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
130 |
3191
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
131 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
|
132 NodeList children = element.getChildNodes(); |
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
133 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
|
134 Node child = children.item(i); |
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
135 if (child.getNodeType() == Node.ELEMENT_NODE |
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
136 && child.getLocalName().equals(name)) { |
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
137 return child; |
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
138 } |
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
139 } |
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
140 return null; |
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
141 } |
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
142 |
1779
2fe270661b20
Let Output and Attribute Parsers collect Facets during processing.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
143 |
1994
3e703d134bbe
Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1976
diff
changeset
|
144 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
|
145 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
|
146 |
3e703d134bbe
Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1976
diff
changeset
|
147 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
|
148 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
|
149 return; |
3e703d134bbe
Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1976
diff
changeset
|
150 } |
3e703d134bbe
Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1976
diff
changeset
|
151 |
3e703d134bbe
Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1976
diff
changeset
|
152 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
|
153 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
|
154 } |
3e703d134bbe
Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1976
diff
changeset
|
155 |
3e703d134bbe
Parse the Settings of each Output during Collection's describe() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1976
diff
changeset
|
156 |
346
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 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
|
158 String uri = ArtifactNamespaceContext.NAMESPACE_URI; |
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
159 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
|
160 |
3191
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
161 NodeList themes = element.getElementsByTagNameNS(uri, "facet"); |
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
162 |
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
163 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
|
164 |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 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
|
166 |
694
68c6c75a6f7c
Add index and description of facets to collections describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
638
diff
changeset
|
167 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
|
168 Element theme = (Element) themes.item(i); |
3191
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
169 if (theme.getParentNode() == out) { |
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
170 attribute.addFacet(outname, new ManagedDomFacet(theme)); |
ef0db530c341
Removed some expensive XPath usage.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2779
diff
changeset
|
171 } |
346
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 } |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 } |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 } |
16161de47662
The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |