Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java @ 2047:0318fa6f0844
Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
flys-artifacts/trunk@3535 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 23 Dec 2011 08:57:25 +0000 |
parents | a7c437c9547e |
children | 118fe1cc8cc8 |
rev | line source |
---|---|
730
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.exports; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import java.io.OutputStream; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 import java.io.OutputStreamWriter; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import java.io.IOException; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import org.w3c.dom.Document; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 import org.apache.log4j.Logger; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifacts.Artifact; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.CallContext; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
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
|
14 import de.intevation.artifactdatabase.state.ArtifactAndFacet; |
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
|
15 import de.intevation.artifactdatabase.state.Settings; |
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
|
16 |
730
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.flys.artifacts.FLYSArtifact; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.flys.artifacts.model.WQ; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
1658
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
730
diff
changeset
|
21 import de.intevation.flys.utils.FLYSUtils; |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
730
diff
changeset
|
22 |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
730
diff
changeset
|
23 |
730
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 public class ATExporter |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 implements OutGenerator |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 { |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 private static Logger logger = Logger.getLogger(ATExporter.class); |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 public static final String DEFAULT_ENCODING = "UTF-8"; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 protected WQ data; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 protected CallContext context; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 protected OutputStream out; |
1658
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
730
diff
changeset
|
34 protected FLYSArtifact master; |
730
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 public ATExporter() { |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 } |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 @Override |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 public void init(Document request, OutputStream out, CallContext context) { |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 this.context = context; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 this.out = out; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 } |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 @Override |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 public void setMasterArtifact(Artifact master) { |
1658
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
730
diff
changeset
|
47 this.master = (FLYSArtifact) master; |
730
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 } |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 @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:
1658
diff
changeset
|
51 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
|
52 ArtifactAndFacet artifactf, |
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:
1658
diff
changeset
|
53 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:
1658
diff
changeset
|
54 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:
1658
diff
changeset
|
55 ) { |
1944
21a4d2c677a1
Changed doOut signature, side effect from blackboard feature (to come).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1684
diff
changeset
|
56 data = (WQ)artifactf.getData(context); |
730
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 } |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 @Override |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 public void generate() throws IOException { |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 if (data == null) { |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 logger.debug("no W/Q data"); |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 return; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 } |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 ATWriter at; |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 try { |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 at = new ATWriter(data); |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 } |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 catch (IllegalArgumentException iae) { |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 logger.error("creating ATWriter failed", iae); |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 throw new IOException(iae); |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 } |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 |
1658
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
730
diff
changeset
|
76 String river = FLYSUtils.getRiver(master).getName(); |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
730
diff
changeset
|
77 double[] kms = FLYSUtils.getLocations(master); |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
730
diff
changeset
|
78 |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
730
diff
changeset
|
79 at.write( |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
730
diff
changeset
|
80 new OutputStreamWriter(out, DEFAULT_ENCODING), |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
730
diff
changeset
|
81 context.getMeta(), |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
730
diff
changeset
|
82 river, |
7d11ad5a52d5
Bugfix: #332 Made AT-exports compatible with desktop FLYS.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
730
diff
changeset
|
83 kms[0]); |
730
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 } |
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
|
85 |
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
|
86 |
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
|
87 /** |
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
|
88 * 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
|
89 * |
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
|
90 * @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
|
91 */ |
2047
0318fa6f0844
Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1979
diff
changeset
|
92 @Override |
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
|
93 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
|
94 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
|
95 } |
2047
0318fa6f0844
Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1979
diff
changeset
|
96 |
0318fa6f0844
Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1979
diff
changeset
|
97 |
0318fa6f0844
Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1979
diff
changeset
|
98 /** |
0318fa6f0844
Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1979
diff
changeset
|
99 * This method is not implemented! |
0318fa6f0844
Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1979
diff
changeset
|
100 * |
0318fa6f0844
Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1979
diff
changeset
|
101 * @param settings A settings object. |
0318fa6f0844
Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1979
diff
changeset
|
102 */ |
0318fa6f0844
Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1979
diff
changeset
|
103 @Override |
0318fa6f0844
Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1979
diff
changeset
|
104 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:
1979
diff
changeset
|
105 // do nothing here |
0318fa6f0844
Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1979
diff
changeset
|
106 } |
730
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 } |
97d774d58e24
Added exporter for AT facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |