annotate artifacts/src/main/java/org/dive4elements/river/exports/AbstractExporter.java @ 6905:1b35b2ddfc28

Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 22 Aug 2013 23:31:38 +0200
parents af13ceeba52a
children e61bb712ee41 5c6fd2c010dd
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
6905
1b35b2ddfc28 Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
35 import org.dive4elements.river.themes.ThemeDocument;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5133
diff changeset
36 import org.dive4elements.river.utils.Formatter;
2284
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
37
391
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 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 * 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
41 * artifacts.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 *
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 * @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
44 */
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 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
46
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 /** 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
48 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
49
3223
282c9da923ab FixA: flys/issue689: Export CSV for facet 'fix_parameters'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3217
diff changeset
50 /* 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
51 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
52
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
53 /** 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
54 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
55
2176
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
56 /** The name of the PDF facet which triggers the PDF creation. */
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
57 public static final String FACET_PDF = "pdf";
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
58
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
59 /** 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
60 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
61
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
62 /** 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
63 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
64
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
65 /** 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
66 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
67
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
68 /** 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
69 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
70
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
71 /** 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
72 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
73
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
74 /** 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
75 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
76
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
77 /** 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
78 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
79
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
80 /** The collection.*/
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
81 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
82
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
83 /** 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
84 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
85
5111
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
86 private NumberFormat kmFormat;
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
87
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
88 private NumberFormat wFormat;
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
89
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
90 private NumberFormat qFormat;
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
91
391
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 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 * 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
95 * 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
96 *
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 * @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
98 */
2792
fe987587ebc9 Merged revisions 4539-4540,4543,4545-4546 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2284
diff changeset
99 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
100
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 /**
2176
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
103 * 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
104 * objects into the PDF document.
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
105 */
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
106 protected abstract void writePDF(OutputStream out);
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
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
109 /**
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 * 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
111 * data.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 *
3270
4ac581062c40 Fix various documentation issues.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3223
diff changeset
113 * @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
114 * exported.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 */
701
dad1a2c88f9f Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 695
diff changeset
116 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
117
3270
4ac581062c40 Fix various documentation issues.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3223
diff changeset
118
710
cded0924193d Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
119 @Override
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 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
121 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
122
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 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
124 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
125 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
126 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128
710
cded0924193d Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
129 @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
130 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
131 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
132 }
046bd86ae41d Improved the OutGenerator interface to set a master artifact for the out generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 391
diff changeset
133
5102
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
134 /** 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
135 * with. */
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
136 public CallContext getCallContext() {
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
137 return this.context;
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
138 }
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
139
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
140
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
141 @Override
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
142 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
143 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
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
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
146
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 * 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
149 * 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
150 * 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
151 * 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
152 *
3270
4ac581062c40 Fix various documentation issues.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3223
diff changeset
153 * @param artifactFacet The artifact and facet.
4ac581062c40 Fix various documentation issues.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3223
diff changeset
154 * 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
155 * 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
156 * skipped.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 * @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
158 */
710
cded0924193d Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
159 @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
160 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
161 ArtifactAndFacet artifactFacet,
6905
1b35b2ddfc28 Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
162 ThemeDocument attr,
1944
21a4d2c677a1 Changed doOut signature, side effect from blackboard feature (to come).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
163 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
164 ) {
1944
21a4d2c677a1 Changed doOut signature, side effect from blackboard feature (to come).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
165 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
166
695
45cd58a2a2bb OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 445
diff changeset
167 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
168
45cd58a2a2bb OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 445
diff changeset
169 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
170 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
171 return;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173
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
174 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
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 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 * 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
180 */
710
cded0924193d Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
181 @Override
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 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
183 throws IOException
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184 {
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185 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
186
3217
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
187 if (facet == null) {
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
188 throw new IOException("invalid (null) facet for exporter");
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
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
191 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
192 generateCSV();
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193 }
3217
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
194 else if (facet.equals(FACET_PDF)) {
2176
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
195 generatePDF();
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
196 }
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
197 else {
3223
282c9da923ab FixA: flys/issue689: Export CSV for facet 'fix_parameters'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3217
diff changeset
198 throw new IOException(
282c9da923ab FixA: flys/issue689: Export CSV for facet 'fix_parameters'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3217
diff changeset
199 "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
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 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 * 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
206 * 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
207 *
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208 * @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
209 *
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 * @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
211 */
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 protected boolean isFacetValid(String facet) {
2284
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
213 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
214
445
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
215 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
216
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
217 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
218 return false;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
219 }
445
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
220 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
221 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
222 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
223 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
224 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
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
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
228
445
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
229 /**
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
230 * 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
231 *
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
232 * @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
233 */
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
234 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
235 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
236 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
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
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
239 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
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 /**
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
244 * 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
245 *
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
246 * @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
247 */
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
248 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
249 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
250 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
251 }
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
252
416
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 412
diff changeset
253
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 412
diff changeset
254 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
255 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
256 }
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 412
diff changeset
257
5133
8e52b4829cd1 Fix flys/issue1228: Units in tabular calculation output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5111
diff changeset
258 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
259 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
260 }
8e52b4829cd1 Fix flys/issue1228: Units in tabular calculation output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5111
diff changeset
261
416
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 412
diff changeset
262
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
263 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
264 * 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
265 * 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
266 */
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
267 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
268 throws IOException
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
269 {
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
270 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
271
4910
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 quote = '"';
a707ef048188 Insert CR and LF at the end of each line in CSV exports.
Raimund Renkert <rrenkert@intevation.de>
parents: 3422
diff changeset
273 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
274
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
275 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
276 new OutputStreamWriter(
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
277 out,
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
278 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
279 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
280
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
281 writeCSVData(writer);
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
282
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
283 writer.close();
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
284 }
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
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
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
287 /**
2176
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
288 * This method starts PDF creation.
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
289 */
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
290 protected void generatePDF()
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
291 throws IOException
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
292 {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
293 logger.info("AbstractExporter.generatePDF");
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
294 writePDF(this.out);
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
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
298 /**
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
299 * 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
300 *
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 * @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
302 */
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 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
304 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
305 }
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
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 /**
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 * 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
310 * <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
311 */
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 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
313 // 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
314 }
2284
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 /**
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
318 * Returns the number formatter for kilometer values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
319 *
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
320 * @return the number formatter for kilometer values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
321 */
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
322 protected NumberFormat getKmFormatter() {
5111
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
323 if (kmFormat == null) {
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
324 kmFormat = Formatter.getWaterlevelKM(context);
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
325 }
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
326 return kmFormat;
2284
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 /**
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
331 * Returns the number formatter for W values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
332 *
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
333 * @return the number formatter for W values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
334 */
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
335 protected NumberFormat getWFormatter() {
5111
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
336 if (wFormat == null) {
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
337 wFormat = Formatter.getWaterlevelW(context);
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
338 }
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
339 return wFormat;
2284
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 /**
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
344 * Returns the number formatter for Q values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
345 *
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
346 * @return the number formatter for Q values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
347 */
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
348 protected NumberFormat getQFormatter() {
5111
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
349 if (qFormat == null) {
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
350 qFormat = Formatter.getWaterlevelQ(context);
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
351 }
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
352 return qFormat;
2284
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
353 }
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
354 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
355 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org