annotate flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java @ 1634:cc47828a1390

Added documentation. flys-artifacts/trunk@2813 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 23 Sep 2011 04:21:16 +0000
parents 16c74ca3586e
children 1b5204203e18
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
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.util.List;
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 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
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.w3c.dom.Document;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import org.w3c.dom.Element;
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.Node;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 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
13
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import de.intevation.artifactdatabase.state.Facet;
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.artifactdatabase.state.Output;
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.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
18 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import de.intevation.flys.artifacts.model.ManagedFacet;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
1634
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
22 /**
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
23 * Create attribute- element of describe document of an ArtifactCollection.
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
24 * The attribute-element contains the merged output of all outputmodes and
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
25 * facets that are part of the collection.
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
26 */
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 public class AttributeWriter {
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 protected Map<String, Output> oldAttr;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 protected Map<String, Output> newAttr;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 private static Logger logger = Logger.getLogger(AttributeWriter.class);
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
1634
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
35 /**
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
36 * Create a AttributeWriter.
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
37 * Attributes not present in newAttr will not be included in the document.
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
38 * @param oldAttr "Old" (possibly user-changed) outputs.
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
39 * @param newAttr "New" (eventually re-read in its original, unchagnged
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
40 * form) outputs.
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
41 */
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 public AttributeWriter(
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 Map<String, Output> oldAttr,
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 Map<String, Output> newAttr)
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 {
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 this.oldAttr = oldAttr;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 this.newAttr = newAttr;
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
1628
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
51 /**
1634
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
52 * Create document by merging outputs given in
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
53 * constructor.
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
54 * The "new" set rules about existance of attributes, so anything not
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
55 * present in it will not be included in the resulting document.
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
56 * The "old" set rules about the content of attributes (as user changes
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
57 * are recorded here and not in the new set).
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
58 * @return document with merged outputs as described.
1628
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
59 */
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 protected Document write() {
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 Document doc = XMLUtils.newDocument();
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 ElementCreator cr = new ElementCreator(
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 doc,
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 ArtifactNamespaceContext.NAMESPACE_URI,
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 ArtifactNamespaceContext.NAMESPACE_PREFIX);
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
638
9c565eb46f06 Fixed the process of creating and storing the attribute of a collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 353
diff changeset
68 Element attribute = cr.create("attribute");
705
853dceead0f4 Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 694
diff changeset
69 Element outs = cr.create("outputs");
638
9c565eb46f06 Fixed the process of creating and storing the attribute of a collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 353
diff changeset
70
9c565eb46f06 Fixed the process of creating and storing the attribute of a collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 353
diff changeset
71 attribute.appendChild(outs);
9c565eb46f06 Fixed the process of creating and storing the attribute of a collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 353
diff changeset
72 doc.appendChild(attribute);
353
8378683fa07a Bugfix: The outputs of a Collection's attribute document are stored in an outputs node now instead of being stored toplevel in the document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 346
diff changeset
73
705
853dceead0f4 Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 694
diff changeset
74 for (String outName: newAttr.keySet()) {
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 Output a = newAttr.get(outName);
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 Output b = oldAttr.get(outName);
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: 705
diff changeset
78
353
8378683fa07a Bugfix: The outputs of a Collection's attribute document are stored in an outputs node now instead of being stored toplevel in the document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 346
diff changeset
79 writeOutput(doc, outs, cr, a, b);
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 return doc;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84
1634
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
85
1628
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
86 /**
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
87 * @param doc Document to add output nodes to
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
88 * @param outs Node in Document to add output nodes to
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
89 * @param a the new output
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
90 * @param b the old output
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
91 */
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 protected void writeOutput(
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 Document doc,
353
8378683fa07a Bugfix: The outputs of a Collection's attribute document are stored in an outputs node now instead of being stored toplevel in the document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 346
diff changeset
94 Node outs,
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 ElementCreator cr,
1171
a3108f0a2fe7 Bugfix: merge facets for the Collection's attribute only if the new and old facet's name and owner artifact are equal.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 945
diff changeset
96 Output a, /* new output */
a3108f0a2fe7 Bugfix: merge facets for the Collection's attribute only if the new and old facet's name and owner artifact are equal.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 945
diff changeset
97 Output b) /* old output */
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 Element output = cr.create("output");
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 cr.addAttr(output, "name", a.getName());
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101
353
8378683fa07a Bugfix: The outputs of a Collection's attribute document are stored in an outputs node now instead of being stored toplevel in the document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 346
diff changeset
102 outs.appendChild(output);
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 List<Facet> facetsA = a.getFacets();
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 List<Facet> facetsB = null;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 if (b != null) {
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 facetsB = b.getFacets();
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 writeFacets(doc, cr, output, facetsA, facetsB);
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114
1628
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
115 /**
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
116 * @param doc Document to add facet nodes to
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
117 * @param output Node in Document to add facet nodes to
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
118 * @param a the new facets
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
119 * @param b the old facets
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
120 */
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 protected void writeFacets(
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 Document doc,
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 ElementCreator cr,
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 Element output,
1171
a3108f0a2fe7 Bugfix: merge facets for the Collection's attribute only if the new and old facet's name and owner artifact are equal.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 945
diff changeset
125 List<Facet> a, /* new facets */
a3108f0a2fe7 Bugfix: merge facets for the Collection's attribute only if the new and old facet's name and owner artifact are equal.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 945
diff changeset
126 List<Facet> b) /* old facets */
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 {
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128 int num = a.size();
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130 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
131 ManagedFacet fA = (ManagedFacet) a.get(i);
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133 if (!mergeFacets(doc, cr, output, fA, b)) {
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: 705
diff changeset
134 Node n = fA.toXML(doc);
59ae2a823e73 Use the Facet.toXML() method to write facet elements into the DESCRIBE document of the Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 705
diff changeset
135
59ae2a823e73 Use the Facet.toXML() method to write facet elements into the DESCRIBE document of the Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 705
diff changeset
136 if (n != null) {
59ae2a823e73 Use the Facet.toXML() method to write facet elements into the DESCRIBE document of the Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 705
diff changeset
137 output.appendChild(n);
59ae2a823e73 Use the Facet.toXML() method to write facet elements into the DESCRIBE document of the Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 705
diff changeset
138 }
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143
1628
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
144 /**
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
145 * @param a new facets
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
146 * @param list old facets
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
147 */
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 protected boolean mergeFacets(
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 Document doc,
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 ElementCreator cr,
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 Element output,
1171
a3108f0a2fe7 Bugfix: merge facets for the Collection's attribute only if the new and old facet's name and owner artifact are equal.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 945
diff changeset
152 ManagedFacet a, /* new facets */
a3108f0a2fe7 Bugfix: merge facets for the Collection's attribute only if the new and old facet's name and owner artifact are equal.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 945
diff changeset
153 List<Facet> list) /* old facets */
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 {
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: 705
diff changeset
155 String nameA = a.getName() + a.getIndex();
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 if (list == null) {
638
9c565eb46f06 Fixed the process of creating and storing the attribute of a collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 353
diff changeset
158 logger.debug("No old facets found.");
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159 return false;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162 for (Facet facet: list) {
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: 705
diff changeset
163 String nameB = facet.getName() + facet.getIndex();
59ae2a823e73 Use the Facet.toXML() method to write facet elements into the DESCRIBE document of the Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 705
diff changeset
164
59ae2a823e73 Use the Facet.toXML() method to write facet elements into the DESCRIBE document of the Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 705
diff changeset
165 if (nameA.equals(nameB)) {
1171
a3108f0a2fe7 Bugfix: merge facets for the Collection's attribute only if the new and old facet's name and owner artifact are equal.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 945
diff changeset
166 ManagedFacet b = (ManagedFacet) facet;
a3108f0a2fe7 Bugfix: merge facets for the Collection's attribute only if the new and old facet's name and owner artifact are equal.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 945
diff changeset
167
a3108f0a2fe7 Bugfix: merge facets for the Collection's attribute only if the new and old facet's name and owner artifact are equal.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 945
diff changeset
168 if (!b.getArtifact().equals(a.getArtifact())) {
a3108f0a2fe7 Bugfix: merge facets for the Collection's attribute only if the new and old facet's name and owner artifact are equal.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 945
diff changeset
169 continue;
a3108f0a2fe7 Bugfix: merge facets for the Collection's attribute only if the new and old facet's name and owner artifact are equal.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 945
diff changeset
170 }
a3108f0a2fe7 Bugfix: merge facets for the Collection's attribute only if the new and old facet's name and owner artifact are equal.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 945
diff changeset
171
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: 705
diff changeset
172 Node n = facet.toXML(doc);
59ae2a823e73 Use the Facet.toXML() method to write facet elements into the DESCRIBE document of the Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 705
diff changeset
173
59ae2a823e73 Use the Facet.toXML() method to write facet elements into the DESCRIBE document of the Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 705
diff changeset
174 if (n != null) {
59ae2a823e73 Use the Facet.toXML() method to write facet elements into the DESCRIBE document of the Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 705
diff changeset
175 output.appendChild(n);
59ae2a823e73 Use the Facet.toXML() method to write facet elements into the DESCRIBE document of the Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 705
diff changeset
176 }
59ae2a823e73 Use the Facet.toXML() method to write facet elements into the DESCRIBE document of the Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 705
diff changeset
177
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 return true;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
180 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 return false;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184 }
705
853dceead0f4 Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 694
diff changeset
185 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org