Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java @ 1999:02ce03329ef5
Some optimizations during out() operation of FLYSArtifactCollection.
flys-artifacts/trunk@3437 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 16 Dec 2011 11:47:57 +0000 |
parents | 3862c50d1cf3 |
children | 81eaea64c0db |
comparison
equal
deleted
inserted
replaced
1998:3862c50d1cf3 | 1999:02ce03329ef5 |
---|---|
226 | 226 |
227 Settings settings = output.getSettings(); | 227 Settings settings = output.getSettings(); |
228 | 228 |
229 if (settings == null) { | 229 if (settings == null) { |
230 log.debug("No Settings set for Output '" + outName + "'."); | 230 log.debug("No Settings set for Output '" + outName + "'."); |
231 output.setSettings(createInitialOutputSettings(cc, outName)); | 231 output.setSettings( |
232 createInitialOutputSettings(cc, attribute, outName)); | |
232 | 233 |
233 modified = true; | 234 modified = true; |
234 } | 235 } |
235 } | 236 } |
236 | 237 |
239 | 240 |
240 | 241 |
241 /** | 242 /** |
242 * This method uses the the OutGenerator for the specified Output | 243 * This method uses the the OutGenerator for the specified Output |
243 * <i>out</i> to create an initial Settings object. | 244 * <i>out</i> to create an initial Settings object. |
244 */ | 245 * |
245 protected Settings createInitialOutputSettings(CallContext cc, String out) { | 246 * @param cc The CallContext object. |
247 * @param attr The CollectionAttribute. | |
248 * @param out The name of the output. | |
249 * | |
250 * @return a default Settings object for the specified Output. | |
251 */ | |
252 protected Settings createInitialOutputSettings( | |
253 CallContext cc, | |
254 CollectionAttribute attr, | |
255 String out | |
256 ) { | |
246 OutGenerator outGen = getOutGenerator(cc, out, null); | 257 OutGenerator outGen = getOutGenerator(cc, out, null); |
258 | |
259 if (outGen == null) { | |
260 return null; | |
261 } | |
247 | 262 |
248 // XXX NOTE: the outGen is not able to process its generate() operation, | 263 // XXX NOTE: the outGen is not able to process its generate() operation, |
249 // because it has no OutputStream set! | 264 // because it has no OutputStream set! |
250 outGen.init(XMLUtils.newDocument(), null, cc); | 265 outGen.init(XMLUtils.newDocument(), null, cc); |
251 prepareMasterArtifact(outGen, cc); | 266 prepareMasterArtifact(outGen, cc); |
252 | 267 |
253 try { | 268 try { |
254 Document attr = getAttribute(cc, out); | 269 Document outAttr = getAttribute(cc, attr, out); |
255 doOut(outGen, out, out, attr, cc); | 270 doOut(outGen, out, out, outAttr, cc); |
256 } | 271 } |
257 catch (ArtifactDatabaseException adbe) { | 272 catch (ArtifactDatabaseException adbe) { |
258 log.error(adbe, adbe); | 273 log.error(adbe, adbe); |
259 } | 274 } |
260 catch (IOException ioe) { | 275 catch (IOException ioe) { |
303 // TODO Throw an exception. | 318 // TODO Throw an exception. |
304 | 319 |
305 return; | 320 return; |
306 } | 321 } |
307 | 322 |
323 Document oldAttrs = getAttribute(); | |
324 AttributeParser parser = new AttributeParser(oldAttrs); | |
325 CollectionAttribute cAttr = parser.getCollectionAttribute(); | |
326 | |
327 Output output = cAttr.getOutput(name); | |
328 Settings settings = output.getSettings(); | |
329 | |
308 generator.init(format, out, context); | 330 generator.init(format, out, context); |
309 prepareMasterArtifact(generator, context); | 331 prepareMasterArtifact(generator, context); |
310 | 332 |
311 try { | 333 try { |
312 Document attr = getAttribute(context, name); | 334 Document attr = getAttribute(context, cAttr, name); |
313 doOut(generator, name, subtype, attr, context); | 335 doOut(generator, name, subtype, attr, context); |
314 generator.generate(); | 336 generator.generate(); |
315 } | 337 } |
316 catch (ArtifactDatabaseException adbe) { | 338 catch (ArtifactDatabaseException adbe) { |
317 log.error(adbe, adbe); | 339 log.error(adbe, adbe); |
524 | 546 |
525 /** | 547 /** |
526 * Returns the "attribute" (part of description document) for a specific | 548 * Returns the "attribute" (part of description document) for a specific |
527 * output type. | 549 * output type. |
528 * | 550 * |
551 * @param context The CallContext object. | |
552 * @param cAttr The CollectionAttribute. | |
529 * @param output The name of the desired output type. | 553 * @param output The name of the desired output type. |
530 * | 554 * |
531 * @return the attribute for the desired output type. | 555 * @return the attribute for the desired output type. |
532 */ | 556 */ |
533 protected Document getAttribute(CallContext context, String output) | 557 protected Document getAttribute( |
558 CallContext context, | |
559 CollectionAttribute cAttr, | |
560 String output) | |
534 throws ArtifactDatabaseException | 561 throws ArtifactDatabaseException |
535 { | 562 { |
536 CollectionAttribute cAttr = buildOutAttributes( | |
537 context.getDatabase(), | |
538 context, | |
539 new AttributeParser(getAttribute()), | |
540 getArtifactUUIDs(context)); | |
541 | |
542 Document attr = cAttr.toXML(); | 563 Document attr = cAttr.toXML(); |
543 | 564 |
544 Node out = (Node) XMLUtils.xpath( | 565 Node out = (Node) XMLUtils.xpath( |
545 attr, | 566 attr, |
546 "art:attribute/art:outputs/art:output[@name='" + output + "']", | 567 "art:attribute/art:outputs/art:output[@name='" + output + "']", |
894 protected OutGenerator getOutGenerator( | 915 protected OutGenerator getOutGenerator( |
895 CallContext context, | 916 CallContext context, |
896 String name, | 917 String name, |
897 String type) | 918 String type) |
898 { | 919 { |
920 log.debug("Search OutGenerator for Output '" + name + "'"); | |
921 | |
899 FLYSContext flysContext = context instanceof FLYSContext | 922 FLYSContext flysContext = context instanceof FLYSContext |
900 ? (FLYSContext) context | 923 ? (FLYSContext) context |
901 : (FLYSContext) context.globalContext(); | 924 : (FLYSContext) context.globalContext(); |
902 | 925 |
903 Map<String, Class> generators = (Map<String, Class>) | 926 Map<String, Class> generators = (Map<String, Class>) |