Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/data/importer/LAFProducer.java @ 337:cb47c33b119d
Imporved error/warning handling and fixed some bugs in the importer module.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 28 Aug 2013 15:11:50 +0200 |
parents | 5d11428e6a09 |
children | 97aa76c9c2d3 |
comparison
equal
deleted
inserted
replaced
336:53417b61391c | 337:cb47c33b119d |
---|---|
7 import java.util.Map; | 7 import java.util.Map; |
8 | 8 |
9 import javax.inject.Inject; | 9 import javax.inject.Inject; |
10 import javax.inject.Named; | 10 import javax.inject.Named; |
11 | 11 |
12 import de.intevation.lada.data.QueryBuilder; | |
13 import de.intevation.lada.data.Repository; | |
12 import de.intevation.lada.model.LKommentarM; | 14 import de.intevation.lada.model.LKommentarM; |
13 import de.intevation.lada.model.LKommentarMId; | 15 import de.intevation.lada.model.LKommentarMId; |
14 import de.intevation.lada.model.LKommentarP; | 16 import de.intevation.lada.model.LKommentarP; |
15 import de.intevation.lada.model.LMessung; | 17 import de.intevation.lada.model.LMessung; |
16 import de.intevation.lada.model.LMessungId; | 18 import de.intevation.lada.model.LMessungId; |
17 import de.intevation.lada.model.LMesswert; | 19 import de.intevation.lada.model.LMesswert; |
18 import de.intevation.lada.model.LMesswertId; | 20 import de.intevation.lada.model.LMesswertId; |
19 import de.intevation.lada.model.LOrt; | 21 import de.intevation.lada.model.LOrt; |
20 import de.intevation.lada.model.LProbe; | 22 import de.intevation.lada.model.LProbe; |
21 import de.intevation.lada.model.LProbe; | 23 import de.intevation.lada.model.LProbe; |
24 import de.intevation.lada.model.LZusatzWert; | |
25 import de.intevation.lada.model.LZusatzWertId; | |
26 import de.intevation.lada.model.SProbenZusatz; | |
22 | 27 |
23 @Named("lafproducer") | 28 @Named("lafproducer") |
24 public class LAFProducer | 29 public class LAFProducer |
25 implements Producer | 30 implements Producer |
26 { | 31 { |
32 | |
33 @Inject | |
34 @Named("readonlyrepository") | |
35 private Repository sRepository; | |
27 | 36 |
28 private LProbe probe; | 37 private LProbe probe; |
29 private LMessung messung; | 38 private LMessung messung; |
30 private LOrt ort; | 39 private LOrt ort; |
31 | 40 |
32 private List<LKommentarP> pKommentare; | 41 private List<LKommentarP> pKommentare; |
33 private List<LKommentarM> mKommentare; | 42 private List<LKommentarM> mKommentare; |
34 private List<LMessung> messungen; | 43 private List<LMessung> messungen; |
35 private List<LOrt> orte; | 44 private List<LOrt> orte; |
36 private List<LMesswert> messwerte; | 45 private List<LMesswert> messwerte; |
46 private List<LZusatzWert> zusatzwerte; | |
37 | 47 |
38 private List<EntryFormat> probenFormat; | 48 private List<EntryFormat> probenFormat; |
39 private List<EntryFormat> messungFormat; | 49 private List<EntryFormat> messungFormat; |
40 private List<EntryFormat> ortFormat; | 50 private List<EntryFormat> ortFormat; |
41 | 51 |
82 kommentar.setProbeId(this.probe.getProbeId()); | 92 kommentar.setProbeId(this.probe.getProbeId()); |
83 this.mKommentare.add( | 93 this.mKommentare.add( |
84 mapper.addAttribute(lKey, values, kommentar)); | 94 mapper.addAttribute(lKey, values, kommentar)); |
85 } | 95 } |
86 else if (lKey.equals("probenzusatzbeschreibung")) { | 96 else if (lKey.equals("probenzusatzbeschreibung")) { |
87 //TODO: implement this! | 97 LZusatzWertId zusatzId = new LZusatzWertId(); |
98 zusatzId.setProbeId(this.probe.getProbeId()); | |
99 LZusatzWert wert = new LZusatzWert(); | |
100 wert.setId(zusatzId); | |
101 LZusatzWert zusatzWert = mapper.addAttribute(lKey, values, wert); | |
102 if (zusatzWert != null) { | |
103 this.zusatzwerte.add(zusatzWert); | |
104 } | |
105 else { | |
106 List<ReportData> err = this.errors.get(probe.getProbeId()); | |
107 if (err == null) { | |
108 this.errors.put(probe.getProbeId(), mapper.getErrors()); | |
109 } | |
110 else { | |
111 err.addAll(mapper.getErrors()); | |
112 } | |
113 } | |
88 } | 114 } |
89 else if (lKey.equals("pzb_s")) { | 115 else if (lKey.equals("pzb_s")) { |
90 //TODO: implement this! | 116 LZusatzWertId zusatzId = new LZusatzWertId(); |
117 zusatzId.setProbeId(this.probe.getProbeId()); | |
118 LZusatzWert wert = new LZusatzWert(); | |
119 wert.setId(zusatzId); | |
120 LZusatzWert zusatzWert = mapper.addAttributeS(lKey, values, wert); | |
121 if (zusatzWert != null) { | |
122 this.zusatzwerte.add(zusatzWert); | |
123 } | |
124 else { | |
125 List<ReportData> err = this.errors.get(probe.getProbeId()); | |
126 if (err == null) { | |
127 this.errors.put(probe.getProbeId(), mapper.getErrors()); | |
128 } | |
129 else { | |
130 err.addAll(mapper.getErrors()); | |
131 } | |
132 } | |
91 } | 133 } |
92 else if (lKey.equals("messwert")) { | 134 else if (lKey.equals("messwert")) { |
93 LMesswertId id = new LMesswertId(); | 135 LMesswertId id = new LMesswertId(); |
94 id.setProbeId(this.probe.getProbeId()); | 136 id.setProbeId(this.probe.getProbeId()); |
95 id.setMessungsId(this.messung.getId().getMessungsId()); | 137 id.setMessungsId(this.messung.getId().getMessungsId()); |
99 m.setProbeId(this.probe.getProbeId()); | 141 m.setProbeId(this.probe.getProbeId()); |
100 LMesswert wert = mapper.addAttribute(lKey, values, m); | 142 LMesswert wert = mapper.addAttribute(lKey, values, m); |
101 if (wert != null) { | 143 if (wert != null) { |
102 this.messwerte.add(wert); | 144 this.messwerte.add(wert); |
103 } | 145 } |
146 else { | |
147 List<ReportData> err = this.errors.get(probe.getProbeId()); | |
148 if (err == null) { | |
149 this.errors.put(probe.getProbeId(), mapper.getErrors()); | |
150 } | |
151 else { | |
152 err.addAll(mapper.getErrors()); | |
153 } | |
154 } | |
104 } | 155 } |
105 else if (isValidMessung(lKey, values.toString())) { | 156 else if (isValidMessung(lKey, values.toString())) { |
106 this.messung = mapper.addAttribute(lKey, values, this.messung); | 157 this.messung = mapper.addAttribute(lKey, values, this.messung); |
107 } | 158 } |
108 else if (isValidProbe(lKey, values.toString())) { | 159 else if (isValidProbe(lKey, values.toString())) { |
179 public List<LMesswert> getMesswerte() { | 230 public List<LMesswert> getMesswerte() { |
180 return this.messwerte; | 231 return this.messwerte; |
181 } | 232 } |
182 | 233 |
183 @Override | 234 @Override |
235 public List<LZusatzWert> getZusatzwerte() { | |
236 return this.zusatzwerte; | |
237 } | |
238 | |
239 @Override | |
184 public void reset() { | 240 public void reset() { |
185 this.errors.clear(); | 241 this.errors = new HashMap<String, List<ReportData>>(); |
186 this.warnings.clear(); | 242 this.warnings = new HashMap<String, List<ReportData>>(); |
187 this.probe = new LProbe(); | 243 this.probe = new LProbe(); |
188 this.messungen.clear(); | 244 this.messungen = new ArrayList<LMessung>(); |
189 this.messung = null; | 245 this.messung = null; |
190 this.orte.clear(); | 246 this.orte = new ArrayList<LOrt>(); |
191 this.ort = null; | 247 this.ort = null; |
192 this.messwerte.clear(); | 248 this.messwerte = new ArrayList<LMesswert>(); |
193 this.mKommentare.clear(); | 249 this.mKommentare = new ArrayList<LKommentarM>(); |
194 this.pKommentare.clear(); | 250 this.pKommentare = new ArrayList<LKommentarP>(); |
195 mapper.reset(); | 251 mapper.reset(); |
196 } | 252 } |
197 | 253 |
198 public void newMessung() { | 254 public void newMessung() { |
199 if (this.messung != null) { | 255 if (this.messung != null) { |
216 | 272 |
217 /** | 273 /** |
218 * @return the warnings | 274 * @return the warnings |
219 */ | 275 */ |
220 public Map<String, List<ReportData>> getWarnings() { | 276 public Map<String, List<ReportData>> getWarnings() { |
277 if (this.probe == null) { | |
278 return this.warnings; | |
279 } | |
280 List<ReportData> warn = this.warnings.get(probe.getProbeId()); | |
281 if (warn == null) { | |
282 this.warnings.put(probe.getProbeId(), mapper.getWarnings()); | |
283 } | |
284 else { | |
285 warn.addAll(mapper.getWarnings()); | |
286 } | |
221 return this.warnings; | 287 return this.warnings; |
222 } | 288 } |
223 | 289 |
224 /** | 290 /** |
225 * @return the errors | 291 * @return the errors |
226 */ | 292 */ |
227 public Map<String, List<ReportData>> getErrors() { | 293 public Map<String, List<ReportData>> getErrors() { |
294 if (this.probe == null) { | |
295 return this.errors; | |
296 } | |
297 List<ReportData> err = this.errors.get(this.probe.getProbeId()); | |
298 if (err == null) { | |
299 this.errors.put(probe.getProbeId(), mapper.getErrors()); | |
300 } | |
301 else { | |
302 err.addAll(mapper.getErrors()); | |
303 } | |
228 return this.errors; | 304 return this.errors; |
229 } | 305 } |
230 } | 306 } |