Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/DeltaWtExporter.java @ 3129:04952869e4fa
FixA: Added reference events to CSV export.
flys-artifacts/trunk@4730 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 20 Jun 2012 15:30:38 +0000 |
parents | 65b6e27c6f25 |
children |
comparison
equal
deleted
inserted
replaced
3128:1dd6f30b0a76 | 3129:04952869e4fa |
---|---|
56 | 56 |
57 public static final String DEFAULT_CSV_T_DESC_HEADER = "Beschreibung"; | 57 public static final String DEFAULT_CSV_T_DESC_HEADER = "Beschreibung"; |
58 | 58 |
59 protected List<KMIndex<AnalysisPeriod []>> analysisPeriods; | 59 protected List<KMIndex<AnalysisPeriod []>> analysisPeriods; |
60 | 60 |
61 protected List<KMIndex<QWD[]>> referenceEvents; | |
62 | |
61 @Override | 63 @Override |
62 public void init(Document request, OutputStream out, CallContext context) { | 64 public void init(Document request, OutputStream out, CallContext context) { |
63 log.debug("DeltaWtExporter.init"); | 65 log.debug("DeltaWtExporter.init"); |
64 super.init(request, out, context); | 66 super.init(request, out, context); |
65 analysisPeriods = new ArrayList<KMIndex<AnalysisPeriod []>>(); | 67 analysisPeriods = new ArrayList<KMIndex<AnalysisPeriod []>>(); |
68 referenceEvents = new ArrayList<KMIndex<QWD[]>>(); | |
66 } | 69 } |
67 | 70 |
68 @Override | 71 @Override |
69 public void generate() throws IOException { | 72 public void generate() throws IOException { |
70 log.debug("DeltaWtExporter.generate"); | 73 log.debug("DeltaWtExporter.generate"); |
94 if (!(data instanceof FixResult)) { | 97 if (!(data instanceof FixResult)) { |
95 log.warn("Invalid data stored in result."); | 98 log.warn("Invalid data stored in result."); |
96 } | 99 } |
97 FixResult result = (FixResult)data; | 100 FixResult result = (FixResult)data; |
98 analysisPeriods.add(result.getAnalysisPeriods()); | 101 analysisPeriods.add(result.getAnalysisPeriods()); |
102 referenceEvents.add(result.getReferenced()); | |
99 } | 103 } |
100 | 104 |
101 @Override | 105 @Override |
102 protected void writeCSVData(CSVWriter writer) throws IOException { | 106 protected void writeCSVData(CSVWriter writer) throws IOException { |
103 | 107 |
109 NumberFormat dwF = getDeltaWFormatter(); | 113 NumberFormat dwF = getDeltaWFormatter(); |
110 | 114 |
111 CallMeta meta = context.getMeta(); | 115 CallMeta meta = context.getMeta(); |
112 Locale locale = Resources.getLocale(meta); | 116 Locale locale = Resources.getLocale(meta); |
113 DateFormat dF = DateFormat.getDateInstance(DateFormat.SHORT, locale); | 117 DateFormat dF = DateFormat.getDateInstance(DateFormat.SHORT, locale); |
118 | |
119 for (KMIndex<QWD[]> reference: referenceEvents) { | |
120 | |
121 for (KMIndex.Entry<QWD[]> kmEntry: reference) { | |
122 | |
123 String kmS = kmF.format(kmEntry.getKm()); | |
124 for (QWD qwd: kmEntry.getValue()) { | |
125 double deltaW = qwd.getDeltaW(); | |
126 Date date = qwd.getDate(); | |
127 String desc = qwd.getDescription(); | |
128 | |
129 String deltaWS = dwF.format(deltaW); | |
130 String dateS = dF.format(date); | |
131 | |
132 writer.writeNext(new String[] { | |
133 kmS, | |
134 deltaWS, | |
135 dateS, | |
136 desc != null ? desc : "" }); | |
137 } | |
138 } | |
139 } | |
114 | 140 |
115 if (debug) { | 141 if (debug) { |
116 log.debug("AnalysisPeriods: " + analysisPeriods.size()); | 142 log.debug("AnalysisPeriods: " + analysisPeriods.size()); |
117 } | 143 } |
118 | 144 |