Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java @ 443:da21c256a0ba
"horizontale Schnittprofile" are now configured via conf.xml
gnv-artifacts/trunk@491 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 29 Dec 2009 14:54:17 +0000 |
parents | 52e031261eaa |
children | 85f48e287fb3 |
comparison
equal
deleted
inserted
replaced
442:52e031261eaa | 443:da21c256a0ba |
---|---|
16 import org.apache.log4j.Logger; | 16 import org.apache.log4j.Logger; |
17 | 17 |
18 import org.w3c.dom.Document; | 18 import org.w3c.dom.Document; |
19 import org.w3c.dom.Element; | 19 import org.w3c.dom.Element; |
20 import org.w3c.dom.NodeList; | 20 import org.w3c.dom.NodeList; |
21 import org.w3c.dom.Node; | |
22 | 21 |
23 import de.intevation.gnv.geobackend.base.connectionpool.ConnectionPoolFactory; | 22 import de.intevation.gnv.geobackend.base.connectionpool.ConnectionPoolFactory; |
24 | 23 |
25 import de.intevation.gnv.geobackend.base.query.container.QueryContainerFactory; | 24 import de.intevation.gnv.geobackend.base.query.container.QueryContainerFactory; |
26 import de.intevation.gnv.geobackend.base.query.container.exception.QueryContainerException; | 25 import de.intevation.gnv.geobackend.base.query.container.exception.QueryContainerException; |
64 "/artifact-database/gnv/palettes"; | 63 "/artifact-database/gnv/palettes"; |
65 | 64 |
66 public final static String PALETTE_ITEMS = | 65 public final static String PALETTE_ITEMS = |
67 "palette"; | 66 "palette"; |
68 | 67 |
69 public final static String PALETTES = | 68 public final static String HORIZONTAL_CROSS_SECTION_PROFILE_SAMPLES = |
70 "gnv.color.palettes"; | 69 "/artifact-database/gnv/horizontal-cross-section-profile/samples/@number"; |
71 | |
72 public final static String CHARTTEMPLATE = "gnv.chart.template"; | |
73 | 70 |
74 /** | 71 /** |
75 * Constructor | 72 * Constructor |
76 */ | 73 */ |
77 public GNVArtifactContextFactory() { | 74 public GNVArtifactContextFactory() { |
119 | 116 |
120 configurePalettes(config, returnValue); | 117 configurePalettes(config, returnValue); |
121 | 118 |
122 configureChartTemplate(config, returnValue); | 119 configureChartTemplate(config, returnValue); |
123 | 120 |
121 configureHorizontalCrossSectionProfile(config, returnValue); | |
124 | 122 |
125 } catch (FileNotFoundException e) { | 123 } catch (FileNotFoundException e) { |
126 log.error(e, e); | 124 log.error(e, e); |
127 } catch (IOException e) { | 125 } catch (IOException e) { |
128 log.error(e, e); | 126 log.error(e, e); |
129 } catch (QueryContainerException e) { | 127 } catch (QueryContainerException e) { |
130 log.error(e, e); | 128 log.error(e, e); |
131 } | 129 } |
132 return returnValue; | 130 return returnValue; |
131 } | |
132 | |
133 protected void configureHorizontalCrossSectionProfile( | |
134 Document config, | |
135 GNVArtifactContext context | |
136 ) | |
137 { | |
138 log.info("configuration of horizontal cross section profile"); | |
139 | |
140 String numSamples = Config.getStringXPath( | |
141 config, | |
142 HORIZONTAL_CROSS_SECTION_PROFILE_SAMPLES); | |
143 | |
144 Integer samples = | |
145 GNVArtifactContext.DEFAULT_HORIZONTAL_CROSS_SECTION_PROFILE_SAMPLES; | |
146 | |
147 if (numSamples == null) { | |
148 log.warn("No number of samples found."); | |
149 } | |
150 else { | |
151 try { | |
152 samples = Integer.valueOf(numSamples); | |
153 } | |
154 catch (NumberFormatException nfe) { | |
155 log.warn("Invalid integer for number of samples"); | |
156 } | |
157 } | |
158 | |
159 log.info("# horizontal cross section profile samples: " + samples); | |
160 | |
161 context.put( | |
162 GNVArtifactContext.HORIZONTAL_CROSS_SECTION_PROFILE_SAMPLES_KEY, | |
163 samples); | |
133 } | 164 } |
134 | 165 |
135 protected void configureChartTemplate( | 166 protected void configureChartTemplate( |
136 Document config, | 167 Document config, |
137 GNVArtifactContext context | 168 GNVArtifactContext context |
138 ) { | 169 ) { |
139 log.info("Initialisation of chart template"); | 170 log.info("Initialisation of chart template"); |
140 String chartConfigFile = Config.getStringXPath( | 171 String chartConfigFile = Config.getStringXPath( |
141 config, CHARTCONFIGNODEPATH | 172 config, CHARTCONFIGNODEPATH |
142 ); | 173 ); |
143 chartConfigFile = Config.replaceConfigDir(chartConfigFile); | 174 |
144 log.debug("Parse xml configuration of " + chartConfigFile); | |
145 | |
146 Document tmpl = XMLUtils.parseDocument(new File(chartConfigFile)); | |
147 XMLChartTheme theme = new XMLChartTheme("XMLChartTheme"); | 175 XMLChartTheme theme = new XMLChartTheme("XMLChartTheme"); |
148 if (tmpl != null) { | 176 |
149 theme.applyXMLConfiguration(tmpl); | 177 if (chartConfigFile == null) { |
178 log.warn("no configuration file for chart template found"); | |
150 } | 179 } |
151 else { | 180 else { |
152 log.error( | 181 chartConfigFile = Config.replaceConfigDir(chartConfigFile); |
153 "Cannot load chart template from '" + | 182 log.debug("Parse xml configuration of " + chartConfigFile); |
154 chartConfigFile + "'"); | 183 |
155 } | 184 Document tmpl = XMLUtils.parseDocument(new File(chartConfigFile)); |
156 | 185 if (tmpl != null) { |
157 context.put(CHARTTEMPLATE, theme); | 186 theme.applyXMLConfiguration(tmpl); |
187 } | |
188 else { | |
189 log.error( | |
190 "Cannot load chart template from '" + | |
191 chartConfigFile + "'"); | |
192 } | |
193 } | |
194 | |
195 context.put(GNVArtifactContext.CHART_TEMPLATE_KEY, theme); | |
158 } | 196 } |
159 | 197 |
160 protected void configurePalettes( | 198 protected void configurePalettes( |
161 Document config, | 199 Document config, |
162 GNVArtifactContext context | 200 GNVArtifactContext context |
219 } | 257 } |
220 } | 258 } |
221 } // for all palettes | 259 } // for all palettes |
222 } | 260 } |
223 | 261 |
224 context.put(PALETTES, palettes); | 262 context.put(GNVArtifactContext.PALETTES_KEY, palettes); |
225 } | 263 } |
226 | 264 |
227 /** | 265 /** |
228 * @param filePath | 266 * @param filePath |
229 * @return | 267 * @return |