# HG changeset patch # User Ingo Weinzierl # Date 1342767025 0 # Node ID 118fe1cc8cc8b80f1993fa3617b9d1486e300016 # Parent c44ff50f4970c769e4e19fbdecd0e561f606d85b OutGenerators got a setCollection() method; analogous to setMasterArtifact(). Registered the SQOverviewGenerator as OutGenerator for 'sq_overview' Output. flys-artifacts/trunk@5076 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r c44ff50f4970 -r 118fe1cc8cc8 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Jul 19 21:12:57 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Jul 20 06:50:25 2012 +0000 @@ -1,3 +1,22 @@ +2012-07-20 Ingo Weinzierl + + * src/main/java/de/intevation/flys/exports/ReportGenerator.java, + src/main/java/de/intevation/flys/exports/AbstractExporter.java, + src/main/java/de/intevation/flys/exports/ATExporter.java, + src/main/java/de/intevation/flys/exports/sq/SQOverviewGenerator.java, + src/main/java/de/intevation/flys/exports/ChartGenerator.java, + src/main/java/de/intevation/flys/exports/MapGenerator.java, + src/main/java/de/intevation/flys/exports/OutGenerator.java, + src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java: + Added a setCollection() method that allows the caller of OutGenerators + to set a reference to a FLYSArtifactCollection. + + * src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java: + Use setCollection() to set the reference to the current + FLYSArtifactCollection before using OutGenerators. + + * doc/conf/conf.xml: Registered the SQOverviewGenerator. + 2012-07-19 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java: diff -r c44ff50f4970 -r 118fe1cc8cc8 flys-artifacts/doc/conf/conf.xml --- a/flys-artifacts/doc/conf/conf.xml Thu Jul 19 21:12:57 2012 +0000 +++ b/flys-artifacts/doc/conf/conf.xml Fri Jul 20 06:50:25 2012 +0000 @@ -269,6 +269,7 @@ de.intevation.flys.exports.sq.SQRelationInfoGenerator de.intevation.flys.exports.sq.SQRelationInfoGenerator de.intevation.flys.exports.sq.SQRelationExporter + de.intevation.flys.exports.sq.SQOverviewGenerator de.intevation.flys.exports.fixings.ParametersExporter de.intevation.flys.exports.fixings.DeltaWtExporter de.intevation.flys.exports.fixings.FixDeltaWtGenerator diff -r c44ff50f4970 -r 118fe1cc8cc8 flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java Thu Jul 19 21:12:57 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java Fri Jul 20 06:50:25 2012 +0000 @@ -378,6 +378,7 @@ generator.init(format, out, context); generator.setSettings(settings); + generator.setCollection(this); prepareMasterArtifact(generator, context); try { diff -r c44ff50f4970 -r 118fe1cc8cc8 flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java Thu Jul 19 21:12:57 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java Fri Jul 20 06:50:25 2012 +0000 @@ -17,6 +17,7 @@ import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.model.WQ; +import de.intevation.flys.collections.FLYSArtifactCollection; import de.intevation.flys.utils.FLYSUtils; @@ -33,6 +34,9 @@ protected OutputStream out; protected FLYSArtifact master; + protected FLYSArtifactCollection collection; + + public ATExporter() { } @@ -42,12 +46,18 @@ this.out = out; } + @Override public void setMasterArtifact(Artifact master) { this.master = (FLYSArtifact) master; } @Override + public void setCollection(FLYSArtifactCollection collection) { + this.collection = collection; + } + + @Override public void doOut( ArtifactAndFacet artifactf, Document attr, diff -r c44ff50f4970 -r 118fe1cc8cc8 flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java Thu Jul 19 21:12:57 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java Fri Jul 20 06:50:25 2012 +0000 @@ -22,6 +22,7 @@ import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.flys.artifacts.resources.Resources; +import de.intevation.flys.collections.FLYSArtifactCollection; import de.intevation.flys.utils.Formatter; @@ -67,6 +68,9 @@ /** The selected facet. */ protected String facet; + /** The collection.*/ + protected FLYSArtifactCollection collection; + /** The master artifact. */ protected Artifact master; @@ -113,6 +117,12 @@ } + @Override + public void setCollection(FLYSArtifactCollection collection) { + this.collection = collection; + } + + /** * This doOut() just collects the data of multiple artifacts. Therefore, it * makes use of the addData() method which enables concrete subclasses to diff -r c44ff50f4970 -r 118fe1cc8cc8 flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java Thu Jul 19 21:12:57 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java Fri Jul 20 06:50:25 2012 +0000 @@ -10,6 +10,7 @@ import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.resources.Resources; +import de.intevation.flys.collections.FLYSArtifactCollection; import de.intevation.flys.jfree.Bounds; import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation; import de.intevation.flys.jfree.DoubleBounds; @@ -105,6 +106,8 @@ /** The CallContext object.*/ protected CallContext context; + protected FLYSArtifactCollection collection; + /** The artifact that is used to decorate the chart with meta information.*/ protected Artifact master; @@ -695,6 +698,12 @@ @Override + public void setCollection(FLYSArtifactCollection collection) { + this.collection = collection; + } + + + @Override public void setSettings(Settings settings) { this.settings = settings; } diff -r c44ff50f4970 -r 118fe1cc8cc8 flys-artifacts/src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java Thu Jul 19 21:12:57 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java Fri Jul 20 06:50:25 2012 +0000 @@ -1,5 +1,6 @@ package de.intevation.flys.exports; +import de.intevation.flys.collections.FLYSArtifactCollection; import de.intevation.flys.java2d.NOPGraphics2D; import java.io.IOException; @@ -86,6 +87,16 @@ /** * Dispatches the operation to the instantiated generator. + * + * @param collection The collection. + */ + public void setCollection(FLYSArtifactCollection collection) { + generator.setCollection(collection); + } + + + /** + * Dispatches the operation to the instantiated generator. */ public void doOut( ArtifactAndFacet artifactFacet, diff -r c44ff50f4970 -r 118fe1cc8cc8 flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java Thu Jul 19 21:12:57 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java Fri Jul 20 06:50:25 2012 +0000 @@ -15,6 +15,7 @@ import de.intevation.flys.artifacts.model.map.WMSDBLayerFacet; import de.intevation.flys.artifacts.model.map.WMSLayerFacet; import de.intevation.flys.artifacts.model.map.WSPLGENLayerFacet; +import de.intevation.flys.collections.FLYSArtifactCollection; import de.intevation.flys.utils.GeometryUtils; import de.intevation.flys.utils.MapfileGenerator; import de.intevation.flys.utils.ThemeUtil; @@ -35,6 +36,8 @@ private static Logger logger = Logger.getLogger(MapGenerator.class); + protected FLYSArtifactCollection collection; + protected Artifact master; protected Settings settings; @@ -75,6 +78,10 @@ this.master = master; } + @Override + public void setCollection(FLYSArtifactCollection collection) { + this.collection = collection; + } @Override public void doOut( diff -r c44ff50f4970 -r 118fe1cc8cc8 flys-artifacts/src/main/java/de/intevation/flys/exports/OutGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/OutGenerator.java Thu Jul 19 21:12:57 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/OutGenerator.java Fri Jul 20 06:50:25 2012 +0000 @@ -9,6 +9,7 @@ import de.intevation.artifactdatabase.state.Settings; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; +import de.intevation.flys.collections.FLYSArtifactCollection; /** @@ -38,6 +39,13 @@ void setMasterArtifact(Artifact master); /** + * This method is used to set the Collection of the OutGenerator. + * + * @param collection A reference to the collection. + */ + void setCollection(FLYSArtifactCollection collection); + + /** * Creates the output of an Artifact and appends that single output to the * total output. * diff -r c44ff50f4970 -r 118fe1cc8cc8 flys-artifacts/src/main/java/de/intevation/flys/exports/ReportGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ReportGenerator.java Thu Jul 19 21:12:57 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ReportGenerator.java Fri Jul 20 06:50:25 2012 +0000 @@ -15,6 +15,7 @@ import de.intevation.artifactdatabase.state.Settings; import de.intevation.flys.artifacts.model.Calculation; +import de.intevation.flys.collections.FLYSArtifactCollection; import org.w3c.dom.Document; @@ -44,6 +45,11 @@ } @Override + public void setCollection(FLYSArtifactCollection collection) { + // not needed + } + + @Override public void doOut( ArtifactAndFacet artifactFacet, Document attr, diff -r c44ff50f4970 -r 118fe1cc8cc8 flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQOverviewGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQOverviewGenerator.java Thu Jul 19 21:12:57 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQOverviewGenerator.java Fri Jul 20 06:50:25 2012 +0000 @@ -28,6 +28,7 @@ import de.intevation.flys.artifacts.context.FLYSContext; import de.intevation.flys.collections.AttributeParser; import de.intevation.flys.collections.CollectionAttribute; +import de.intevation.flys.collections.FLYSArtifactCollection; import de.intevation.flys.exports.ChartGenerator; import de.intevation.flys.exports.OutGenerator; import de.intevation.flys.exports.OutputHelper; @@ -40,6 +41,8 @@ public static final String XPATH_CHART_SIZE = "/art:action/art:attributes/art:size"; + protected FLYSArtifactCollection collection; + protected Artifact master; protected Settings settings; @@ -64,7 +67,6 @@ ) { logger.debug("doOut()"); - logger.debug(XMLUtils.toString(attr)); String name = artifactAndFacet.getData(context).toString(); if(name != null) { logger.debug("name: " + name); @@ -73,25 +75,26 @@ context, name, null); + if (g == null) { logger.debug("generator is null."); return; } - logger.debug(XMLUtils.toString(attr)); + OutputHelper helper = new OutputHelper(master.identifier()); + Document collectionAttribute = collection.getAttribute(); + try { - AttributeParser parser = new AttributeParser(request); - CollectionAttribute cAttr = parser.getCollectionAttribute(); - + Document cAttr = getAttribute(context, collectionAttribute, name); g.init(request, out, context); - Document chartAttr = getAttribute(context, cAttr, name); - logger.debug(XMLUtils.toString(chartAttr)); - helper.doOut(g, name, name, request, context); + + helper.doOut(g, name, name, cAttr, context); charts.add(g.generateChart()); - } catch (IOException e) { + } + catch (IOException e) { logger.warn(e); - } catch (ArtifactDatabaseException e) { - // TODO Auto-generated catch block + } + catch (ArtifactDatabaseException e) { logger.warn(e); } } @@ -108,6 +111,10 @@ this.master = master; } + public void setCollection(FLYSArtifactCollection collection) { + this.collection = collection; + } + public void generate() throws IOException { logger.debug("SQOverviewGenerator.generate"); @@ -151,18 +158,18 @@ * output type. * * @param context The CallContext object. - * @param cAttr The CollectionAttribute. + * @param attr The xml attribute saved at the collection. * @param output The name of the desired output type. * * @return the attribute for the desired output type. */ protected Document getAttribute( - CallContext context, - CollectionAttribute cAttr, - String output) + CallContext context, + Document attr, + String output) throws ArtifactDatabaseException { - Document attr = cAttr.toXML(); + logger.debug("find specific XML node for Output: " + output); Map vars = new HashMap(); vars.put("output", output); @@ -174,10 +181,8 @@ ArtifactNamespaceContext.INSTANCE, vars); - if (out != null) { Document o = XMLUtils.newDocument(); - o.appendChild(o.importNode(out, true)); return o;