# HG changeset patch # User Sascha L. Teichmann # Date 1379687649 -7200 # Node ID 0a337f0005c295e0f7fe190e6c6348c09345d79b # Parent a2abd87c0d3b0e44a4c8fdcdd7d21769c51a0b39 Extended init() of OutGenerator to take name of the out to serve. diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/collections/D4EArtifactCollection.java --- a/artifacts/src/main/java/org/dive4elements/river/collections/D4EArtifactCollection.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/collections/D4EArtifactCollection.java Fri Sep 20 16:34:09 2013 +0200 @@ -330,7 +330,7 @@ // XXX NOTE: the outGen is not able to process its generate() operation, // because it has no OutputStream set! - outGen.init(XMLUtils.newDocument(), null, getContext()); + outGen.init(out, XMLUtils.newDocument(), null, getContext()); prepareMasterArtifact(outGen); try { @@ -382,16 +382,12 @@ // If type contains 'chartinfo' use a generator that // just allow access to width, height etc. - OutGenerator generator = null; - if (type != null - && type.length() > 0 - && type.indexOf("chartinfo") > 0) - { - generator = RiverContext.getOutGenerator(context, type, subtype); - } - else { - generator = RiverContext.getOutGenerator(context, name, subtype); - } + + String key = type != null && !type.isEmpty() && type.indexOf("chartinfo") > 0 + ? type + : name; + + OutGenerator generator = RiverContext.getOutGenerator(context, key, subtype); if (generator == null) { log.error("There is no generator specified for output: " + name); @@ -417,7 +413,7 @@ } } - generator.init(format, out, context); + generator.init(key, format, out, context); generator.setSettings(settings); generator.setCollection(this); prepareMasterArtifact(generator); diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/ATExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ATExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ATExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -45,7 +45,8 @@ protected WQ data; protected CallContext context; protected OutputStream out; - protected D4EArtifact master; + protected D4EArtifact master; + protected String outName; protected D4EArtifactCollection collection; @@ -59,7 +60,8 @@ } @Override - public void init(Document request, OutputStream out, CallContext context) { + public void init(String outName, Document request, OutputStream out, CallContext context) { + this.outName = outName; this.context = context; this.out = out; } diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/AbstractExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/AbstractExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/AbstractExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -66,6 +66,9 @@ /** XPath that points to the desired export facet. */ public static final String XPATH_FACET = "/art:action/@art:type"; + /** The out name to serve. */ + protected String outName; + /** The document of the incoming out() request. */ protected Document request; @@ -122,9 +125,15 @@ @Override - public void init(Document request, OutputStream out, CallContext context) { + public void init( + String outName, + Document request, + OutputStream out, + CallContext context + ) { logger.debug("AbstractExporter.init"); + this.outName = outName; this.request = request; this.out = out; this.context = context; diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator.java Fri Sep 20 16:34:09 2013 +0200 @@ -137,6 +137,8 @@ /** List of annotations to insert in plot. */ protected List annotations = new ArrayList(); + protected String outName; + /** * A mini interface that allows to walk over the YAXIS enums defined in * subclasses. @@ -684,9 +686,10 @@ @Override - public void init(Document request, OutputStream out, CallContext context) { + public void init(String outName, Document request, OutputStream out, CallContext context) { logger.debug("ChartGenerator.init"); + this.outName = outName; this.request = request; this.out = out; this.context = context; diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java Fri Sep 20 16:34:09 2013 +0200 @@ -128,6 +128,8 @@ protected abstract List buildYAxisSections(); + protected String outName; + /** * Default constructor that initializes internal data structures. */ @@ -307,9 +309,10 @@ @Override - public void init(Document request, OutputStream out, CallContext context) { + public void init(String outName, Document request, OutputStream out, CallContext context) { logger.debug("ChartGenerator2.init"); + this.outName = outName; this.request = request; this.out = out; this.context = context; diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/ChartInfoGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ChartInfoGenerator.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartInfoGenerator.java Fri Sep 20 16:34:09 2013 +0200 @@ -82,10 +82,10 @@ * @param out * @param context */ - public void init(Document request, OutputStream out, CallContext context) { + public void init(String outName, Document request, OutputStream out, CallContext context) { this.out = out; - generator.init(request, out, context); + generator.init(outName, request, out, context); } diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/ChartInfoGenerator2.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ChartInfoGenerator2.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartInfoGenerator2.java Fri Sep 20 16:34:09 2013 +0200 @@ -82,10 +82,10 @@ * @param out * @param context */ - public void init(Document request, OutputStream out, CallContext context) { + public void init(String outName, Document request, OutputStream out, CallContext context) { this.out = out; - generator.init(request, out, context); + generator.init(outName, request, out, context); } diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -82,15 +82,10 @@ protected boolean isCalculated; protected Date validSince; - public void init(Document request, OutputStream out, CallContext context) { - logger.debug("ComputedDischargeCurveExporter.init"); - - super.init(request, out, context); - - this.data = new ArrayList(); + public ComputedDischargeCurveExporter() { + data = new ArrayList(); } - @Override protected void addData(Object d) { if (d instanceof CalculationResult) { diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -73,16 +73,10 @@ /** The storage that contains all WQKms objects for the different facets. */ protected List data; - - public void init(Document request, OutputStream out, CallContext context) { - logger.debug("DurationCurveExporter.init"); - - super.init(request, out, context); - - this.data = new ArrayList(); + public DurationCurveExporter() { + data = new ArrayList(); } - @Override protected void addData(Object d) { if (d instanceof CalculationResult) { diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/FlowVelocityExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/FlowVelocityExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/FlowVelocityExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -58,13 +58,10 @@ protected List data; - - public void init(Document request, OutputStream out, CallContext cc) { - super.init(request, out, cc); + public FlowVelocityExporter() { data = new ArrayList(); } - @Override protected void addData(Object d) { if (d instanceof CalculationResult) { diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/HistoricalDischargeCurveExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/HistoricalDischargeCurveExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/HistoricalDischargeCurveExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -77,14 +77,10 @@ protected List data; - - public void init(Document request, OutputStream out, CallContext cc) { - super.init(request, out, cc); - + public HistoricalDischargeCurveExporter() { data = new ArrayList(); } - @Override protected void addData(Object d) { logger.debug("Add data of class: " + d.getClass()); diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java Fri Sep 20 16:34:09 2013 +0200 @@ -65,15 +65,18 @@ protected String srid; + protected String outName; + @Override public void setup(Element config) { logger.debug("MapGenerator.setup"); } @Override - public void init(Document request, OutputStream out, CallContext context) { + public void init(String outName, Document request, OutputStream out, CallContext context) { logger.debug("MapGenerator.init"); + this.outName = outName; this.request = request; this.out = out; this.context = context; diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/MiddleBedHeightExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/MiddleBedHeightExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/MiddleBedHeightExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -64,13 +64,10 @@ protected List data; - - public void init(Document request, OutputStream out, CallContext cc) { - super.init(request, out, cc); + public MiddleBedHeightExporter() { data = new ArrayList(); } - @Override protected void addData(Object d) { if (d instanceof CalculationResult) { diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/OutGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/OutGenerator.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/OutGenerator.java Fri Sep 20 16:34:09 2013 +0200 @@ -38,12 +38,13 @@ * Initializes the OutGenerator with meta information which are necessary * for the output generation. * + * @param outName The name of the out to serve. * @param request The incomding request document. * @param out The output stream. * @param context The CallContext that provides further information and * objects used for the output generation. */ - void init(Document request, OutputStream out, CallContext context); + void init(String outName, Document request, OutputStream out, CallContext context); /** * This method is used to tell the OutGenerator which artifact is the master diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/ReferenceCurveExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ReferenceCurveExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ReferenceCurveExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -91,17 +91,10 @@ protected boolean endAtGauge = false; - - @Override - public void init(Document request, OutputStream out, CallContext context) { - logger.debug("ReferenceCurveExporter.init"); - - super.init(request, out, context); - + public ReferenceCurveExporter() { this.data = new ArrayList(); } - /** * Genereate data in csv format. */ diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/ReportGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ReportGenerator.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ReportGenerator.java Fri Sep 20 16:34:09 2013 +0200 @@ -37,6 +37,7 @@ protected Document result; protected OutputStream out; protected CallContext context; + protected String outName; public ReportGenerator() { } @@ -47,8 +48,9 @@ } @Override - public void init(Document request, OutputStream out, CallContext context) { + public void init(String outName, Document request, OutputStream out, CallContext context) { logger.debug("init"); + this.outName = outName; this.out = out; this.context = context; result = null; diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/ShapeExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ShapeExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ShapeExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -30,6 +30,7 @@ private D4EArtifactCollection collection; private String facet; private File dir; + private String outName; @Override public void setup(Element config) { @@ -37,7 +38,8 @@ } @Override - public void init(Document request, OutputStream out, CallContext context) { + public void init(String outName, Document request, OutputStream out, CallContext context) { + this.outName = outName; this.request = request; this.out = out; this.context = context; diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/WDifferencesExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/WDifferencesExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/WDifferencesExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -68,16 +68,10 @@ /** The storage that contains all WKms objects for the different facets. */ protected List data; - - public void init(Document request, OutputStream out, CallContext context) { - logger.debug("WDifferencesExporter.init"); - - super.init(request, out, context); - - this.data = new ArrayList(); + public WDifferencesExporter() { + data = new ArrayList(); } - /** * Genereate data in csv format. */ diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -145,15 +145,10 @@ /** The storage that contains official fixings if available.*/ protected List officalFixings; - public void init(Document request, OutputStream out, CallContext context) { - logger.debug("WaterlevelExporter.init"); - - super.init(request, out, context); - + public WaterlevelExporter() { data = new ArrayList(); } - @Override public void generate() throws IOException diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/fixings/DeltaWtExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/DeltaWtExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/DeltaWtExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -101,10 +101,7 @@ protected List> referenceEvents; - @Override - public void init(Document request, OutputStream out, CallContext context) { - log.debug("DeltaWtExporter.init"); - super.init(request, out, context); + public DeltaWtExporter() { analysisPeriods = new ArrayList>(); referenceEvents = new ArrayList>(); } diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixChartGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixChartGenerator.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixChartGenerator.java Fri Sep 20 16:34:09 2013 +0200 @@ -33,8 +33,8 @@ "/art:action/art:attributes/art:currentKm/@art:km"; @Override - public void init(Document request, OutputStream out, CallContext context) { - super.init(request, out, context); + public void init(String outName, Document request, OutputStream out, CallContext context) { + super.init(outName, request, out, context); Double currentKm = getCurrentKmFromRequest(request); diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDeltaWtGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDeltaWtGenerator.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDeltaWtGenerator.java Fri Sep 20 16:34:09 2013 +0200 @@ -462,8 +462,8 @@ @Override - public void init(Document request, OutputStream out, CallContext context) { - super.init(request, out, context); + public void init(String outName, Document request, OutputStream out, CallContext context) { + super.init(outName, request, out, context); Double currentKm = FixChartGenerator.getCurrentKmFromRequest(request); diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/fixings/ParametersExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/ParametersExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/ParametersExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -40,10 +40,7 @@ protected List parametersList; - @Override - public void init(Document request, OutputStream out, CallContext context) { - log.debug("ParametersExporter.init"); - super.init(request, out, context); + public ParametersExporter() { parametersList = new ArrayList(); } diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -70,10 +70,7 @@ private BedDifferencesResult[] results; - @Override - public void init(Document request, OutputStream out, CallContext context) { - logger.debug("init"); - super.init(request, out, context); + public BedDifferenceExporter() { results = new BedDifferencesResult[0]; } diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedQualityExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedQualityExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedQualityExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -56,10 +56,7 @@ private BedQualityResult[] results; - @Override - public void init(Document request, OutputStream out, CallContext context) { - logger.debug("BedQualityExporter.init"); - super.init(request, out, context); + public BedQualityExporter() { results = new BedQualityResult[0]; } diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -78,17 +78,9 @@ /** Empty constructor. */ public SedimentLoadExporter() { - } - - /** Trivial init. */ - @Override - public void init(Document request, OutputStream out, CallContext context) { - super.init(request, out, context); - logger.debug("init"); results = new SedimentLoadResult[0]; } - /** Process all stored data and write csv. */ @Override protected void writeCSVData(CSVWriter writer) throws IOException { diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/sq/SQOverviewGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQOverviewGenerator.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQOverviewGenerator.java Fri Sep 20 16:34:09 2013 +0200 @@ -62,6 +62,8 @@ protected List charts; + protected String outName; + @Override public void setup(Element config) { logger.debug("SQOverviewGenerator.setup"); @@ -80,6 +82,8 @@ ) { logger.debug("doOut()"); + // TODO: Why not using outName for this. + String name = artifactAndFacet.getData(context).toString(); if(name != null) { logger.debug("name: " + name); @@ -99,7 +103,7 @@ try { Document cAttr = getAttribute(context, collectionAttribute, name); - g.init(request, out, context); + g.init(name, request, out, context); helper.doOut(g, name, name, cAttr, context); JFreeChart chart = g.generateChart(); @@ -116,7 +120,8 @@ } @Override - public void init(Document request, OutputStream out, CallContext context) { + public void init(String outName, Document request, OutputStream out, CallContext context) { + this.outName = outName; this.request = request; this.out = out; this.context = context; @@ -158,6 +163,7 @@ if (i > 1) { vertPos = (size[1] / 3) * (i / 2); } + // TODO: Dispose Graphics object! result.createGraphics().drawImage(img, horPos, vertPos, null); } ImageIO.write(result, "png", out); diff -r a2abd87c0d3b -r 0a337f0005c2 artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java Fri Sep 20 15:44:39 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java Fri Sep 20 16:34:09 2013 +0200 @@ -117,13 +117,10 @@ protected List data; - - public void init(Document request, OutputStream out, CallContext cc) { - super.init(request, out, cc); + public SQRelationExporter() { data = new ArrayList(); } - @Override protected void addData(Object d) { if (d instanceof CalculationResult) {