annotate artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java @ 8254:c87c87544cc6

Made call context injectors a list of comma separated classes.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 10 Sep 2014 12:42:39 +0200
parents 724081af301c
children 4d99606a844e
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 import org.apache.log4j.Logger;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 import org.w3c.dom.Document;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 import org.w3c.dom.Element;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 import org.w3c.dom.Node;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 import org.w3c.dom.NodeList;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25
8221
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
26 import org.dive4elements.artifacts.ContextInjector;
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
27
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
28 import org.dive4elements.artifactdatabase.Backend;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
29 import org.dive4elements.artifactdatabase.Backend.PersistentArtifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
30 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
31 import org.dive4elements.artifactdatabase.state.Facet;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
32 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
33 import org.dive4elements.artifacts.ArtifactDatabase;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
34 import org.dive4elements.artifacts.ArtifactDatabaseException;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
35 import org.dive4elements.artifacts.CallContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
36 import org.dive4elements.artifacts.CallMeta;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
37 import org.dive4elements.artifacts.common.ArtifactNamespaceContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
38 import org.dive4elements.artifacts.common.utils.ClientProtocolUtils;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
39 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
40 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
41 import org.dive4elements.river.artifacts.context.RiverContext;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
42 import org.dive4elements.river.artifacts.model.ManagedDomFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
43 import org.dive4elements.river.artifacts.model.ManagedFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
44 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
45 import org.dive4elements.river.themes.ThemeDocument;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4433
diff changeset
46 import org.dive4elements.river.themes.ThemeFactory;
3295
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 public class OutputHelper {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7254
diff changeset
49 /** The log used in this class. */
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 private static Logger log = Logger.getLogger(OutputHelper.class);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 protected String identifier;
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 OutputHelper(String identifier) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 this.identifier = identifier;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 }
8221
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
57
8254
c87c87544cc6 Made call context injectors a list of comma separated classes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8225
diff changeset
58 private static List<ContextInjector> getContextInjectors(CallContext context, String out) {
8221
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
59 RiverContext flysContext = context instanceof RiverContext
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
60 ? (RiverContext)context
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
61 : (RiverContext)context.globalContext();
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
62
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
63 GeneratorLookup generators =
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
64 (GeneratorLookup)flysContext.get(RiverContext.OUTGENERATORS_KEY);
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
65
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
66 if (generators == null) {
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
67 return null;
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
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
70 GeneratorLookup.Item item = generators.getGenerator(out);
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
71 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
72 ? item.getContextInjectors()
8221
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
73 : null;
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
74 }
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 /**
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 * Creates a concrete output.
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 * @param generator The OutGenerator that creates the output.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 * @param outputName The name of the requested output.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 * @param attributes The collection's attributes for this concrete output
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 * type.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 * @param context The context object.
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 public void doOut(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 OutGenerator generator,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 String outName,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 String facet,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 Document attributes,
8225
724081af301c Pass request document to the context injectors.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8223
diff changeset
89 CallContext context,
724081af301c Pass request document to the context injectors.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8223
diff changeset
90 Document request
724081af301c Pass request document to the context injectors.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8223
diff changeset
91 ) throws IOException {
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 boolean debug = log.isDebugEnabled();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 if (debug) {
6564
42856353a222 OutputHelper: Fix misleading debug output copy/pasted from D4EArtifactCollection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6140
diff changeset
95 log.debug("OutputHelper.doOut: " + outName);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 ThemeList themeList = new ThemeList(attributes);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99
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
100 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
101
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 List<ArtifactAndFacet> dataProviders =
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
103 doBlackboardPass(themeList, context, outName);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104
8254
c87c87544cc6 Made call context injectors a list of comma separated classes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8225
diff changeset
105 List<ContextInjector> cis = getContextInjectors(context, outName);
8221
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
106
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107 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
108 for (int i = 0, T = themeList.size(); i < T; i++) {
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
109 ManagedFacet theme = themeList.get(i);
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 if (theme == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 log.debug("Theme is empty - no output is generated.");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113 continue;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
114 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
116 String art = theme.getArtifact();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117 String facetName = theme.getName();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 if (debug) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120 log.debug("Do output for...");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 log.debug("... artifact: " + art);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122 log.debug("... facet: " + facetName);
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 if (outName.equals("export") && !facetName.equals(facet)) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
126 continue;
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 // Skip invisible themes.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 if (theme.getVisible() == 0) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 continue;
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
8254
c87c87544cc6 Made call context injectors a list of comma separated classes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8225
diff changeset
134 if (cis != null) {
c87c87544cc6 Made call context injectors a list of comma separated classes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8225
diff changeset
135 for (ContextInjector ci: cis) {
c87c87544cc6 Made call context injectors a list of comma separated classes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8225
diff changeset
136 ci.injectContext(
c87c87544cc6 Made call context injectors a list of comma separated classes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8225
diff changeset
137 context, dataProviders.get(i).getArtifact(), request);
c87c87544cc6 Made call context injectors a list of comma separated classes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8225
diff changeset
138 }
8221
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
139 }
a0994a326e2a Call context inspector in output helper.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8202
diff changeset
140
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
141 if (outName.equals("sq_overview")) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
142 generator.doOut(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
143 dataProviders.get(i),
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
144 themeDoc,
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
145 theme.getActive() == 1);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
146 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
147 else {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
148 generator.doOut(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
149 dataProviders.get(i),
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
150 getFacetThemeFromAttribute(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
151 art,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
152 outName,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
153 facetName,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
154 theme.getDescription(),
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
155 theme.getIndex(),
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
156 context),
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
157 theme.getActive() == 1);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
158 }
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 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
161 catch (ArtifactDatabaseException ade) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
162 log.error(ade, ade);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
163 }
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 /**
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
166 * Returns the attribute that belongs to an artifact and facet stored in
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
167 * this collection.
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 * @param uuid The Artifact's uuid.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
170 * @param outname The name of the requested output.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
171 * @param facet The name of the requested facet.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
172 * @param context The CallContext.
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 * @return an attribute in form of a document.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
175 */
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
176 protected ThemeDocument getFacetThemeFromAttribute(
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
177 String uuid,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
178 String outName,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
179 String facet,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
180 String pattern,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
181 int index,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
182 CallContext context)
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
183 throws ArtifactDatabaseException
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 boolean debug = log.isDebugEnabled();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
186
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
187 if (debug) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
188 log.debug(
6564
42856353a222 OutputHelper: Fix misleading debug output copy/pasted from D4EArtifactCollection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6140
diff changeset
189 "OutputHelper.getFacetThemeFromAttribute(facet="
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
190 + facet + ", index=" + index + ")");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
191 }
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 ArtifactDatabase db = context.getDatabase();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
194 CallMeta meta = context.getMeta();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
195
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
196 Document attr = db.getCollectionItemAttribute(identifier, uuid, meta);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
197
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
198 if (attr == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
199 attr = initItemAttribute(uuid, facet, pattern, index, outName, context);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
200
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
201 if (attr == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
202 return null;
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 }
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 (debug) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
207 log.debug("Search attribute of collection item: " + uuid);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
208 }
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 Node tmp = (Node) XMLUtils.xpath(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
211 attr,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
212 "/art:attribute",
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
213 XPathConstants.NODE,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
214 ArtifactNamespaceContext.INSTANCE);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
215
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
216 if (tmp == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
217 log.warn("No attribute found. Operation failed.");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
218 return null;
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 if (debug) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
222 log.debug("Search theme for facet '" + facet + "' in attribute.");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
223 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
224
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
225 Map<String, String> vars = new HashMap<String, String>();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
226 vars.put("facet", facet);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
227 vars.put("index", String.valueOf(index));
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
228
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
229 Node theme = (Node) XMLUtils.xpath(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
230 tmp,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
231 "art:themes/theme[@facet=$facet and @index=$index]",
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
232 XPathConstants.NODE,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
233 ArtifactNamespaceContext.INSTANCE,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
234 vars);
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 (theme == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
237 log.warn("Could not find the theme in attribute of: " + facet + " " + uuid);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
238
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
239 Theme t = getThemeForFacet(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
240 uuid, facet, pattern, index, outName, context);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
241
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
242 if (t == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
243 log.warn("No theme found for facet: " + facet);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
244 return null;
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
247 addThemeToAttribute(uuid, attr, t, context);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
248 theme = t.toXML().getFirstChild();
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
251 Document doc = XMLUtils.newDocument();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
252 doc.appendChild(doc.importNode(theme, true));
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
253
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
254 return new ThemeDocument(doc);
3295
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 * Adds the theme of a facet to a CollectionItem's attribute.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
258 *
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
259 * @param uuid The uuid of the artifact.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
260 * @param attr The current attribute of an artifact.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
261 * @param t The theme to add.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
262 * @param context The CallContext.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
263 */
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
264 protected void addThemeToAttribute(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
265 String uuid,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
266 Document attr,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
267 Theme t,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
268 CallContext context)
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
269 {
6564
42856353a222 OutputHelper: Fix misleading debug output copy/pasted from D4EArtifactCollection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6140
diff changeset
270 log.debug("OutputHelper.addThemeToAttribute: " + uuid);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
271
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
272 if (t == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
273 log.warn("Theme is empty - cancel adding it to attribute!");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
274 return;
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
277 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
278 attr,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
279 ArtifactNamespaceContext.NAMESPACE_URI,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
280 ArtifactNamespaceContext.NAMESPACE_PREFIX);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
281
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
282 Node tmp = (Node) XMLUtils.xpath(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
283 attr,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
284 "/art:attribute",
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
285 XPathConstants.NODE,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
286 ArtifactNamespaceContext.INSTANCE);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
287
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
288 if (tmp == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
289 tmp = ec.create("attribute");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
290 attr.appendChild(tmp);
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
293 Node themes = (Node) XMLUtils.xpath(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
294 tmp,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
295 "art:themes",
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
296 XPathConstants.NODE,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
297 ArtifactNamespaceContext.INSTANCE);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
298
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
299 if (themes == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
300 themes = ec.create("themes");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
301 tmp.appendChild(themes);
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
304 themes.appendChild(attr.importNode(t.toXML().getFirstChild(), true));
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
305
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
306 try {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
307 setCollectionItemAttribute(uuid, attr, context);
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 catch (ArtifactDatabaseException e) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
310 // do nothing
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
311 log.warn("Cannot set attribute of item: " + uuid);
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 /**
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
316 * 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
317 * value <i>attr</i>.
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 * @param uuid The uuid of the CollectionItem.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
320 * @param attr The new attribute for the CollectionItem.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
321 * @param context The CallContext.
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 public void setCollectionItemAttribute(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
324 String uuid,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
325 Document attr,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
326 CallContext context)
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
327 throws ArtifactDatabaseException
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
328 {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
329 Document doc = ClientProtocolUtils.newSetItemAttributeDocument(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
330 uuid,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
331 attr);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
332
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
333 if (doc == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
334 log.warn("Cannot set item attribute: No attribute found.");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
335 return;
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
338 ArtifactDatabase db = context.getDatabase();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
339 CallMeta meta = context.getMeta();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
340
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
341 db.setCollectionItemAttribute(identifier, uuid, doc, meta);
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 /**
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
346 * Show blackboard (context) to each facet and create a list of
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
347 * ArtifactAndFacets on the fly (with the same ordering as the passed
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
348 * ThemeList).
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
349 * @param themeList ThemeList to create a ArtifactAndFacetList along.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
350 * @param context The "Blackboard".
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 protected List<ArtifactAndFacet> doBlackboardPass(
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
353 ThemeList themeList, CallContext context, String outname
3295
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 ArrayList<ArtifactAndFacet> dataProviders =
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
356 new ArrayList<ArtifactAndFacet>();
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 try {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
359 // Collect all ArtifactAndFacets for blackboard pass.
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
360 for (int i = 0; i < themeList.size(); i++) {
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
361 log.debug("BLackboard pass for: " + outname);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
362 ManagedFacet theme = themeList.get(i);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
363 if (theme == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
364 log.warn("A ManagedFacet in ThemeList is null.");
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
365 themeList.remove(i);
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
366 i--;
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
367 continue;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
368 }
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
369
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
370 String uuid = theme.getArtifact();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
371 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
372 D4EArtifact flys = (D4EArtifact) artifact;
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
373 Facet face = flys.getNativeFacet(theme, outname);
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
374 log.debug("Looking for Native Facet for theme: " + theme + " and out: " +
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
375 outname + " in artifact: " + uuid +
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
376 face == null ? " Found. " : " Not Found. ");
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
377 if (face == null) {
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
378 log.warn("Theme " + theme.getName() + " for " + outname + " has no facets!. Removing theme.");
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
379 themeList.remove(i);
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
380 i--;
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
381 continue;
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
382 }
3295
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 ArtifactAndFacet artifactAndFacet = new ArtifactAndFacet(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
385 artifact,
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
386 face);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
387
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
388 // XXX HELP ME PLEASE
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
389 artifactAndFacet.setFacetDescription(theme.getDescription());
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
390
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
391 // Show blackboard to facet.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
392 artifactAndFacet.register(context);
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 // Add to themes.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
395 dataProviders.add(i, artifactAndFacet);
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 catch (ArtifactDatabaseException ade) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
399 log.error("ArtifactDatabaseException!", ade);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
400 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
401
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
402 return dataProviders;
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 * Returns a concrete Artifact of this collection specified by its uuid.
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 * @param uuid The Artifact's uuid.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
408 * @param context The CallContext.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
409 *
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
410 * @return an Artifact.
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 protected Artifact getArtifact(String uuid, CallContext context)
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
413 throws ArtifactDatabaseException
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
414 {
6564
42856353a222 OutputHelper: Fix misleading debug output copy/pasted from D4EArtifactCollection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6140
diff changeset
415 log.debug("OutputHelper.getArtifact");
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 Backend backend = Backend.getInstance();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
418 PersistentArtifact persistent = backend.getArtifact(uuid);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
419
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
420 return persistent != null ? persistent.getArtifact() : null;
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
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 * Initializes the attribute of an collection item with the theme of a
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
425 * specific facet.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
426 *
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
427 * @param uuid The uuid of an artifact.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
428 * @param facet The name of a facet.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
429 * @param context The CallContext.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
430 *
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
431 * @param the new attribute.
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 protected Document initItemAttribute(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
434 String uuid,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
435 String facet,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
436 String pattern,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
437 int index,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
438 String outName,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
439 CallContext context)
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
440 {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
441 boolean debug = log.isDebugEnabled();
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 if (debug) {
6564
42856353a222 OutputHelper: Fix misleading debug output copy/pasted from D4EArtifactCollection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6140
diff changeset
444 log.debug("OutputHelper.initItemAttribute");
3295
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
447 Theme t = getThemeForFacet(uuid, facet, pattern, index, outName, context);
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 if (t == null) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
450 log.info("Could not find theme for facet. Cancel initialization.");
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
451 return null;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
452 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
453
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
454 Document attr = XMLUtils.newDocument();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
455 addThemeToAttribute(uuid, attr, t, context);
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 (debug) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
458 log.debug("initItemAttribute for facet " + facet + ": "
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
459 + XMLUtils.toString(attr));
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
460 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
461
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
462 return attr;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
463 }
3299
d76a889bc30d Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3295
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 * Returns the theme of a specific facet.
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 * @param uuid The uuid of an artifact.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
469 * @param facet The name of the facet.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
470 * @param context The CallContext object.
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 * @return the desired theme.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
473 */
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
474 protected Theme getThemeForFacet(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
475 String uuid,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
476 String facet,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
477 String pattern,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
478 int index,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
479 String outName,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
480 CallContext context)
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
481 {
6564
42856353a222 OutputHelper: Fix misleading debug output copy/pasted from D4EArtifactCollection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6140
diff changeset
482 log.info("OutputHelper.getThemeForFacet: " + facet);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
483
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
484 RiverContext flysContext = context instanceof RiverContext
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
485 ? (RiverContext) context
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
486 : (RiverContext) context.globalContext();
3295
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 // Push artifact in flysContext.
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
489 ArtifactDatabase db = context.getDatabase();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
490 try {
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
491 D4EArtifact artifact = (D4EArtifact) db.getRawArtifact(uuid);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
492 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
493 flysContext.put(RiverContext.ARTIFACT_KEY, artifact);
3295
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 catch (ArtifactDatabaseException dbe) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
496 log.error("Exception caught when trying to get art.", dbe);
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
499 Theme t = ThemeFactory.getTheme(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
500 flysContext,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
501 facet,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
502 pattern,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
503 outName,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
504 "default");
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 if (t != null) {
3781
8e713e9bb4d7 Defined colors for bed quality themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3304
diff changeset
507 log.debug("found theme for facet '" + facet + "'");
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
508 t.setFacet(facet);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
509 t.setIndex(index);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
510 }
3781
8e713e9bb4d7 Defined colors for bed quality themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3304
diff changeset
511 else {
8e713e9bb4d7 Defined colors for bed quality themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3304
diff changeset
512 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
513 }
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
514
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
515 return t;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
516 }
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 /**
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
519 * Inner class to structure/order the themes of a chart.
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 private static class ThemeList {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7254
diff changeset
522 private Logger log = Logger.getLogger(ThemeList.class);
4255
670e98f5a441 Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents: 4049
diff changeset
523 protected List<ManagedFacet> themes;
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
524
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
525 public ThemeList(Document output) {
4255
670e98f5a441 Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents: 4049
diff changeset
526 themes = new ArrayList<ManagedFacet>();
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
527 parse(output);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
528 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
529
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
530 protected void parse(Document output) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
531 NodeList themeList = (NodeList) XMLUtils.xpath(
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
532 output,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
533 "art:output/art:facet",
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
534 XPathConstants.NODESET,
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
535 ArtifactNamespaceContext.INSTANCE);
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
536
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
537 int num = themeList != null ? themeList.getLength() : 0;
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
538
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7254
diff changeset
539 log.debug("Output has " + num + " elements.");
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
540
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
541 if (num == 0) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
542 return;
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
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
545 for (int i = 0; i < num; i++) {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
546 Element theme = (Element) themeList.item(i);
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 ManagedDomFacet facet = new ManagedDomFacet(theme);
4255
670e98f5a441 Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents: 4049
diff changeset
549 themes.add(facet);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
550 }
4255
670e98f5a441 Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents: 4049
diff changeset
551
670e98f5a441 Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents: 4049
diff changeset
552 Collections.sort(themes);
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
553 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
554
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
555 public ManagedFacet get(int idx) {
4255
670e98f5a441 Fixed leak while merging facets.
Ingo Weinzierl <weinzierl.ingo@googlemail.com>
parents: 4049
diff changeset
556 return themes.get(idx);
3295
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
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
559 public void remove(int idx) {
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
560 themes.remove(idx);
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
561 }
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
562
3295
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
563 public int size() {
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
564 return themes.size();
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
565 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
566 }
4fc442f1b4f6 Refactored FLYSArtifactCollection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
567 }
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3299
diff changeset
568 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org