Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculationResult.java @ 9150:23945061daec
gigantic refactoring: exporter, result, results
to support multiple jaspers -> collisions
author | gernotbelger |
---|---|
date | Thu, 14 Jun 2018 16:56:31 +0200 |
parents | 1ffd38826175 |
children | a4121ec450d6 |
comparison
equal
deleted
inserted
replaced
9149:5be112fba832 | 9150:23945061daec |
---|---|
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.vegetationzones; | 10 package org.dive4elements.river.artifacts.uinfo.vegetationzones; |
11 | 11 |
12 import java.util.ArrayList; | |
12 import java.util.Collection; | 13 import java.util.Collection; |
13 | 14 |
14 import org.dive4elements.river.artifacts.common.AbstractCalculationResult; | 15 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; |
16 import org.dive4elements.river.artifacts.common.ExportContextCSV; | |
17 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; | |
15 import org.dive4elements.river.artifacts.common.ResultRow; | 18 import org.dive4elements.river.artifacts.common.ResultRow; |
19 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | |
20 import org.dive4elements.river.artifacts.uinfo.commons.UInfoResultType; | |
16 | 21 |
17 /** | 22 /** |
18 * @author Domenico Nardi Tironi | 23 * @author Domenico Nardi Tironi |
19 */ | 24 */ |
20 final class VegetationZonesCalculationResult extends AbstractCalculationResult { | 25 final class VegetationZonesCalculationResult extends AbstractCalculationExportableResult<VegetationZonesCalculationResults> { |
26 private static final long serialVersionUID = 1L; | |
21 | 27 |
22 private static final long serialVersionUID = 1L; | 28 private static final String JASPER_FILE = "/jasper/templates/uinfo.vegetationzones.jrxml"; |
23 | 29 |
24 public VegetationZonesCalculationResult(final String label, final Collection<ResultRow> rows) { | 30 public VegetationZonesCalculationResult(final String label, final Collection<ResultRow> rows) { |
25 super(label, rows); | 31 super(label, rows); |
26 } | 32 } |
27 | 33 |
34 @Override | |
35 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final VegetationZonesCalculationResults results, final RiverInfo river) { | |
36 | |
37 final Collection<String> header = new ArrayList<>(11); | |
38 | |
39 header.add(exportContextCSV.formatCsvHeader(UInfoResultType.vegname)); | |
40 header.add(exportContextCSV.formatCsvHeader(UInfoResultType.vegdauervon)); | |
41 header.add(exportContextCSV.formatCsvHeader(UInfoResultType.vegdauerbis)); | |
42 | |
43 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); | |
44 } | |
45 | |
46 @Override | |
47 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV, final VegetationZonesCalculationResults results) { | |
48 // no metadata | |
49 | |
50 } | |
51 | |
52 @Override | |
53 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final VegetationZonesCalculationResults results, final ResultRow row) { | |
54 return formatRow(exportContextCSV, results, row); | |
55 } | |
56 | |
57 @Override | |
58 protected String[] formatPDFRow(final ExportContextCSV exportContextPDF, final VegetationZonesCalculationResults results, final ResultRow row) { | |
59 | |
60 return formatRow(exportContextPDF, results, row); | |
61 } | |
62 | |
63 @Override | |
64 protected String getJasperFile() { | |
65 | |
66 return JASPER_FILE; | |
67 } | |
68 | |
69 @Override | |
70 protected void addJRTableHeader(final ExportContextCSV exportContextPDF, final MetaAndTableJRDataSource source, | |
71 final VegetationZonesCalculationResults results) { | |
72 /* additional column headings */ | |
73 exportContextPDF.addJRMetadata(source, "veg_name", UInfoResultType.vegname); | |
74 exportContextPDF.addJRMetadata(source, "veg_dauervon", UInfoResultType.vegdauervon); | |
75 exportContextPDF.addJRMetadata(source, "veg_dauerbis", UInfoResultType.vegdauerbis); | |
76 | |
77 } | |
78 | |
79 protected String[] formatRow(final ExportContextCSV context, final VegetationZonesCalculationResults results, final ResultRow row) { | |
80 | |
81 final Collection<String> lines = new ArrayList<>(11); | |
82 | |
83 lines.add(context.formatRowValue(row, UInfoResultType.vegname)); | |
84 lines.add(context.formatRowValue(row, UInfoResultType.vegdauervon)); | |
85 lines.add(context.formatRowValue(row, UInfoResultType.vegdauerbis)); | |
86 | |
87 return lines.toArray(new String[lines.size()]); | |
88 } | |
89 | |
28 } | 90 } |