annotate artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java @ 9801:1d7a72a50183 3.2.x tip

Assume Compose V2, consistently
author Tom Gottfried <tom@intevation.de>
date Thu, 23 Nov 2023 10:14:13 +0100
parents 0a5239a1e46e
children
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
9 package org.dive4elements.river.exports;
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 import java.io.IOException;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 import java.util.ArrayList;
4255
670e98f5a441 Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents: 4049
diff changeset
13 import java.util.Collections;
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 import java.util.HashMap;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 import java.util.List;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 import java.util.Map;
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 javax.xml.xpath.XPathConstants;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
20 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
21 import org.apache.logging.log4j.LogManager;
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 import org.w3c.dom.Document;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 import org.w3c.dom.Element;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 import org.w3c.dom.Node;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 import org.w3c.dom.NodeList;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26
8221
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
27 import org.dive4elements.artifacts.ContextInjector;
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
28
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
29 import org.dive4elements.artifactdatabase.Backend;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
30 import org.dive4elements.artifactdatabase.Backend.PersistentArtifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
31 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
32 import org.dive4elements.artifactdatabase.state.Facet;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
33 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
34 import org.dive4elements.artifacts.ArtifactDatabase;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
35 import org.dive4elements.artifacts.ArtifactDatabaseException;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
36 import org.dive4elements.artifacts.CallContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
37 import org.dive4elements.artifacts.CallMeta;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
38 import org.dive4elements.artifacts.common.ArtifactNamespaceContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
39 import org.dive4elements.artifacts.common.utils.ClientProtocolUtils;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
40 import org.dive4elements.artifacts.common.utils.XMLUtils;
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
41 import org.dive4elements.river.artifacts.D4EArtifact;
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
42 import org.dive4elements.river.artifacts.context.RiverContext;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
43 import org.dive4elements.river.artifacts.model.ManagedDomFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
44 import org.dive4elements.river.artifacts.model.ManagedFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
45 import org.dive4elements.river.themes.Theme;
6905
1b35b2ddfc28 Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6564
diff changeset
46 import org.dive4elements.river.themes.ThemeDocument;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
47 import org.dive4elements.river.themes.ThemeFactory;
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 public class OutputHelper {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7254
diff changeset
50 /** The log used in this class. */
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
51 private static Logger log = LogManager.getLogger(OutputHelper.class);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 protected String identifier;
8392
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
54 private D4EArtifact masterArtifact;
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55
8392
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
56 public OutputHelper(String identifier, D4EArtifact masterArtifact) {
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 this.identifier = identifier;
8392
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
58 this.masterArtifact = masterArtifact;
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 }
8221
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
60
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
61 private static List<ContextInjector> getContextInjectors(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
62 CallContext context,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
63 String out
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
64 ) {
8221
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
65 RiverContext flysContext = context instanceof RiverContext
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
66 ? (RiverContext)context
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
67 : (RiverContext)context.globalContext();
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
68
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
69 GeneratorLookup generators =
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
70 (GeneratorLookup)flysContext.get(RiverContext.OUTGENERATORS_KEY);
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
71
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
72 if (generators == null) {
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
73 return null;
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
74 }
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
75
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
76 GeneratorLookup.Item item = generators.getGenerator(out);
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
77 return item != null
8254
c87c87544cc6 Made call context injectors a list of comma separated classes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8225
diff changeset
78 ? item.getContextInjectors()
8221
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
79 : null;
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
80 }
3295
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 * Creates a concrete output.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 *
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 * @param generator The OutGenerator that creates the output.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 * @param outputName The name of the requested output.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 * @param attributes The collection's attributes for this concrete output
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 * type.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 * @param context The context object.
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 public void doOut(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 OutGenerator generator,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 String outName,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93 String facet,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 Document attributes,
8225
724081af301c Pass request document to the context injectors.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8223
diff changeset
95 CallContext context,
724081af301c Pass request document to the context injectors.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8223
diff changeset
96 Document request
724081af301c Pass request document to the context injectors.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8223
diff changeset
97 ) throws IOException {
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 boolean debug = log.isDebugEnabled();
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 if (debug) {
6564
42856353a222 OutputHelper: Fix misleading debug output copy/pasted from D4EArtifactCollection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6140
diff changeset
101 log.debug("OutputHelper.doOut: " + outName);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 }
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 ThemeList themeList = new ThemeList(attributes);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105
6905
1b35b2ddfc28 Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6564
diff changeset
106 ThemeDocument themeDoc = new ThemeDocument(attributes);
1b35b2ddfc28 Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6564
diff changeset
107
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 List<ArtifactAndFacet> dataProviders =
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
109 doBlackboardPass(themeList, context, outName);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110
8254
c87c87544cc6 Made call context injectors a list of comma separated classes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8225
diff changeset
111 List<ContextInjector> cis = getContextInjectors(context, outName);
8221
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
112
8392
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
113 if (cis != null) {
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
114 for (ContextInjector ci: cis) {
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
115 ci.injectContext(context, masterArtifact, request);
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
116 }
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
117 }
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
118
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 try {
7254
fe32a7f9655e Reduce usage of careless 'for (int i = 0; i < x.size(); i++)' pattern.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6905
diff changeset
120 for (int i = 0, T = themeList.size(); i < T; i++) {
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 ManagedFacet theme = themeList.get(i);
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 if (theme == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
124 log.debug("Theme is empty - no output is generated.");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 continue;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
126 }
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 String art = theme.getArtifact();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 String facetName = theme.getName();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 if (debug) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 log.debug("Do output for...");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133 log.debug("... artifact: " + art);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
134 log.debug("... facet: " + facetName);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
135 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137 if (outName.equals("export") && !facetName.equals(facet)) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 continue;
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
141 // Skip invisible themes.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
142 if (theme.getVisible() == 0) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
143 continue;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
144 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
145
8264
4d99606a844e SQ relation overview is now a single chart containing all fractions.
Raimund Renkert <rrenkert@intevation.de>
parents: 8254
diff changeset
146 generator.doOut(
8392
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
147 dataProviders.get(i),
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
148 getFacetThemeFromAttribute(
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
149 art,
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
150 outName,
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
151 facetName,
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
152 theme.getDescription(),
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
153 theme.getIndex(),
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
154 context),
994995baa32b Only the master-artifact should decide about injected CURRENT_KM et al. (and removed dependend obsolete class).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8264
diff changeset
155 theme.getActive() == 1);
3295
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 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
158 catch (ArtifactDatabaseException ade) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
159 log.error(ade, ade);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
160 }
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 /**
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
163 * Returns the attribute that belongs to an artifact and facet stored in
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
164 * this collection.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
165 *
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
166 * @param uuid The Artifact's uuid.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
167 * @param outname The name of the requested output.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
168 * @param facet The name of the requested facet.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
169 * @param context The CallContext.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
170 *
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
171 * @return an attribute in form of a document.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
172 */
6905
1b35b2ddfc28 Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6564
diff changeset
173 protected ThemeDocument getFacetThemeFromAttribute(
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
174 String uuid,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
175 String outName,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
176 String facet,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
177 String pattern,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
178 int index,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
179 CallContext context)
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
180 throws ArtifactDatabaseException
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
181 {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
182 boolean debug = log.isDebugEnabled();
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 if (debug) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
185 log.debug(
6564
42856353a222 OutputHelper: Fix misleading debug output copy/pasted from D4EArtifactCollection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6140
diff changeset
186 "OutputHelper.getFacetThemeFromAttribute(facet="
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
187 + facet + ", index=" + index + ")");
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
190 ArtifactDatabase db = context.getDatabase();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
191 CallMeta meta = context.getMeta();
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 Document attr = db.getCollectionItemAttribute(identifier, uuid, meta);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
194
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
195 if (attr == null) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
196 attr = initItemAttribute(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
197 uuid, facet, pattern, index, outName, context);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
198
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
199 if (attr == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
200 return null;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
201 }
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
204 if (debug) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
205 log.debug("Search attribute of collection item: " + uuid);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
206 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
207
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
208 Node tmp = (Node) XMLUtils.xpath(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
209 attr,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
210 "/art:attribute",
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
211 XPathConstants.NODE,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
212 ArtifactNamespaceContext.INSTANCE);
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 if (tmp == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
215 log.warn("No attribute found. Operation failed.");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
216 return null;
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
219 if (debug) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
220 log.debug("Search theme for facet '" + facet + "' in attribute.");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
221 }
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 Map<String, String> vars = new HashMap<String, String>();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
224 vars.put("facet", facet);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
225 vars.put("index", String.valueOf(index));
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
226
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
227 Node theme = (Node) XMLUtils.xpath(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
228 tmp,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
229 "art:themes/theme[@facet=$facet and @index=$index]",
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
230 XPathConstants.NODE,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
231 ArtifactNamespaceContext.INSTANCE,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
232 vars);
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 if (theme == null) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
235 log.warn("Could not find the theme in attribute of: "
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
236 + facet + " " + uuid);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
237
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
238 Theme t = getThemeForFacet(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
239 uuid, facet, pattern, index, outName, context);
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 if (t == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
242 log.warn("No theme found for facet: " + facet);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
243 return null;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
244 }
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 addThemeToAttribute(uuid, attr, t, context);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
247 theme = t.toXML().getFirstChild();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
248 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
249
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
250 Document doc = XMLUtils.newDocument();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
251 doc.appendChild(doc.importNode(theme, true));
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
252
6905
1b35b2ddfc28 Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6564
diff changeset
253 return new ThemeDocument(doc);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
254 }
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 * Adds the theme of a facet to a CollectionItem's attribute.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
257 *
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
258 * @param uuid The uuid of the artifact.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
259 * @param attr The current attribute of an artifact.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
260 * @param t The theme to add.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
261 * @param context The CallContext.
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 protected void addThemeToAttribute(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
264 String uuid,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
265 Document attr,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
266 Theme t,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
267 CallContext context)
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
268 {
6564
42856353a222 OutputHelper: Fix misleading debug output copy/pasted from D4EArtifactCollection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6140
diff changeset
269 log.debug("OutputHelper.addThemeToAttribute: " + uuid);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
270
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
271 if (t == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
272 log.warn("Theme is empty - cancel adding it to attribute!");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
273 return;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
274 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
275
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
276 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
277 attr,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
278 ArtifactNamespaceContext.NAMESPACE_URI,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
279 ArtifactNamespaceContext.NAMESPACE_PREFIX);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
280
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
281 Node tmp = (Node) XMLUtils.xpath(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
282 attr,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
283 "/art:attribute",
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
284 XPathConstants.NODE,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
285 ArtifactNamespaceContext.INSTANCE);
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 if (tmp == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
288 tmp = ec.create("attribute");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
289 attr.appendChild(tmp);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
290 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
291
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
292 Node themes = (Node) XMLUtils.xpath(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
293 tmp,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
294 "art:themes",
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
295 XPathConstants.NODE,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
296 ArtifactNamespaceContext.INSTANCE);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
297
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
298 if (themes == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
299 themes = ec.create("themes");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
300 tmp.appendChild(themes);
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
303 themes.appendChild(attr.importNode(t.toXML().getFirstChild(), true));
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 try {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
306 setCollectionItemAttribute(uuid, attr, context);
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 catch (ArtifactDatabaseException e) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
309 // do nothing
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
310 log.warn("Cannot set attribute of item: " + uuid);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
311 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
312 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
313
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
314 /**
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
315 * 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
316 * value <i>attr</i>.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
317 *
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
318 * @param uuid The uuid of the CollectionItem.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
319 * @param attr The new attribute for the CollectionItem.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
320 * @param context The CallContext.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
321 */
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
322 public void setCollectionItemAttribute(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
323 String uuid,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
324 Document attr,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
325 CallContext context)
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
326 throws ArtifactDatabaseException
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
327 {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
328 Document doc = ClientProtocolUtils.newSetItemAttributeDocument(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
329 uuid,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
330 attr);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
331
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
332 if (doc == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
333 log.warn("Cannot set item attribute: No attribute found.");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
334 return;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
335 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
336
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
337 ArtifactDatabase db = context.getDatabase();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
338 CallMeta meta = context.getMeta();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
339
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
340 db.setCollectionItemAttribute(identifier, uuid, doc, meta);
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
343
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 * Show blackboard (context) to each facet and create a list of
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
346 * ArtifactAndFacets on the fly (with the same ordering as the passed
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
347 * ThemeList).
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
348 * @param themeList ThemeList to create a ArtifactAndFacetList along.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
349 * @param context The "Blackboard".
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
350 */
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
351 protected List<ArtifactAndFacet> doBlackboardPass(
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
352 ThemeList themeList, CallContext context, String outname
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
353 ) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
354 ArrayList<ArtifactAndFacet> dataProviders =
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
355 new ArrayList<ArtifactAndFacet>();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
356
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
357 try {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
358 // Collect all ArtifactAndFacets for blackboard pass.
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
359 for (int i = 0; i < themeList.size(); i++) {
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
360 log.debug("BLackboard pass for: " + outname);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
361 ManagedFacet theme = themeList.get(i);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
362 if (theme == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
363 log.warn("A ManagedFacet in ThemeList is null.");
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
364 themeList.remove(i);
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
365 i--;
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
366 continue;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
367 }
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
368
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
369 String uuid = theme.getArtifact();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
370 Artifact artifact = getArtifact(uuid, context);
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
371 D4EArtifact flys = (D4EArtifact) artifact;
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
372 Facet face = flys.getNativeFacet(theme, outname);
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
373 log.debug("Looking for Native Facet for theme: "
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
374 + theme + " and out: "
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
375 + outname + " in artifact: " + uuid
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
376 + face == null ? " Found. " : " Not Found. ");
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
377 if (face == null) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
378 log.warn("Theme " + theme.getName()
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
379 + " for " + outname
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
380 + " has no facets!. Removing theme.");
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
381 themeList.remove(i);
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
382 i--;
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
383 continue;
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
384 }
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
385
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
386 ArtifactAndFacet artifactAndFacet = new ArtifactAndFacet(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
387 artifact,
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
388 face);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
389
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
390 // XXX HELP ME PLEASE
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
391 artifactAndFacet.setFacetDescription(theme.getDescription());
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
392
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
393 // Show blackboard to facet.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
394 artifactAndFacet.register(context);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
395
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
396 // Add to themes.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
397 dataProviders.add(i, artifactAndFacet);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
398 }
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 catch (ArtifactDatabaseException ade) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
401 log.error("ArtifactDatabaseException!", ade);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
402 }
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 return dataProviders;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
405 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
406 /**
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
407 * Returns a concrete Artifact of this collection specified by its uuid.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
408 *
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
409 * @param uuid The Artifact's uuid.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
410 * @param context The CallContext.
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 * @return an Artifact.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
413 */
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
414 protected Artifact getArtifact(String uuid, CallContext context)
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
415 throws ArtifactDatabaseException
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
416 {
6564
42856353a222 OutputHelper: Fix misleading debug output copy/pasted from D4EArtifactCollection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6140
diff changeset
417 log.debug("OutputHelper.getArtifact");
3295
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 Backend backend = Backend.getInstance();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
420 PersistentArtifact persistent = backend.getArtifact(uuid);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
421
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
422 return persistent != null ? persistent.getArtifact() : null;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
423 }
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 /**
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
426 * Initializes the attribute of an collection item with the theme of a
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
427 * specific facet.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
428 *
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
429 * @param uuid The uuid of an artifact.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
430 * @param facet The name of a facet.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
431 * @param context The CallContext.
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 * @param the new attribute.
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 protected Document initItemAttribute(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
436 String uuid,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
437 String facet,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
438 String pattern,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
439 int index,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
440 String outName,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
441 CallContext context)
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
442 {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
443 boolean debug = log.isDebugEnabled();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
444
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
445 if (debug) {
6564
42856353a222 OutputHelper: Fix misleading debug output copy/pasted from D4EArtifactCollection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6140
diff changeset
446 log.debug("OutputHelper.initItemAttribute");
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
447 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
448
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
449 Theme t = getThemeForFacet(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8392
diff changeset
450 uuid, facet, pattern, index, outName, context);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
451
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
452 if (t == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
453 log.info("Could not find theme for facet. Cancel initialization.");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
454 return null;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
455 }
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 Document attr = XMLUtils.newDocument();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
458 addThemeToAttribute(uuid, attr, t, context);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
459
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
460 if (debug) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
461 log.debug("initItemAttribute for facet " + facet + ": "
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
462 + XMLUtils.toString(attr));
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
463 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
464
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
465 return attr;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
466 }
3299
d76a889bc30d Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3295
diff changeset
467
3295
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 * Returns the theme of a specific facet.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
470 *
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
471 * @param uuid The uuid of an artifact.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
472 * @param facet The name of the facet.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
473 * @param context The CallContext object.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
474 *
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
475 * @return the desired theme.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
476 */
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
477 protected Theme getThemeForFacet(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
478 String uuid,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
479 String facet,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
480 String pattern,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
481 int index,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
482 String outName,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
483 CallContext context)
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
484 {
6564
42856353a222 OutputHelper: Fix misleading debug output copy/pasted from D4EArtifactCollection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6140
diff changeset
485 log.info("OutputHelper.getThemeForFacet: " + facet);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
486
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
487 RiverContext flysContext = context instanceof RiverContext
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
488 ? (RiverContext) context
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
489 : (RiverContext) context.globalContext();
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
490
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
491 // Push artifact in flysContext.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
492 ArtifactDatabase db = context.getDatabase();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
493 try {
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
494 D4EArtifact artifact = (D4EArtifact) db.getRawArtifact(uuid);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
495 log.debug("Got raw artifact");
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
496 flysContext.put(RiverContext.ARTIFACT_KEY, artifact);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
497 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
498 catch (ArtifactDatabaseException dbe) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
499 log.error("Exception caught when trying to get art.", dbe);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
500 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
501
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
502 Theme t = ThemeFactory.getTheme(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
503 flysContext,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
504 facet,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
505 pattern,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
506 outName,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
507 "default");
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 if (t != null) {
3781
8e713e9bb4d7 Defined colors for bed quality themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3304
diff changeset
510 log.debug("found theme for facet '" + facet + "'");
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
511 t.setFacet(facet);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
512 t.setIndex(index);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
513 }
3781
8e713e9bb4d7 Defined colors for bed quality themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3304
diff changeset
514 else {
8e713e9bb4d7 Defined colors for bed quality themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3304
diff changeset
515 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
516 }
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
517
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
518 return t;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
519 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
520
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
521 /**
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
522 * Inner class to structure/order the themes of a chart.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
523 */
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
524 private static class ThemeList {
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
525 private Logger log = LogManager.getLogger(ThemeList.class);
4255
670e98f5a441 Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents: 4049
diff changeset
526 protected List<ManagedFacet> themes;
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
527
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
528 public ThemeList(Document output) {
4255
670e98f5a441 Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents: 4049
diff changeset
529 themes = new ArrayList<ManagedFacet>();
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
530 parse(output);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
531 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
532
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
533 protected void parse(Document output) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
534 NodeList themeList = (NodeList) XMLUtils.xpath(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
535 output,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
536 "art:output/art:facet",
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
537 XPathConstants.NODESET,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
538 ArtifactNamespaceContext.INSTANCE);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
539
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
540 int num = themeList != null ? themeList.getLength() : 0;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
541
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7254
diff changeset
542 log.debug("Output has " + num + " elements.");
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
543
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
544 if (num == 0) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
545 return;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
546 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
547
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
548 for (int i = 0; i < num; i++) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
549 Element theme = (Element) themeList.item(i);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
550
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
551 ManagedDomFacet facet = new ManagedDomFacet(theme);
4255
670e98f5a441 Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents: 4049
diff changeset
552 themes.add(facet);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
553 }
4255
670e98f5a441 Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents: 4049
diff changeset
554
670e98f5a441 Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents: 4049
diff changeset
555 Collections.sort(themes);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
556 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
557
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
558 public ManagedFacet get(int idx) {
4255
670e98f5a441 Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents: 4049
diff changeset
559 return themes.get(idx);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
560 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
561
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
562 public void remove(int idx) {
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
563 themes.remove(idx);
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
564 }
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
565
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
566 public int size() {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
567 return themes.size();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
568 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
569 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
570 }
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3299
diff changeset
571 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org