annotate artifacts/src/main/java/org/dive4elements/river/exports/AbstractExporter.java @ 6611:dfdeed3e997e

Shorten and correct waterlevel not in gauge string
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 18 Jul 2013 17:54:44 +0200
parents af13ceeba52a
children 1b35b2ddfc28
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5133
diff changeset
9 package org.dive4elements.river.exports;
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import java.io.IOException;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import java.io.OutputStream;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import java.io.OutputStreamWriter;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
2284
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
15 import java.text.NumberFormat;
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
16
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import org.w3c.dom.Document;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import org.apache.log4j.Logger;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import au.com.bytecode.opencsv.CSVWriter;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5133
diff changeset
23 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5133
diff changeset
24 import org.dive4elements.artifacts.CallContext;
695
45cd58a2a2bb OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 445
diff changeset
25
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5133
diff changeset
26 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5133
diff changeset
27 import org.dive4elements.artifactdatabase.state.Settings;
445
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
28
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5133
diff changeset
29 import org.dive4elements.artifacts.common.ArtifactNamespaceContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5133
diff changeset
30 import org.dive4elements.artifacts.common.utils.XMLUtils;
416
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 412
diff changeset
31
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5133
diff changeset
32 import org.dive4elements.river.artifacts.resources.Resources;
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
33 import org.dive4elements.river.collections.D4EArtifactCollection;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5133
diff changeset
34
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5133
diff changeset
35 import org.dive4elements.river.utils.Formatter;
2284
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
36
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 * An abstract exporter that implements some basic methods for exporting data of
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 * artifacts.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 *
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 */
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 public abstract class AbstractExporter implements OutGenerator {
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 /** The logger used in this exporter.*/
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 private static Logger logger = Logger.getLogger(AbstractExporter.class);
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
3223
282c9da923ab FixA: flys/issue689: Export CSV for facet 'fix_parameters'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3217
diff changeset
49 /* XXX: Why does AbstractExporter do not implement FacetTypes? */
282c9da923ab FixA: flys/issue689: Export CSV for facet 'fix_parameters'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3217
diff changeset
50 public static String FIX_PARAMETERS = "fix_parameters";
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
52 /** The name of the CSV facet which triggers the CSV creation. */
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 public static final String FACET_CSV = "csv";
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54
2176
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
55 /** The name of the PDF facet which triggers the PDF creation. */
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
56 public static final String FACET_PDF = "pdf";
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
57
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
58 /** The default charset for the CSV export. */
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 public static final String DEFAULT_CSV_CHARSET = "UTF-8";
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
61 /** The default separator for the CSV export. */
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 public static final char DEFAULT_CSV_SEPARATOR = ',';
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
64 /** XPath that points to the desired export facet. */
445
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
65 public static final String XPATH_FACET = "/art:action/@art:type";
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
66
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
67 /** The document of the incoming out() request. */
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 protected Document request;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
70 /** The output stream where the data should be written to. */
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 protected OutputStream out;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
73 /** The CallContext object. */
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 protected CallContext context;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
76 /** The selected facet. */
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 protected String facet;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78
3422
118fe1cc8cc8 OutGenerators got a setCollection() method; analogous to setMasterArtifact(). Registered the SQOverviewGenerator as OutGenerator for 'sq_overview' Output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3270
diff changeset
79 /** The collection.*/
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
80 protected D4EArtifactCollection collection;
3422
118fe1cc8cc8 OutGenerators got a setCollection() method; analogous to setMasterArtifact(). Registered the SQOverviewGenerator as OutGenerator for 'sq_overview' Output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3270
diff changeset
81
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
82 /** The master artifact. */
412
046bd86ae41d Improved the OutGenerator interface to set a master artifact for the out generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 391
diff changeset
83 protected Artifact master;
046bd86ae41d Improved the OutGenerator interface to set a master artifact for the out generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 391
diff changeset
84
5111
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
85 private NumberFormat kmFormat;
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
86
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
87 private NumberFormat wFormat;
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
88
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
89 private NumberFormat qFormat;
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
90
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 * Concrete subclasses need to use this method to write their special data
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 * objects into the CSV document.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 *
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 * @param writer The CSVWriter.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 */
2792
fe987587ebc9 Merged revisions 4539-4540,4543,4545-4546 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2284
diff changeset
98 protected abstract void writeCSVData(CSVWriter writer) throws IOException;
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 /**
2176
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
102 * Concrete subclasses need to use this method to write their special data
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
103 * objects into the PDF document.
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
104 */
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
105 protected abstract void writePDF(OutputStream out);
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
106
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
107
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
108 /**
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 * This method enables concrete subclasses to collected its own special
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 * data.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 *
3270
4ac581062c40 Fix various documentation issues.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3223
diff changeset
112 * @param data The artifact that stores the data that has to be
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 * exported.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 */
701
dad1a2c88f9f Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 695
diff changeset
115 protected abstract void addData(Object data);
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116
3270
4ac581062c40 Fix various documentation issues.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3223
diff changeset
117
710
cded0924193d Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
118 @Override
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 public void init(Document request, OutputStream out, CallContext context) {
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 logger.debug("AbstractExporter.init");
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 this.request = request;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 this.out = out;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 this.context = context;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127
710
cded0924193d Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
128 @Override
412
046bd86ae41d Improved the OutGenerator interface to set a master artifact for the out generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 391
diff changeset
129 public void setMasterArtifact(Artifact master) {
046bd86ae41d Improved the OutGenerator interface to set a master artifact for the out generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 391
diff changeset
130 this.master = master;
046bd86ae41d Improved the OutGenerator interface to set a master artifact for the out generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 391
diff changeset
131 }
046bd86ae41d Improved the OutGenerator interface to set a master artifact for the out generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 391
diff changeset
132
5102
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
133 /** Get the callcontext that this exporter has been initialized
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
134 * with. */
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
135 public CallContext getCallContext() {
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
136 return this.context;
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
137 }
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
138
412
046bd86ae41d Improved the OutGenerator interface to set a master artifact for the out generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 391
diff changeset
139
3422
118fe1cc8cc8 OutGenerators got a setCollection() method; analogous to setMasterArtifact(). Registered the SQOverviewGenerator as OutGenerator for 'sq_overview' Output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3270
diff changeset
140 @Override
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
141 public void setCollection(D4EArtifactCollection collection) {
3422
118fe1cc8cc8 OutGenerators got a setCollection() method; analogous to setMasterArtifact(). Registered the SQOverviewGenerator as OutGenerator for 'sq_overview' Output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3270
diff changeset
142 this.collection = collection;
118fe1cc8cc8 OutGenerators got a setCollection() method; analogous to setMasterArtifact(). Registered the SQOverviewGenerator as OutGenerator for 'sq_overview' Output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3270
diff changeset
143 }
118fe1cc8cc8 OutGenerators got a setCollection() method; analogous to setMasterArtifact(). Registered the SQOverviewGenerator as OutGenerator for 'sq_overview' Output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3270
diff changeset
144
118fe1cc8cc8 OutGenerators got a setCollection() method; analogous to setMasterArtifact(). Registered the SQOverviewGenerator as OutGenerator for 'sq_overview' Output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3270
diff changeset
145
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 * This doOut() just collects the data of multiple artifacts. Therefore, it
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 * makes use of the addData() method which enables concrete subclasses to
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 * store its data on its own. The real output creation takes place in the
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 * concrete generate() methods.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 *
3270
4ac581062c40 Fix various documentation issues.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3223
diff changeset
152 * @param artifactFacet The artifact and facet.
4ac581062c40 Fix various documentation issues.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3223
diff changeset
153 * The facet to add - NOTE: the facet needs to fit to the first
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 * facet inserted into this exporter. Otherwise this artifact/facet is
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155 * skipped.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 * @param attr The attr document.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 */
710
cded0924193d Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
158 @Override
1684
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
159 public void doOut(
1944
21a4d2c677a1 Changed doOut signature, side effect from blackboard feature (to come).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
160 ArtifactAndFacet artifactFacet,
21a4d2c677a1 Changed doOut signature, side effect from blackboard feature (to come).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
161 Document attr,
21a4d2c677a1 Changed doOut signature, side effect from blackboard feature (to come).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
162 boolean visible
1684
bdb05dc9b763 Bugfix: #353 Enabled chart's to be drawn with proper axes set even if no data is contained.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
163 ) {
1944
21a4d2c677a1 Changed doOut signature, side effect from blackboard feature (to come).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
164 String name = artifactFacet.getFacetName();
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165
695
45cd58a2a2bb OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 445
diff changeset
166 logger.debug("AbstractExporter.doOut: " + name);
45cd58a2a2bb OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 445
diff changeset
167
45cd58a2a2bb OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 445
diff changeset
168 if (!isFacetValid(name)) {
45cd58a2a2bb OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 445
diff changeset
169 logger.warn("Facet '" + name + "' not valid. No output created!");
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170 return;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172
2038
f73036b991e2 Bugfix: repaired broken named values in exports - the last solution had bad side effects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2035
diff changeset
173 addData(artifactFacet.getData(context));
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 * Generates an export based on a specified facet.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 */
710
cded0924193d Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
180 @Override
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181 public void generate()
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 throws IOException
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 {
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184 logger.debug("AbstractExporter.generate");
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185
3217
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
186 if (facet == null) {
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
187 throw new IOException("invalid (null) facet for exporter");
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
188 }
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
189
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
190 if (facet.equals(FACET_CSV)) {
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191 generateCSV();
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192 }
3217
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
193 else if (facet.equals(FACET_PDF)) {
2176
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
194 generatePDF();
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
195 }
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
196 else {
3223
282c9da923ab FixA: flys/issue689: Export CSV for facet 'fix_parameters'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3217
diff changeset
197 throw new IOException(
282c9da923ab FixA: flys/issue689: Export CSV for facet 'fix_parameters'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3217
diff changeset
198 "invalid facet for exporter: '" + facet + "'");
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204 * Determines if the desired facet is valid for this exporter. If no facet
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 * is currently set, <i>facet</i> is set.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206 *
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207 * @param facet The desired facet.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208 *
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209 * @return true, if <i>facet</i> is valid, otherwise false.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 */
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 protected boolean isFacetValid(String facet) {
2284
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
212 logger.debug("AbstractExporter.isFacetValid : " + facet + " (" + getFacet() + ")" );
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213
445
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
214 String thisFacet = getFacet();
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
215
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
216 if (thisFacet == null || thisFacet.length() == 0) {
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217 return false;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218 }
445
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
219 else if (facet == null || facet.length() == 0) {
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
220 return false;
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
221 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
222 else {
445
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
223 return thisFacet.equals(facet);
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
224 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
226
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
227
445
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
228 /**
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
229 * Returns the name of the desired facet.
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
230 *
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
231 * @return the name of the desired facet.
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
232 */
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
233 protected String getFacet() {
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
234 if (facet == null) {
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
235 facet = getFacetFromRequest();
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
236 }
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
237
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
238 return facet;
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
239 }
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
240
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
241
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
242 /**
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
243 * Extracts the name of the requested facet from request document.
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
244 *
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
245 * @return the name of the requested facet.
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
246 */
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
247 protected String getFacetFromRequest() {
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
248 return XMLUtils.xpathString(
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
249 request, XPATH_FACET, ArtifactNamespaceContext.INSTANCE);
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
250 }
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
251
416
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 412
diff changeset
252
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 412
diff changeset
253 protected String msg(String key, String def) {
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 412
diff changeset
254 return Resources.getMsg(context.getMeta(), key, def);
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 412
diff changeset
255 }
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 412
diff changeset
256
5133
8e52b4829cd1 Fix flys/issue1228: Units in tabular calculation output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5111
diff changeset
257 protected String msg(String key, String def, Object[] args) {
8e52b4829cd1 Fix flys/issue1228: Units in tabular calculation output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5111
diff changeset
258 return Resources.getMsg(context.getMeta(), key, def, args);
8e52b4829cd1 Fix flys/issue1228: Units in tabular calculation output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5111
diff changeset
259 }
8e52b4829cd1 Fix flys/issue1228: Units in tabular calculation output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5111
diff changeset
260
416
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 412
diff changeset
261
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
262 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
263 * This method starts CSV creation. It makes use of writeCSVData() which has
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
264 * to be implemented by concrete subclasses.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
265 */
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
266 protected void generateCSV()
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
267 throws IOException
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
268 {
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
269 logger.info("AbstractExporter.generateCSV");
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
270
4910
a707ef048188 Insert CR and LF at the end of each line in CSV exports.
Raimund Renkert <rrenkert@intevation.de>
parents: 3422
diff changeset
271 char quote = '"';
a707ef048188 Insert CR and LF at the end of each line in CSV exports.
Raimund Renkert <rrenkert@intevation.de>
parents: 3422
diff changeset
272 char escape = '\\';
a707ef048188 Insert CR and LF at the end of each line in CSV exports.
Raimund Renkert <rrenkert@intevation.de>
parents: 3422
diff changeset
273
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
274 CSVWriter writer = new CSVWriter(
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
275 new OutputStreamWriter(
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
276 out,
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
277 DEFAULT_CSV_CHARSET),
4910
a707ef048188 Insert CR and LF at the end of each line in CSV exports.
Raimund Renkert <rrenkert@intevation.de>
parents: 3422
diff changeset
278 DEFAULT_CSV_SEPARATOR, quote, escape, "\r\n");
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
279
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
280 writeCSVData(writer);
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
281
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
282 writer.close();
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
283 }
1979
a7c437c9547e Added a getSettings() operation to OutGenerator - FLYSArtifactCollection will now evaluate all available Outputs and create initial Settings using OutGenerators if the Settings for an Output is missing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1948
diff changeset
284
a7c437c9547e Added a getSettings() operation to OutGenerator - FLYSArtifactCollection will now evaluate all available Outputs and create initial Settings using OutGenerators if the Settings for an Output is missing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1948
diff changeset
285
a7c437c9547e Added a getSettings() operation to OutGenerator - FLYSArtifactCollection will now evaluate all available Outputs and create initial Settings using OutGenerators if the Settings for an Output is missing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1948
diff changeset
286 /**
2176
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
287 * This method starts PDF creation.
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
288 */
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
289 protected void generatePDF()
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
290 throws IOException
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
291 {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
292 logger.info("AbstractExporter.generatePDF");
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
293 writePDF(this.out);
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
294 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
295
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
296
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
297 /**
1979
a7c437c9547e Added a getSettings() operation to OutGenerator - FLYSArtifactCollection will now evaluate all available Outputs and create initial Settings using OutGenerators if the Settings for an Output is missing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1948
diff changeset
298 * Returns an instance of <i>EmptySettings</i> currently!
a7c437c9547e Added a getSettings() operation to OutGenerator - FLYSArtifactCollection will now evaluate all available Outputs and create initial Settings using OutGenerators if the Settings for an Output is missing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1948
diff changeset
299 *
a7c437c9547e Added a getSettings() operation to OutGenerator - FLYSArtifactCollection will now evaluate all available Outputs and create initial Settings using OutGenerators if the Settings for an Output is missing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1948
diff changeset
300 * @return an instance of <i>EmptySettings</i>.
a7c437c9547e Added a getSettings() operation to OutGenerator - FLYSArtifactCollection will now evaluate all available Outputs and create initial Settings using OutGenerators if the Settings for an Output is missing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1948
diff changeset
301 */
a7c437c9547e Added a getSettings() operation to OutGenerator - FLYSArtifactCollection will now evaluate all available Outputs and create initial Settings using OutGenerators if the Settings for an Output is missing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1948
diff changeset
302 public Settings getSettings() {
a7c437c9547e Added a getSettings() operation to OutGenerator - FLYSArtifactCollection will now evaluate all available Outputs and create initial Settings using OutGenerators if the Settings for an Output is missing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1948
diff changeset
303 return new EmptySettings();
a7c437c9547e Added a getSettings() operation to OutGenerator - FLYSArtifactCollection will now evaluate all available Outputs and create initial Settings using OutGenerators if the Settings for an Output is missing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1948
diff changeset
304 }
2047
0318fa6f0844 Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2038
diff changeset
305
0318fa6f0844 Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2038
diff changeset
306
0318fa6f0844 Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2038
diff changeset
307 /**
0318fa6f0844 Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2038
diff changeset
308 * This method is not implemented. Override it in subclasses if those need a
0318fa6f0844 Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2038
diff changeset
309 * <i>Settings</i> object.
0318fa6f0844 Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2038
diff changeset
310 */
0318fa6f0844 Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2038
diff changeset
311 public void setSettings(Settings settings) {
0318fa6f0844 Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2038
diff changeset
312 // do nothing
0318fa6f0844 Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2038
diff changeset
313 }
2284
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
314
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
315
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
316 /**
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
317 * Returns the number formatter for kilometer values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
318 *
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
319 * @return the number formatter for kilometer values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
320 */
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
321 protected NumberFormat getKmFormatter() {
5111
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
322 if (kmFormat == null) {
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
323 kmFormat = Formatter.getWaterlevelKM(context);
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
324 }
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
325 return kmFormat;
2284
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
326 }
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
327
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
328
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
329 /**
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
330 * Returns the number formatter for W values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
331 *
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
332 * @return the number formatter for W values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
333 */
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
334 protected NumberFormat getWFormatter() {
5111
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
335 if (wFormat == null) {
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
336 wFormat = Formatter.getWaterlevelW(context);
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
337 }
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
338 return wFormat;
2284
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
339 }
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
340
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
341
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
342 /**
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
343 * Returns the number formatter for Q values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
344 *
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
345 * @return the number formatter for Q values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
346 */
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
347 protected NumberFormat getQFormatter() {
5111
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
348 if (qFormat == null) {
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
349 qFormat = Formatter.getWaterlevelQ(context);
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
350 }
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
351 return qFormat;
2284
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
352 }
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
353 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
354 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org