Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java @ 1738:6cdc7a77d3d4
Apply theme attributes to axis annotation.
flys-artifacts/trunk@3028 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 19 Oct 2011 11:39:46 +0000 |
parents | bdb05dc9b763 |
children | 21a4d2c677a1 |
rev | line source |
---|---|
391
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.exports; |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 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
|
4 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
|
5 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
|
6 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 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
|
8 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 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
|
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 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
|
12 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.artifacts.Artifact; |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.artifacts.CallContext; |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
695
45cd58a2a2bb
OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
445
diff
changeset
|
16 import de.intevation.artifactdatabase.state.Facet; |
45cd58a2a2bb
OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
445
diff
changeset
|
17 |
445
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
18 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
19 import de.intevation.artifacts.common.utils.XMLUtils; |
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
20 |
416
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
412
diff
changeset
|
21 import de.intevation.flys.artifacts.resources.Resources; |
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
412
diff
changeset
|
22 |
701
dad1a2c88f9f
Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
695
diff
changeset
|
23 import de.intevation.flys.artifacts.FLYSArtifact; |
dad1a2c88f9f
Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
695
diff
changeset
|
24 |
391
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 /** |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 * 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
|
28 * artifacts. |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 * |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 * @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
|
31 */ |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 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
|
33 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 /** 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
|
35 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
|
36 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
710
diff
changeset
|
38 /** 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
|
39 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
|
40 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
710
diff
changeset
|
41 /** 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
|
42 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
|
43 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
710
diff
changeset
|
44 /** 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
|
45 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
|
46 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
710
diff
changeset
|
47 /** 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
|
48 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
|
49 |
391
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
710
diff
changeset
|
51 /** 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
|
52 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
|
53 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
710
diff
changeset
|
54 /** 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
|
55 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
|
56 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
710
diff
changeset
|
57 /** 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
|
58 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
|
59 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
710
diff
changeset
|
60 /** 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
|
61 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
|
62 |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
710
diff
changeset
|
63 /** 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
|
64 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
|
65 |
391
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 /** |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 * 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
|
69 * 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
|
70 * |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 * @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
|
72 */ |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 protected abstract void writeCSVData(CSVWriter writer); |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 /** |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 * 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
|
78 * data. |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 * |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 * @param artifacts The artifact that stores the data that has to be |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 * exported. |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 */ |
701
dad1a2c88f9f
Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
695
diff
changeset
|
83 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
|
84 |
710
cded0924193d
Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
701
diff
changeset
|
85 @Override |
391
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 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
|
87 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
|
88 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 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
|
90 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
|
91 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
|
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 |
710
cded0924193d
Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
701
diff
changeset
|
95 @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
|
96 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
|
97 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
|
98 } |
046bd86ae41d
Improved the OutGenerator interface to set a master artifact for the out generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
99 |
046bd86ae41d
Improved the OutGenerator interface to set a master artifact for the out generation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
391
diff
changeset
|
100 |
391
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 * 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
|
103 * 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
|
104 * 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
|
105 * 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
|
106 * |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 * @param artifact The artifact. |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 * @param facet The facet to add - NOTE: the facet needs to fit to the first |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 * 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
|
110 * skipped. |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 * @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
|
112 */ |
710
cded0924193d
Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
701
diff
changeset
|
113 @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
|
114 public void doOut( |
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
|
115 Artifact artifact, |
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
|
116 Facet facet, |
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
|
117 Document attr, |
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
|
118 boolean visible |
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
|
119 ) { |
695
45cd58a2a2bb
OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
445
diff
changeset
|
120 String name = facet.getName(); |
391
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 |
695
45cd58a2a2bb
OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
445
diff
changeset
|
122 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
|
123 |
45cd58a2a2bb
OutGenerators doOut() takes a facet object now instead of just its name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
445
diff
changeset
|
124 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
|
125 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
|
126 return; |
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 |
701
dad1a2c88f9f
Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
695
diff
changeset
|
129 FLYSArtifact flys = (FLYSArtifact)artifact; |
dad1a2c88f9f
Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
695
diff
changeset
|
130 |
dad1a2c88f9f
Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
695
diff
changeset
|
131 Facet nativeFacet = flys.getNativeFacet(facet); |
dad1a2c88f9f
Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
695
diff
changeset
|
132 |
dad1a2c88f9f
Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
695
diff
changeset
|
133 if (nativeFacet != null) { |
dad1a2c88f9f
Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
695
diff
changeset
|
134 addData(nativeFacet.getData(flys, context)); |
dad1a2c88f9f
Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
695
diff
changeset
|
135 } |
391
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
136 } |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
137 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 |
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 * 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
|
141 */ |
710
cded0924193d
Added generator and facet for error reports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
701
diff
changeset
|
142 @Override |
391
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
143 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
|
144 throws IOException |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 { |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 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
|
147 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
148 if (facet != null && facet.equals(FACET_CSV)) { |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 generateCSV(); |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 } |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 else { |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 throw new IOException("invalid facet for exporter."); |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 } |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 } |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 /** |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 * 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
|
159 * 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
|
160 * |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 * @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
|
162 * |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 * @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
|
164 */ |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 protected boolean isFacetValid(String facet) { |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 logger.debug("AbstractExporter.isFacetValid"); |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 |
445
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
168 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
|
169 |
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
170 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
|
171 return false; |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 } |
445
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
173 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
|
174 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
|
175 } |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 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
|
177 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
|
178 } |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 } |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
181 |
445
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
182 /** |
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
183 * 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
|
184 * |
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
185 * @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
|
186 */ |
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
187 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
|
188 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
|
189 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
|
190 } |
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
191 |
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
192 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
|
193 } |
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
194 |
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
195 |
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
196 /** |
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
197 * 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
|
198 * |
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
199 * @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
|
200 */ |
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
201 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
|
202 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
|
203 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
|
204 } |
a7947972fdeb
Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
418
diff
changeset
|
205 |
416
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
412
diff
changeset
|
206 |
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
412
diff
changeset
|
207 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
|
208 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
|
209 } |
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
412
diff
changeset
|
210 |
340dc41a7ea3
The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
412
diff
changeset
|
211 |
391
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
212 /** |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
213 * 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
|
214 * 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
|
215 */ |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
216 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
|
217 throws IOException |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
218 { |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
219 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
|
220 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
221 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
|
222 new OutputStreamWriter( |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
223 out, |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
224 DEFAULT_CSV_CHARSET), |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
225 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
|
226 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
227 writeCSVData(writer); |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
228 |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
229 writer.close(); |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
230 } |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
231 } |
5d6988836f01
Added an exporter to export the computed data of a duration curve.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
232 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |