Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/exports/OutputHelper.java @ 5698:74ebef99772d
Switch back to example url and correct background wms url
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 15 Apr 2013 11:06:31 +0200 |
parents | 5b8919ef601d |
children |
rev | line source |
---|---|
3295
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.exports; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 import java.io.IOException; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 import java.util.ArrayList; |
4255
670e98f5a441
Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents:
4049
diff
changeset
|
5 import java.util.Collections; |
3295
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 import java.util.HashMap; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 import java.util.List; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 import java.util.Map; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import javax.xml.xpath.XPathConstants; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 import org.apache.log4j.Logger; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 import org.w3c.dom.Document; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 import org.w3c.dom.Element; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 import org.w3c.dom.Node; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 import org.w3c.dom.NodeList; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.artifactdatabase.Backend; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.artifactdatabase.Backend.PersistentArtifact; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.artifactdatabase.state.ArtifactAndFacet; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.artifacts.Artifact; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 import de.intevation.artifacts.ArtifactDatabase; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.artifacts.ArtifactDatabaseException; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 import de.intevation.artifacts.CallContext; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 import de.intevation.artifacts.CallMeta; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 import de.intevation.artifacts.common.utils.ClientProtocolUtils; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 import de.intevation.artifacts.common.utils.XMLUtils; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 import de.intevation.flys.artifacts.FLYSArtifact; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 import de.intevation.flys.artifacts.context.FLYSContext; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 import de.intevation.flys.artifacts.model.ManagedDomFacet; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 import de.intevation.flys.artifacts.model.ManagedFacet; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 import de.intevation.flys.themes.Theme; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 import de.intevation.flys.themes.ThemeFactory; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 public class OutputHelper { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 /** The logger used in this class. */ |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 private static Logger log = Logger.getLogger(OutputHelper.class); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 protected String identifier; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 public OutputHelper(String identifier) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 this.identifier = identifier; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 /** |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 * Creates a concrete output. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 * |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 * @param generator The OutGenerator that creates the output. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 * @param outputName The name of the requested output. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 * @param attributes The collection's attributes for this concrete output |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 * type. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 * @param context The context object. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 */ |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 public void doOut( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 OutGenerator generator, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 String outName, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 String facet, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 Document attributes, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 CallContext context) |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 throws IOException |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 boolean debug = log.isDebugEnabled(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 if (debug) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 log.debug("FLYSArtifactCollection.doOut: " + outName); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 ThemeList themeList = new ThemeList(attributes); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 int size = themeList.size(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 if (debug) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 log.debug("Output will contain " + size + " elements."); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 List<ArtifactAndFacet> dataProviders = |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 doBlackboardPass(themeList, context); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 try { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 for (int i = 0; i < size; i++) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 ManagedFacet theme = themeList.get(i); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 if (theme == null) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 log.debug("Theme is empty - no output is generated."); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 continue; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 String art = theme.getArtifact(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 String facetName = theme.getName(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 if (debug) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 log.debug("Do output for..."); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 log.debug("... artifact: " + art); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 log.debug("... facet: " + facetName); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
94 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 if (outName.equals("export") && !facetName.equals(facet)) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 continue; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
100 // Skip invisible themes. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 if (theme.getVisible() == 0) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 continue; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 if (outName.equals("sq_overview")) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 generator.doOut( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 dataProviders.get(i), |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 attributes, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
109 theme.getActive() == 1); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 else { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 generator.doOut( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 dataProviders.get(i), |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 getFacetThemeFromAttribute( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 art, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 outName, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
117 facetName, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 theme.getDescription(), |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
119 theme.getIndex(), |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 context), |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
121 theme.getActive() == 1); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
122 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
123 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
124 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 catch (ArtifactDatabaseException ade) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 log.error(ade, ade); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
127 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 /** |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
130 * Returns the attribute that belongs to an artifact and facet stored in |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
131 * this collection. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
132 * |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 * @param uuid The Artifact's uuid. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
134 * @param outname The name of the requested output. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
135 * @param facet The name of the requested facet. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
136 * @param context The CallContext. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
137 * |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
138 * @return an attribute in form of a document. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
139 */ |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
140 protected Document getFacetThemeFromAttribute( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
141 String uuid, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
142 String outName, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
143 String facet, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
144 String pattern, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
145 int index, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
146 CallContext context) |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
147 throws ArtifactDatabaseException |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
148 { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
149 boolean debug = log.isDebugEnabled(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
150 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
151 if (debug) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
152 log.debug( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
153 "FLYSArtifactCollection.getFacetThemeFromAttribute(facet=" |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
154 + facet + ", index=" + index + ")"); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
155 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
156 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
157 ArtifactDatabase db = context.getDatabase(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
158 CallMeta meta = context.getMeta(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
159 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
160 Document attr = db.getCollectionItemAttribute(identifier, uuid, meta); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
161 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
162 if (attr == null) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
163 attr = initItemAttribute(uuid, facet, pattern, index, outName, context); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
164 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
165 if (attr == null) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
166 return null; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
167 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
168 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
169 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
170 if (debug) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
171 log.debug("Search attribute of collection item: " + uuid); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
172 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
173 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
174 Node tmp = (Node) XMLUtils.xpath( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
175 attr, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
176 "/art:attribute", |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
177 XPathConstants.NODE, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
178 ArtifactNamespaceContext.INSTANCE); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
179 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
180 if (tmp == null) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
181 log.warn("No attribute found. Operation failed."); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
182 return null; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
183 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
184 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
185 if (debug) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
186 log.debug("Search theme for facet '" + facet + "' in attribute."); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
187 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
188 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
189 Map<String, String> vars = new HashMap<String, String>(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
190 vars.put("facet", facet); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
191 vars.put("index", String.valueOf(index)); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
192 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
193 Node theme = (Node) XMLUtils.xpath( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
194 tmp, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
195 "art:themes/theme[@facet=$facet and @index=$index]", |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
196 XPathConstants.NODE, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
197 ArtifactNamespaceContext.INSTANCE, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
198 vars); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
199 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
200 if (theme == null) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
201 log.warn("Could not find the theme in attribute of: " + facet + " " + uuid); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
202 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
203 Theme t = getThemeForFacet( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
204 uuid, facet, pattern, index, outName, context); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
205 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
206 if (t == null) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
207 log.warn("No theme found for facet: " + facet); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
208 return null; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
209 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
210 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
211 addThemeToAttribute(uuid, attr, t, context); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
212 theme = t.toXML().getFirstChild(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
213 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
214 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
215 Document doc = XMLUtils.newDocument(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
216 doc.appendChild(doc.importNode(theme, true)); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
217 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
218 return doc; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
219 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
220 /** |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
221 * Adds the theme of a facet to a CollectionItem's attribute. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
222 * |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
223 * @param uuid The uuid of the artifact. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
224 * @param attr The current attribute of an artifact. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
225 * @param t The theme to add. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
226 * @param context The CallContext. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
227 */ |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
228 protected void addThemeToAttribute( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
229 String uuid, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
230 Document attr, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
231 Theme t, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
232 CallContext context) |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
233 { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
234 log.debug("FLYSArtifactCollection.addThemeToAttribute: " + uuid); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
235 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
236 if (t == null) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
237 log.warn("Theme is empty - cancel adding it to attribute!"); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
238 return; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
239 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
240 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
241 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
242 attr, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
243 ArtifactNamespaceContext.NAMESPACE_URI, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
244 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
245 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
246 Node tmp = (Node) XMLUtils.xpath( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
247 attr, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
248 "/art:attribute", |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
249 XPathConstants.NODE, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
250 ArtifactNamespaceContext.INSTANCE); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
251 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
252 if (tmp == null) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
253 tmp = ec.create("attribute"); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
254 attr.appendChild(tmp); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
255 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
256 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
257 Node themes = (Node) XMLUtils.xpath( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
258 tmp, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
259 "art:themes", |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
260 XPathConstants.NODE, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
261 ArtifactNamespaceContext.INSTANCE); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
262 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
263 if (themes == null) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
264 themes = ec.create("themes"); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
265 tmp.appendChild(themes); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
266 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
267 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
268 themes.appendChild(attr.importNode(t.toXML().getFirstChild(), true)); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
269 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
270 try { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
271 setCollectionItemAttribute(uuid, attr, context); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
272 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
273 catch (ArtifactDatabaseException e) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
274 // do nothing |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
275 log.warn("Cannot set attribute of item: " + uuid); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
276 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
277 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
278 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
279 /** |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
280 * Sets the attribute of a CollectionItem specified by <i>uuid</i> to a new |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
281 * value <i>attr</i>. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
282 * |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
283 * @param uuid The uuid of the CollectionItem. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
284 * @param attr The new attribute for the CollectionItem. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
285 * @param context The CallContext. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
286 */ |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
287 public void setCollectionItemAttribute( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
288 String uuid, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
289 Document attr, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
290 CallContext context) |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
291 throws ArtifactDatabaseException |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
292 { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
293 Document doc = ClientProtocolUtils.newSetItemAttributeDocument( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
294 uuid, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
295 attr); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
296 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
297 if (doc == null) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
298 log.warn("Cannot set item attribute: No attribute found."); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
299 return; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
300 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
301 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
302 ArtifactDatabase db = context.getDatabase(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
303 CallMeta meta = context.getMeta(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
304 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
305 db.setCollectionItemAttribute(identifier, uuid, doc, meta); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
306 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
307 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
308 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
309 /** |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
310 * Show blackboard (context) to each facet and create a list of |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
311 * ArtifactAndFacets on the fly (with the same ordering as the passed |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
312 * ThemeList). |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
313 * @param themeList ThemeList to create a ArtifactAndFacetList along. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
314 * @param context The "Blackboard". |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
315 */ |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
316 protected List<ArtifactAndFacet> doBlackboardPass( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
317 ThemeList themeList, CallContext context |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
318 ) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
319 ArrayList<ArtifactAndFacet> dataProviders = |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
320 new ArrayList<ArtifactAndFacet>(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
321 int size = themeList.size(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
322 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
323 try { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
324 // Collect all ArtifactAndFacets for blackboard pass. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
325 for (int i = 0; i < size; i++) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
326 ManagedFacet theme = themeList.get(i); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
327 if (theme == null) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
328 log.warn("A ManagedFacet in ThemeList is null."); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
329 continue; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
330 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
331 String uuid = theme.getArtifact(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
332 Artifact artifact = getArtifact(uuid, context); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
333 FLYSArtifact flys = (FLYSArtifact) artifact; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
334 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
335 ArtifactAndFacet artifactAndFacet = new ArtifactAndFacet( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
336 artifact, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
337 flys.getNativeFacet(theme)); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
338 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
339 // XXX HELP ME PLEASE |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
340 artifactAndFacet.setFacetDescription(theme.getDescription()); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
341 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
342 // Show blackboard to facet. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
343 artifactAndFacet.register(context); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
344 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
345 // Add to themes. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
346 dataProviders.add(i, artifactAndFacet); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
347 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
348 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
349 catch (ArtifactDatabaseException ade) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
350 log.error("ArtifactDatabaseException!", ade); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
351 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
352 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
353 return dataProviders; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
354 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
355 /** |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
356 * Returns a concrete Artifact of this collection specified by its uuid. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
357 * |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
358 * @param uuid The Artifact's uuid. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
359 * @param context The CallContext. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
360 * |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
361 * @return an Artifact. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
362 */ |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
363 protected Artifact getArtifact(String uuid, CallContext context) |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
364 throws ArtifactDatabaseException |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
365 { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
366 log.debug("FLYSArtifactCollection.getArtifact"); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
367 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
368 Backend backend = Backend.getInstance(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
369 PersistentArtifact persistent = backend.getArtifact(uuid); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
370 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
371 return persistent != null ? persistent.getArtifact() : null; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
372 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
373 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
374 /** |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
375 * Initializes the attribute of an collection item with the theme of a |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
376 * specific facet. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
377 * |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
378 * @param uuid The uuid of an artifact. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
379 * @param facet The name of a facet. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
380 * @param context The CallContext. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
381 * |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
382 * @param the new attribute. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
383 */ |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
384 protected Document initItemAttribute( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
385 String uuid, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
386 String facet, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
387 String pattern, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
388 int index, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
389 String outName, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
390 CallContext context) |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
391 { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
392 boolean debug = log.isDebugEnabled(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
393 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
394 if (debug) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
395 log.debug("FLYSArtifactCollection.initItemAttribute"); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
396 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
397 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
398 Theme t = getThemeForFacet(uuid, facet, pattern, index, outName, context); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
399 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
400 if (t == null) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
401 log.info("Could not find theme for facet. Cancel initialization."); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
402 return null; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
403 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
404 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
405 Document attr = XMLUtils.newDocument(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
406 addThemeToAttribute(uuid, attr, t, context); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
407 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
408 if (debug) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
409 log.debug("initItemAttribute for facet " + facet + ": " |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
410 + XMLUtils.toString(attr)); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
411 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
412 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
413 return attr; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
414 } |
3299
d76a889bc30d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3295
diff
changeset
|
415 |
3295
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
416 /** |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
417 * Returns the theme of a specific facet. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
418 * |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
419 * @param uuid The uuid of an artifact. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
420 * @param facet The name of the facet. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
421 * @param context The CallContext object. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
422 * |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
423 * @return the desired theme. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
424 */ |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
425 protected Theme getThemeForFacet( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
426 String uuid, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
427 String facet, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
428 String pattern, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
429 int index, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
430 String outName, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
431 CallContext context) |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
432 { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
433 log.info("FLYSArtifactCollection.getThemeForFacet: " + facet); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
434 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
435 FLYSContext flysContext = context instanceof FLYSContext |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
436 ? (FLYSContext) context |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
437 : (FLYSContext) context.globalContext(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
438 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
439 // Push artifact in flysContext. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
440 ArtifactDatabase db = context.getDatabase(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
441 try { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
442 FLYSArtifact artifact = (FLYSArtifact) db.getRawArtifact(uuid); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
443 log.debug("Got raw artifact"); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
444 flysContext.put(FLYSContext.ARTIFACT_KEY, artifact); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
445 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
446 catch (ArtifactDatabaseException dbe) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
447 log.error("Exception caught when trying to get art.", dbe); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
448 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
449 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
450 Theme t = ThemeFactory.getTheme( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
451 flysContext, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
452 facet, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
453 pattern, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
454 outName, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
455 "default"); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
456 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
457 if (t != null) { |
3781
8e713e9bb4d7
Defined colors for bed quality themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3304
diff
changeset
|
458 log.debug("found theme for facet '" + facet + "'"); |
3295
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
459 t.setFacet(facet); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
460 t.setIndex(index); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
461 } |
3781
8e713e9bb4d7
Defined colors for bed quality themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3304
diff
changeset
|
462 else { |
8e713e9bb4d7
Defined colors for bed quality themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3304
diff
changeset
|
463 log.warn("unable to find theme for facet '" + facet + "'"); |
8e713e9bb4d7
Defined colors for bed quality themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3304
diff
changeset
|
464 } |
3295
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
465 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
466 return t; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
467 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
468 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
469 /** |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
470 * Inner class to structure/order the themes of a chart. |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
471 */ |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
472 private static class ThemeList { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
473 private Logger logger = Logger.getLogger(ThemeList.class); |
4255
670e98f5a441
Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents:
4049
diff
changeset
|
474 protected List<ManagedFacet> themes; |
3295
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
475 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
476 public ThemeList(Document output) { |
4255
670e98f5a441
Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents:
4049
diff
changeset
|
477 themes = new ArrayList<ManagedFacet>(); |
3295
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
478 parse(output); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
479 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
480 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
481 protected void parse(Document output) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
482 NodeList themeList = (NodeList) XMLUtils.xpath( |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
483 output, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
484 "art:output/art:facet", |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
485 XPathConstants.NODESET, |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
486 ArtifactNamespaceContext.INSTANCE); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
487 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
488 int num = themeList != null ? themeList.getLength() : 0; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
489 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
490 logger.debug("Output has " + num + " elements."); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
491 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
492 if (num == 0) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
493 return; |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
494 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
495 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
496 for (int i = 0; i < num; i++) { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
497 Element theme = (Element) themeList.item(i); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
498 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
499 ManagedDomFacet facet = new ManagedDomFacet(theme); |
4255
670e98f5a441
Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents:
4049
diff
changeset
|
500 themes.add(facet); |
3295
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
501 } |
4255
670e98f5a441
Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents:
4049
diff
changeset
|
502 |
670e98f5a441
Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents:
4049
diff
changeset
|
503 Collections.sort(themes); |
3295
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
504 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
505 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
506 public ManagedFacet get(int idx) { |
4255
670e98f5a441
Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents:
4049
diff
changeset
|
507 return themes.get(idx); |
3295
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
508 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
509 |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
510 public int size() { |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
511 return themes.size(); |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
512 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
513 } |
4fc442f1b4f6
Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
514 } |
3304
02d5731b43a2
SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3299
diff
changeset
|
515 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |