annotate artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java @ 7640:b7690b485439

flys/issue1638: Calculate ntot correctly.
author Sascha L. Teichmann <teichmann@intevation.de>
date Tue, 03 Dec 2013 16:44:20 +0100
parents d8d0caaf60a2
children 5ef60ed15c25
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: 5863
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: 5863
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: 3552
diff changeset
9 package org.dive4elements.river.exports.sq;
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import java.io.OutputStream;
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import java.util.ArrayList;
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import java.util.List;
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
14 import java.util.Map;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
15 import java.util.HashMap;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
16 import java.util.Date;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
17 import java.util.Locale;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
18 import java.text.DateFormat;
6828
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
19 import java.text.NumberFormat;
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
21 import net.sf.jasperreports.engine.JasperExportManager;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
22 import net.sf.jasperreports.engine.JasperFillManager;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
23 import net.sf.jasperreports.engine.JasperPrint;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
24 import net.sf.jasperreports.engine.JRException;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
25
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 import au.com.bytecode.opencsv.CSVWriter;
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
28 import org.dive4elements.artifacts.CallMeta;
3392
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
29
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3552
diff changeset
30 import org.dive4elements.river.artifacts.model.CalculationResult;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3552
diff changeset
31 import org.dive4elements.river.artifacts.model.sq.SQFractionResult;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3552
diff changeset
32 import org.dive4elements.river.artifacts.model.sq.SQResult;
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
33 import org.dive4elements.river.artifacts.model.sq.SQRelationJRDataSource;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3552
diff changeset
34 import org.dive4elements.river.artifacts.model.Parameters;
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
35 import org.dive4elements.river.artifacts.model.DateRange;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
36 import org.dive4elements.river.artifacts.access.SQRelationAccess;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
37
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
38 import org.dive4elements.river.artifacts.resources.Resources;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
39
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
40 import org.dive4elements.river.artifacts.D4EArtifact;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3552
diff changeset
41
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3552
diff changeset
42 import org.dive4elements.river.exports.AbstractExporter;
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
44 import org.dive4elements.river.utils.RiverUtils;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
45 import org.dive4elements.river.utils.Formatter;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
46
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
47 import org.dive4elements.artifacts.common.utils.Config;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
48
3392
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
49 import org.apache.log4j.Logger;
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 /**
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 */
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 public class SQRelationExporter extends AbstractExporter {
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 /** Private logger. */
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 private static final Logger logger =
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 Logger.getLogger(SQRelationExporter.class);
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 public static final String CSV_PARAMETER =
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 "export.sqrelation.csv.header.parameter";
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 public static final String CSV_STATION =
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 "export.sqrelation.csv.header.station";
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 public static final String CSV_KM =
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 "export.sqrelation.csv.header.km";
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 public static final String CSV_FUNCTION =
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 "export.sqrelation.csv.header.function";
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 public static final String CSV_GAUGE =
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 "export.sqrelation.csv.header.gauge";
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 public static final String CSV_COEFF_A =
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 "export.sqrelation.csv.header.coeff.a";
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 public static final String CSV_COEFF_B =
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 "export.sqrelation.csv.header.coeff.b";
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 public static final String CSV_COEFF_Q =
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 "export.sqrelation.csv.header.coeff.q";
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 public static final String CSV_COEFF_R =
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 "export.sqrelation.csv.header.coeff.r";
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 public static final String CSV_N_TOTAL =
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 "export.sqrelation.csv.header.n.total";
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 public static final String CSV_N_OUTLIERS =
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 "export.sqrelation.csv.header.n.outliers";
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 public static final String CSV_C_DUAN =
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 "export.sqrelation.csv.header.c.duan";
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 public static final String CSV_C_FERGUSON =
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 "export.sqrelation.csv.header.c.ferguson";
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99
6828
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
100 public static final String CSV_QMAX =
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
101 "export.sqrelation.csv.header.qmax";
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
102
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
103 public static final String CSV_SD =
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
104 "export.sqrelation.csv.header.sd";
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
106 public static final String PDF_TITLE=
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
107 "export.sqrelation.pdf.title";
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
108
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
109 public static final String PDF_HEADER_MODE =
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
110 "export.sqrelation.pdf.mode";
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
111
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
112 public static final String JASPER_FILE =
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
113 "export.sqrelation.pdf.file";
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114
3392
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
115 protected List<SQResult []> data;
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116
7077
0a337f0005c2 Extended init() of OutGenerator to take name of the out to serve.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6859
diff changeset
117 public SQRelationExporter() {
3392
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
118 data = new ArrayList<SQResult []>();
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 }
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 @Override
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 protected void addData(Object d) {
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 if (d instanceof CalculationResult) {
3392
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
124 d = ((CalculationResult)d).getData();
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
125 if (d instanceof SQResult []) {
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
126 data.add((SQResult [])d);
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 }
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128 }
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129 }
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130
3392
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
131 protected void writeCSVHeader(CSVWriter writer) {
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
132 writer.writeNext(new String[] {
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
133 msg(CSV_KM , CSV_KM),
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
134 msg(CSV_PARAMETER, CSV_PARAMETER),
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
135 msg(CSV_COEFF_A , CSV_COEFF_A),
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
136 msg(CSV_COEFF_B , CSV_COEFF_B),
6828
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
137 msg(CSV_SD, CSV_SD),
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
138 msg(CSV_QMAX, CSV_QMAX),
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
139 msg(CSV_COEFF_R, CSV_COEFF_R),
3392
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
140 msg(CSV_N_TOTAL , CSV_N_TOTAL),
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
141 msg(CSV_N_OUTLIERS, CSV_N_OUTLIERS),
6828
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
142 msg(CSV_C_DUAN, CSV_C_DUAN),
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
143 msg(CSV_C_FERGUSON, CSV_C_FERGUSON)
3392
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
144 });
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
145 }
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 @Override
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 protected void writeCSVData(CSVWriter writer) {
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 logger.debug("writeCSVData");
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 writeCSVHeader(writer);
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152
3392
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
153 for (SQResult [] results: data) {
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
154 for (SQResult result: results) {
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
155 writer.writeAll(data2StringArrays(result));
3392
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
156 }
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 }
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 }
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
160 protected List<String[]> data2StringArrays(SQResult result) {
6322
8c976bb0362f Add SQ Relation KM formatter and use it fopr issue 1071
Andre Heinecke <aheinecke@intevation.de>
parents: 6207
diff changeset
161 String km = Formatter.getSQRelationKM(context
8c976bb0362f Add SQ Relation KM formatter and use it fopr issue 1071
Andre Heinecke <aheinecke@intevation.de>
parents: 6207
diff changeset
162 ).format(result.getKm());
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
163 List<String[]> retval = new ArrayList<String[]>();
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164
6828
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
165 NumberFormat sqAFormatter = Formatter.getSQRelationA(context);
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
166 NumberFormat sqBFormatter = Formatter.getSQRelationB(context);
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
167 NumberFormat fThreeFormatter = Formatter.getFormatter(context, 3, 3);
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
168 NumberFormat fTwoFormatter = Formatter.getFormatter(context, 2, 2);
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
169 NumberFormat fZeroFormatter = Formatter.getFormatter(context, 0, 0);
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
170
3392
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
171 for (int i = 0; i < SQResult.NUMBER_FRACTIONS; ++i) {
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
172 SQFractionResult fraction = result.getFraction(i);
3552
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3392
diff changeset
173
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3392
diff changeset
174 String name = result.getFractionName(i);
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3392
diff changeset
175
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3392
diff changeset
176 Parameters parameters = fraction.getParameters();
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3392
diff changeset
177
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3392
diff changeset
178 if (parameters == null) {
3392
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
179 continue;
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
180 }
3552
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3392
diff changeset
181
6828
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
182 String a, b, sd, o, t, max_q, c_ferguson, c_duan, r2;
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
183 a = sqAFormatter.format(parameters.getValue(0, "a"));
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
184 b = sqBFormatter.format(parameters.getValue(0, "b"));
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
185
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
186 /* The std_dev parameter contains the standard error actually */
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
187 sd = fThreeFormatter.format(parameters.getValue(0, "std_dev"));
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
188 max_q = fZeroFormatter.format(parameters.getValue(0, "max_q"));
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
189 c_ferguson = fTwoFormatter.format(parameters.getValue(0, "c_ferguson"));
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
190 c_duan = fTwoFormatter.format(parameters.getValue(0, "c_duan"));
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
191 r2 = fTwoFormatter.format(parameters.getValue(0, "r2"));
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
192
3552
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3392
diff changeset
193
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
194 o = String.valueOf(fraction.totalNumOutliers());
7640
b7690b485439 flys/issue1638: Calculate ntot correctly.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7380
diff changeset
195 t = String.valueOf(fraction.numMeasurements());
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
196
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
197 retval.add(new String[] {
3392
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
198 km,
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
199 name,
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
200 a,
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
201 b,
6828
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
202 sd, // 4
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
203 max_q, // 5
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
204 r2, // 6
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
205 t, // 7
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
206 o, // 8
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
207 c_duan, // 9
708416bb560c (issue1347) Add new variables to SQ Relation output.
Andre Heinecke <aheinecke@intevation.de>
parents: 6322
diff changeset
208 c_ferguson // 10
3392
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
209 });
56f62b5209f5 S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
210 }
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
211 return retval;
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 }
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
215 protected SQRelationJRDataSource createJRData() {
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
216 SQRelationJRDataSource source = new SQRelationJRDataSource();
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
217
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
218 addMetaData(source);
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
219 for (SQResult [] results: data) {
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
220 for (SQResult result: results) {
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
221 for (String[] res: data2StringArrays(result)) {
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
222 source.addData(res);
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
223 }
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
224 }
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
225 }
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
226 return source;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
227 }
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
228
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
229 protected void addMetaData(SQRelationJRDataSource source) {
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
230 CallMeta meta = context.getMeta();
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
231
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
232 D4EArtifact arti = (D4EArtifact) master;
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
233
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
234 source.addMetaData ("river", RiverUtils.getRivername(arti));
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
235
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
236 Locale locale = Resources.getLocale(meta);
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
237 DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
238
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
239 source.addMetaData("date", df.format(new Date()));
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
240
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
241 SQRelationAccess access = new SQRelationAccess(arti);
6175
6a04081a2f69 Add unit to location and translate outliertest method
Andre Heinecke <aheinecke@intevation.de>
parents: 6172
diff changeset
242 source.addMetaData("location", "KM " + getKmFormatter().format(access.getLocation()));
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
243
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
244 DateRange period = access.getPeriod();
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
245 source.addMetaData("periods", df.format(period.getFrom()) + " - " +
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
246 df.format(period.getTo()));
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
247
6175
6a04081a2f69 Add unit to location and translate outliertest method
Andre Heinecke <aheinecke@intevation.de>
parents: 6172
diff changeset
248 source.addMetaData("outliertest", Resources.getMsg(meta,
6a04081a2f69 Add unit to location and translate outliertest method
Andre Heinecke <aheinecke@intevation.de>
parents: 6172
diff changeset
249 access.getOutlierMethod(),
6a04081a2f69 Add unit to location and translate outliertest method
Andre Heinecke <aheinecke@intevation.de>
parents: 6172
diff changeset
250 access.getOutlierMethod()));
6830
eb4b123daaf7 (issue1347) Localize outliers and pdf Header
Andre Heinecke <aheinecke@intevation.de>
parents: 6828
diff changeset
251 source.addMetaData("outliers", Formatter.getRawFormatter(context).format(
eb4b123daaf7 (issue1347) Localize outliers and pdf Header
Andre Heinecke <aheinecke@intevation.de>
parents: 6828
diff changeset
252 access.getOutliers()));
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
253
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
254 source.addMetaData("calculation", Resources.getMsg(
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
255 locale,
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
256 PDF_HEADER_MODE,
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
257 "SQRelation"));
6859
3ccbc278f2e6 (issue1347) Add SQ Relation fields for measurement station information
Andre Heinecke <aheinecke@intevation.de>
parents: 6830
diff changeset
258
3ccbc278f2e6 (issue1347) Add SQ Relation fields for measurement station information
Andre Heinecke <aheinecke@intevation.de>
parents: 6830
diff changeset
259 String measurementStationName = access.getMeasurementStationName();
3ccbc278f2e6 (issue1347) Add SQ Relation fields for measurement station information
Andre Heinecke <aheinecke@intevation.de>
parents: 6830
diff changeset
260
3ccbc278f2e6 (issue1347) Add SQ Relation fields for measurement station information
Andre Heinecke <aheinecke@intevation.de>
parents: 6830
diff changeset
261 if (measurementStationName != null) {
3ccbc278f2e6 (issue1347) Add SQ Relation fields for measurement station information
Andre Heinecke <aheinecke@intevation.de>
parents: 6830
diff changeset
262 source.addMetaData("msName", measurementStationName);
7380
d8d0caaf60a2 (issue1071) Handle the case where no MeasurementStation exists
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
263 } else {
d8d0caaf60a2 (issue1071) Handle the case where no MeasurementStation exists
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
264 source.addMetaData("msName", "");
6859
3ccbc278f2e6 (issue1347) Add SQ Relation fields for measurement station information
Andre Heinecke <aheinecke@intevation.de>
parents: 6830
diff changeset
265 }
3ccbc278f2e6 (issue1347) Add SQ Relation fields for measurement station information
Andre Heinecke <aheinecke@intevation.de>
parents: 6830
diff changeset
266
3ccbc278f2e6 (issue1347) Add SQ Relation fields for measurement station information
Andre Heinecke <aheinecke@intevation.de>
parents: 6830
diff changeset
267 String measurementStationGaugeName = access.getMeasurementStationGaugeName();
3ccbc278f2e6 (issue1347) Add SQ Relation fields for measurement station information
Andre Heinecke <aheinecke@intevation.de>
parents: 6830
diff changeset
268
3ccbc278f2e6 (issue1347) Add SQ Relation fields for measurement station information
Andre Heinecke <aheinecke@intevation.de>
parents: 6830
diff changeset
269 if (measurementStationGaugeName != null) {
3ccbc278f2e6 (issue1347) Add SQ Relation fields for measurement station information
Andre Heinecke <aheinecke@intevation.de>
parents: 6830
diff changeset
270 source.addMetaData("msGauge", measurementStationGaugeName);
7380
d8d0caaf60a2 (issue1071) Handle the case where no MeasurementStation exists
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
271 } else {
d8d0caaf60a2 (issue1071) Handle the case where no MeasurementStation exists
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
272 source.addMetaData("msGauge", "");
6859
3ccbc278f2e6 (issue1347) Add SQ Relation fields for measurement station information
Andre Heinecke <aheinecke@intevation.de>
parents: 6830
diff changeset
273 }
3ccbc278f2e6 (issue1347) Add SQ Relation fields for measurement station information
Andre Heinecke <aheinecke@intevation.de>
parents: 6830
diff changeset
274
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
275 }
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
276
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
277 @Override
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
278 protected void writePDF(OutputStream out) {
6172
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
279 logger.debug("write PDF");
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
280 SQRelationJRDataSource source = createJRData();
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
281
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
282 String jasperFile = Resources.getMsg(
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
283 context.getMeta(),
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
284 JASPER_FILE,
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
285 "/jasper/sqrelation_en.jasper");
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
286 String confPath = Config.getConfigDirectory().toString();
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
287
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
288
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
289 Map parameters = new HashMap();
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
290 parameters.put("ReportTitle", Resources.getMsg(
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
291 context.getMeta(), PDF_TITLE, "Exported Data"));
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
292 try {
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
293 JasperPrint print = JasperFillManager.fillReport(
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
294 confPath + jasperFile,
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
295 parameters,
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
296 source);
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
297 JasperExportManager.exportReportToPdfStream(print, out);
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
298 }
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
299 catch(JRException je) {
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
300 logger.warn("Error generating PDF Report!", je);
58a613798386 Implement PDF export for SQ Relation
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
301 }
3077
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
302 }
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
303 }
5c87d4ca1bd3 Added chart and export generator stubs for SQ relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
304 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org