comparison artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java @ 8221:a0994a326e2a

Call context inspector in output helper.
author Sascha L. Teichmann <teichmann@intevation.de>
date Mon, 08 Sep 2014 15:48:11 +0200
parents e4606eae8ea5
children 0bec47e5a951
comparison
equal deleted inserted replaced
8220:1d3d61c8f596 8221:a0994a326e2a
20 import org.apache.log4j.Logger; 20 import org.apache.log4j.Logger;
21 import org.w3c.dom.Document; 21 import org.w3c.dom.Document;
22 import org.w3c.dom.Element; 22 import org.w3c.dom.Element;
23 import org.w3c.dom.Node; 23 import org.w3c.dom.Node;
24 import org.w3c.dom.NodeList; 24 import org.w3c.dom.NodeList;
25
26 import org.dive4elements.artifacts.ContextInjector;
25 27
26 import org.dive4elements.artifactdatabase.Backend; 28 import org.dive4elements.artifactdatabase.Backend;
27 import org.dive4elements.artifactdatabase.Backend.PersistentArtifact; 29 import org.dive4elements.artifactdatabase.Backend.PersistentArtifact;
28 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; 30 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
29 import org.dive4elements.artifactdatabase.state.Facet; 31 import org.dive4elements.artifactdatabase.state.Facet;
50 protected String identifier; 52 protected String identifier;
51 53
52 public OutputHelper(String identifier) { 54 public OutputHelper(String identifier) {
53 this.identifier = identifier; 55 this.identifier = identifier;
54 } 56 }
57
58 private static ContextInjector getContextInjector(CallContext context, String out) {
59 RiverContext flysContext = context instanceof RiverContext
60 ? (RiverContext)context
61 : (RiverContext)context.globalContext();
62
63 GeneratorLookup generators =
64 (GeneratorLookup)flysContext.get(RiverContext.OUTGENERATORS_KEY);
65
66 if (generators == null) {
67 return null;
68 }
69
70 GeneratorLookup.Item item = generators.getGenerator(out);
71 return item != null
72 ? item.getContextInjector()
73 : null;
74 }
55 /** 75 /**
56 * Creates a concrete output. 76 * Creates a concrete output.
57 * 77 *
58 * @param generator The OutGenerator that creates the output. 78 * @param generator The OutGenerator that creates the output.
59 * @param outputName The name of the requested output. 79 * @param outputName The name of the requested output.
80 ThemeDocument themeDoc = new ThemeDocument(attributes); 100 ThemeDocument themeDoc = new ThemeDocument(attributes);
81 101
82 List<ArtifactAndFacet> dataProviders = 102 List<ArtifactAndFacet> dataProviders =
83 doBlackboardPass(themeList, context, outName); 103 doBlackboardPass(themeList, context, outName);
84 104
105 ContextInjector ci = getContextInjector(context, outName);
106
85 try { 107 try {
86 for (int i = 0, T = themeList.size(); i < T; i++) { 108 for (int i = 0, T = themeList.size(); i < T; i++) {
87 ManagedFacet theme = themeList.get(i); 109 ManagedFacet theme = themeList.get(i);
88 110
89 if (theme == null) { 111 if (theme == null) {
105 } 127 }
106 128
107 // Skip invisible themes. 129 // Skip invisible themes.
108 if (theme.getVisible() == 0) { 130 if (theme.getVisible() == 0) {
109 continue; 131 continue;
132 }
133
134 if (ci != null) {
135 ci.injectContext(context, dataProviders.get(i).getArtifact());
110 } 136 }
111 137
112 if (outName.equals("sq_overview")) { 138 if (outName.equals("sq_overview")) {
113 generator.doOut( 139 generator.doOut(
114 dataProviders.get(i), 140 dataProviders.get(i),

http://dive4elements.wald.intevation.org