Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/sq/SQOverviewGenerator.java @ 3422:118fe1cc8cc8
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
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 20 Jul 2012 06:50:25 +0000 |
parents | 02d5731b43a2 |
children | 3fc5c914b1c1 |
line wrap: on
line diff
--- 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<String, String> vars = new HashMap<String, String>(); 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;