Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationExporter.java @ 9006:7134a4c7d1b6
U-Info S-Info general work
author | gernotbelger |
---|---|
date | Tue, 17 Apr 2018 13:20:25 +0200 |
parents | fb9430250899 |
children | 41f4bc83aa7a |
comparison
equal
deleted
inserted
replaced
9005:460fcc128794 | 9006:7134a4c7d1b6 |
---|---|
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | 7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
8 * documentation coming with Dive4Elements River for details. | 8 * documentation coming with Dive4Elements River for details. |
9 */ | 9 */ |
10 package org.dive4elements.river.artifacts.uinfo.inundationduration; | 10 package org.dive4elements.river.artifacts.uinfo.inundationduration; |
11 | 11 |
12 import java.io.OutputStream; | |
12 import java.util.ArrayList; | 13 import java.util.ArrayList; |
13 import java.util.Collection; | 14 import java.util.Collection; |
14 | 15 |
15 import org.apache.log4j.Logger; | 16 import org.apache.log4j.Logger; |
16 import org.dive4elements.river.artifacts.common.GeneralResultType; | 17 import org.dive4elements.river.artifacts.common.GeneralResultType; |
18 import org.dive4elements.river.artifacts.common.JasperReporter; | |
19 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; | |
17 import org.dive4elements.river.artifacts.common.ResultRow; | 20 import org.dive4elements.river.artifacts.common.ResultRow; |
18 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; | 21 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; |
19 import org.dive4elements.river.artifacts.sinfo.util.MetaAndTableJRDataSource; | |
20 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | 22 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; |
21 import org.dive4elements.river.artifacts.uinfo.commons.AbstractUInfoExporter; | 23 import org.dive4elements.river.artifacts.uinfo.commons.AbstractUInfoExporter; |
22 | 24 |
23 import au.com.bytecode.opencsv.CSVWriter; | 25 import au.com.bytecode.opencsv.CSVWriter; |
26 import net.sf.jasperreports.engine.JRException; | |
24 | 27 |
25 /** | 28 /** |
26 * @author Domenico Nardi Tironi | 29 * @author Domenico Nardi Tironi |
27 * | 30 * |
28 */ | 31 */ |
29 public class InundationDurationExporter extends AbstractUInfoExporter<InundationDurationCalculationResult, InundationDurationCalculationResults> { | 32 public class InundationDurationExporter extends AbstractUInfoExporter<InundationDurationCalculationResult, InundationDurationCalculationResults> { |
30 | 33 |
31 /** The log used in this exporter. */ | 34 /** The log used in this exporter. */ |
32 private static Logger log = Logger.getLogger(InundationDurationExporter.class); | 35 private static Logger log = Logger.getLogger(InundationDurationExporter.class); |
33 | 36 |
34 private static final String JASPER_FILE = "/jasper/uinfo.inundationduration.jasper"; | 37 private static final String JASPER_FILE = "/jasper/templates/uinfo.inundationduration.jrxml"; |
35 | 38 |
36 @Override | 39 @Override |
37 protected Logger getLog() { | 40 protected Logger getLog() { |
38 return log; | 41 return log; |
39 } | 42 } |
41 @Override | 44 @Override |
42 protected void writeCSVGlobalMetadata(final CSVWriter writer, final InundationDurationCalculationResults results) { | 45 protected void writeCSVGlobalMetadata(final CSVWriter writer, final InundationDurationCalculationResults results) { |
43 log.info("SalixLineExporter.writeCSVMeta"); | 46 log.info("SalixLineExporter.writeCSVMeta"); |
44 | 47 |
45 super.writeCSVGlobalMetadataDefaults(writer, results); | 48 super.writeCSVGlobalMetadataDefaults(writer, results); |
49 writer.writeNext(new String[] { "" }); // break line | |
46 } | 50 } |
47 | 51 |
48 @Override | 52 @Override |
49 protected void writeCSVResultMetadata(final CSVWriter writer, final InundationDurationCalculationResults results, | 53 protected void writeCSVResultMetadata(final CSVWriter writer, final InundationDurationCalculationResults results, |
50 final InundationDurationCalculationResult result) { | 54 final InundationDurationCalculationResult result) { |
109 | 113 |
110 return lines.toArray(new String[lines.size()]); | 114 return lines.toArray(new String[lines.size()]); |
111 } | 115 } |
112 | 116 |
113 @Override | 117 @Override |
114 protected final String getJasperFile() { | |
115 return JASPER_FILE; | |
116 } | |
117 | |
118 @Override | |
119 protected final void addJRMetaData(final MetaAndTableJRDataSource source, final InundationDurationCalculationResults results) { | 118 protected final void addJRMetaData(final MetaAndTableJRDataSource source, final InundationDurationCalculationResults results) { |
120 | 119 |
121 /* general metadata */ | 120 /* general metadata */ |
122 super.addJRMetaData(source, results); | 121 super.addJRMetaData(source, results); |
123 | 122 |
124 /* column headings */ | 123 /* column headings */ |
125 source.addMetaData("station_header", GeneralResultType.station.getPdfHeader(this.context.getMeta())); | 124 source.addMetaData("station_header", GeneralResultType.station.getPdfHeader(this.context.getMeta())); |
126 // source.addMetaData("flowdepth_header", SInfoResultType.flowdepth.getPdfHeader(this.context.getMeta())); | 125 |
127 // source.addMetaData("flowdepth_tkh_header", SInfoResultType.flowdepthtkh.getPdfHeader(this.context.getMeta())); | 126 } |
128 // source.addMetaData("tkh_header", SInfoResultType.tkh.getPdfHeader(this.context.getMeta())); | 127 |
129 // source.addMetaData("waterlevel_header", SInfoResultType.waterlevel.getPdfHeader(this.context.getMeta())); | 128 @Override |
130 // source.addMetaData("discharge_header", SInfoResultType.discharge.getPdfHeader(this.context.getMeta())); | 129 protected void writePDF(final OutputStream out) { |
131 // source.addMetaData("waterlevel_name_header", SInfoResultType.waterlevelLabel.getPdfHeader(this.context.getMeta())); | 130 try { |
132 // source.addMetaData("gauge_header", SInfoResultType.gaugeLabel.getPdfHeader(this.context.getMeta())); | 131 final MetaAndTableJRDataSource source = createJRData(this.data); |
133 // source.addMetaData("bedheight_header", SInfoResultType.meanBedHeight.getPdfHeader(this.context.getMeta())); | 132 |
134 // source.addMetaData("sounding_name_header", SInfoResultType.soundingLabel.getPdfHeader(this.context.getMeta())); | 133 final JasperReporter reporter = new JasperReporter(); |
135 // source.addMetaData("location_header", SInfoResultType.location.getPdfHeader(this.context.getMeta())); | 134 reporter.addReport(JASPER_FILE, source); |
135 reporter.exportPDF(out); | |
136 } | |
137 catch (final JRException je) { | |
138 getLog().warn("Error generating PDF Report!", je); | |
139 } | |
136 } | 140 } |
137 | 141 |
138 } | 142 } |