annotate artifacts/src/main/java/org/dive4elements/river/exports/AbstractExporter.java @ 7936:5ef60ed15c25

So you do not need to type every string twice.
author Tom Gottfried <tom@intevation.de>
date Tue, 17 Jun 2014 17:50:59 +0200
parents 3c7471b929d1
children a310b1f85ce0
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. */
7035
e61bb712ee41 issue971: Change CSV column separator to ";" for Exports, client-side change follows.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6905
diff changeset
63 public static final char DEFAULT_CSV_SEPARATOR = ';';
391
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
7077
0a337f0005c2 Extended init() of OutGenerator to take name of the out to serve.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7037
diff changeset
68 /** The out name to serve. */
0a337f0005c2 Extended init() of OutGenerator to take name of the out to serve.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7037
diff changeset
69 protected String outName;
0a337f0005c2 Extended init() of OutGenerator to take name of the out to serve.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7037
diff changeset
70
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
71 /** 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
72 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
73
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
74 /** 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
75 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
76
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
77 /** 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
78 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
79
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
80 /** 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
81 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
82
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
83 /** The collection.*/
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
84 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
85
1160
efe1b8545f5c Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 710
diff changeset
86 /** 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
87 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
88
5111
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
89 private NumberFormat kmFormat;
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
90
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
91 private NumberFormat wFormat;
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
92
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
93 private NumberFormat qFormat;
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
94
391
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 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 * 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
98 * 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
99 *
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 * @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
101 */
2792
fe987587ebc9 Merged revisions 4539-4540,4543,4545-4546 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2284
diff changeset
102 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
103
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 /**
2176
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
106 * 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
107 * objects into the PDF document.
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 protected abstract void writePDF(OutputStream out);
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
110
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
111
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
112 /**
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 * 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
114 * data.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 *
3270
4ac581062c40 Fix various documentation issues.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3223
diff changeset
116 * @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
117 * exported.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 */
701
dad1a2c88f9f Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 695
diff changeset
119 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
120
7087
ada424214b02 Use Object instead of DOM Element as argument for setup of out generators. First step to remove dependency to XML DOM when using configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7077
diff changeset
121 public void setup(Object config) {
7037
5c6fd2c010dd Add setup(Element config) method to Generator interface to be initialized from configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6905
diff changeset
122 logger.debug("AbstractExporter.setup");
5c6fd2c010dd Add setup(Element config) method to Generator interface to be initialized from configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6905
diff changeset
123 }
5c6fd2c010dd Add setup(Element config) method to Generator interface to be initialized from configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6905
diff changeset
124
3270
4ac581062c40 Fix various documentation issues.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3223
diff changeset
125
710
cded0924193d Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
126 @Override
7077
0a337f0005c2 Extended init() of OutGenerator to take name of the out to serve.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7037
diff changeset
127 public void init(
0a337f0005c2 Extended init() of OutGenerator to take name of the out to serve.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7037
diff changeset
128 String outName,
0a337f0005c2 Extended init() of OutGenerator to take name of the out to serve.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7037
diff changeset
129 Document request,
0a337f0005c2 Extended init() of OutGenerator to take name of the out to serve.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7037
diff changeset
130 OutputStream out,
0a337f0005c2 Extended init() of OutGenerator to take name of the out to serve.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7037
diff changeset
131 CallContext context
0a337f0005c2 Extended init() of OutGenerator to take name of the out to serve.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7037
diff changeset
132 ) {
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133 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
134
7077
0a337f0005c2 Extended init() of OutGenerator to take name of the out to serve.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7037
diff changeset
135 this.outName = outName;
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 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
137 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
138 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
139 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141
710
cded0924193d Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
142 @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
143 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
144 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
145 }
046bd86ae41d Improved the OutGenerator interface to set a master artifact for the out generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 391
diff changeset
146
5102
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
147 /** 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
148 * with. */
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
149 public CallContext getCallContext() {
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
150 return this.context;
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
151 }
baf51f820838 AbstractExporter: Added getter for CallContext.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4910
diff changeset
152
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
153
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
154 @Override
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
155 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
156 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
157 }
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
158
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
159
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161 * 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
162 * 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
163 * 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
164 * 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
165 *
3270
4ac581062c40 Fix various documentation issues.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3223
diff changeset
166 * @param artifactFacet The artifact and facet.
4ac581062c40 Fix various documentation issues.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3223
diff changeset
167 * 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
168 * 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
169 * skipped.
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170 * @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
171 */
710
cded0924193d Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
172 @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
173 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
174 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
175 ThemeDocument attr,
1944
21a4d2c677a1 Changed doOut signature, side effect from blackboard feature (to come).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
176 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
177 ) {
1944
21a4d2c677a1 Changed doOut signature, side effect from blackboard feature (to come).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
178 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
179
695
45cd58a2a2bb OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 445
diff changeset
180 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
181
45cd58a2a2bb OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 445
diff changeset
182 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
183 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
184 return;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
186
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
187 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
188 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192 * 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
193 */
710
cded0924193d Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
194 @Override
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
195 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
196 throws IOException
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
197 {
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198 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
199
3217
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
200 if (facet == null) {
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
201 throw new IOException("invalid (null) facet for exporter");
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
202 }
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
203
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
204 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
205 generateCSV();
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206 }
3217
79dd823733e2 FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2792
diff changeset
207 else if (facet.equals(FACET_PDF)) {
2176
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
208 generatePDF();
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
209 }
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 else {
3223
282c9da923ab FixA: flys/issue689: Export CSV for facet 'fix_parameters'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3217
diff changeset
211 throw new IOException(
282c9da923ab FixA: flys/issue689: Export CSV for facet 'fix_parameters'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3217
diff changeset
212 "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
213 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217 /**
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218 * 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
219 * 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
220 *
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
221 * @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
222 *
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
223 * @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
224 */
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225 protected boolean isFacetValid(String facet) {
2284
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
226 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
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 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
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 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
231 return false;
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
232 }
445
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
233 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
234 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
235 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
236 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
237 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
238 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
239 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
240
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
241
445
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 * 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
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 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
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 getFacet() {
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
248 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
249 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
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
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
252 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
253 }
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
254
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
255
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
256 /**
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
257 * 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
258 *
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
259 * @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
260 */
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
261 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
262 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
263 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
264 }
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
265
7936
5ef60ed15c25 So you do not need to type every string twice.
Tom Gottfried <tom@intevation.de>
parents: 7116
diff changeset
266 protected String msg(String key) {
5ef60ed15c25 So you do not need to type every string twice.
Tom Gottfried <tom@intevation.de>
parents: 7116
diff changeset
267 return Resources.getMsg(context.getMeta(), key, key);
5ef60ed15c25 So you do not need to type every string twice.
Tom Gottfried <tom@intevation.de>
parents: 7116
diff changeset
268 }
416
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 412
diff changeset
269
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 412
diff changeset
270 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
271 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
272 }
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 412
diff changeset
273
5133
8e52b4829cd1 Fix flys/issue1228: Units in tabular calculation output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5111
diff changeset
274 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
275 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
276 }
8e52b4829cd1 Fix flys/issue1228: Units in tabular calculation output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5111
diff changeset
277
416
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 412
diff changeset
278
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 * 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
281 * 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
282 */
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
283 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
284 throws IOException
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
285 {
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
286 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
287
4910
a707ef048188 Insert CR and LF at the end of each line in CSV exports.
Raimund Renkert <rrenkert@intevation.de>
parents: 3422
diff changeset
288 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
289 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
290
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
291 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
292 new OutputStreamWriter(
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
293 out,
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
294 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
295 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
296
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
297 writeCSVData(writer);
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
298
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
299 writer.close();
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
300 }
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
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
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 /**
2176
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
304 * This method starts PDF creation.
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
305 */
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
306 protected void generatePDF()
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
307 throws IOException
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
308 {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
309 logger.info("AbstractExporter.generatePDF");
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
310 writePDF(this.out);
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
311 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
312
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
313
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2047
diff changeset
314 /**
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
315 * 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
316 *
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
317 * @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
318 */
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
319 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
320 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
321 }
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
322
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
323
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
324 /**
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
325 * 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
326 * <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
327 */
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
328 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
329 // 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
330 }
2284
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
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 * Returns the number formatter for kilometer values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
335 *
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
336 * @return the number formatter for kilometer values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
337 */
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
338 protected NumberFormat getKmFormatter() {
5111
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
339 if (kmFormat == null) {
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
340 kmFormat = Formatter.getWaterlevelKM(context);
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
341 }
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
342 return kmFormat;
2284
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
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 /**
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
347 * Returns the number formatter for W values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
348 *
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
349 * @return the number formatter for W values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
350 */
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
351 protected NumberFormat getWFormatter() {
5111
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
352 if (wFormat == null) {
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
353 wFormat = Formatter.getWaterlevelW(context);
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
354 }
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
355 return wFormat;
2284
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
356 }
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
357
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
358
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
359 /**
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
360 * Returns the number formatter for Q values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
361 *
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
362 * @return the number formatter for Q values.
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
363 */
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
364 protected NumberFormat getQFormatter() {
5111
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
365 if (qFormat == null) {
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
366 qFormat = Formatter.getWaterlevelQ(context);
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
367 }
4898376c680b AbstractExporter: keep km-, w- and q-formatter instances.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5102
diff changeset
368 return qFormat;
2284
5d1ba04d2f68 Refactored Formatter access to ease reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2176
diff changeset
369 }
391
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
370 }
5d6988836f01 Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
371 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org