Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/factory/ProbeFactory.java @ 1262:9dfb52db6a0f
Make use of the ort factory in ort service.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 27 Jan 2017 15:10:01 +0100 |
parents | 6e393b614edf |
children | 212fe0cfd694 |
comparison
equal
deleted
inserted
replaced
1261:dc7dde59bb54 | 1262:9dfb52db6a0f |
---|---|
23 import de.intevation.lada.model.land.MessprogrammMmt; | 23 import de.intevation.lada.model.land.MessprogrammMmt; |
24 import de.intevation.lada.model.land.Probe; | 24 import de.intevation.lada.model.land.Probe; |
25 import de.intevation.lada.model.land.Messung; | 25 import de.intevation.lada.model.land.Messung; |
26 import de.intevation.lada.model.land.Messwert; | 26 import de.intevation.lada.model.land.Messwert; |
27 import de.intevation.lada.model.land.Ortszuordnung; | 27 import de.intevation.lada.model.land.Ortszuordnung; |
28 import de.intevation.lada.model.land.OrtszuordnungMp; | |
28 import de.intevation.lada.model.land.StatusProtokoll; | 29 import de.intevation.lada.model.land.StatusProtokoll; |
29 import de.intevation.lada.model.stammdaten.DeskriptorUmwelt; | 30 import de.intevation.lada.model.stammdaten.DeskriptorUmwelt; |
30 import de.intevation.lada.model.stammdaten.Deskriptoren; | 31 import de.intevation.lada.model.stammdaten.Deskriptoren; |
31 import de.intevation.lada.model.stammdaten.Ort; | 32 import de.intevation.lada.model.stammdaten.Ort; |
32 import de.intevation.lada.util.annotation.RepositoryConfig; | 33 import de.intevation.lada.util.annotation.RepositoryConfig; |
58 int[] Q = { Calendar.MONTH, Calendar.DAY_OF_MONTH, 3 }; | 59 int[] Q = { Calendar.MONTH, Calendar.DAY_OF_MONTH, 3 }; |
59 int[] H = { Calendar.MONTH, Calendar.DAY_OF_MONTH, 6 }; | 60 int[] H = { Calendar.MONTH, Calendar.DAY_OF_MONTH, 6 }; |
60 | 61 |
61 int[] J = { Calendar.YEAR, Calendar.DAY_OF_YEAR, 1 }; | 62 int[] J = { Calendar.YEAR, Calendar.DAY_OF_YEAR, 1 }; |
62 | 63 |
63 this.fieldsTable = new Hashtable<String, int[]>(); | 64 fieldsTable = new Hashtable<String, int[]>(); |
64 | 65 |
65 this.fieldsTable.put("T", T); | 66 fieldsTable.put("T", T); |
66 this.fieldsTable.put("W", W); | 67 fieldsTable.put("W", W); |
67 this.fieldsTable.put("W2", W2); | 68 fieldsTable.put("W2", W2); |
68 this.fieldsTable.put("W4", W4); | 69 fieldsTable.put("W4", W4); |
69 this.fieldsTable.put("M", M); | 70 fieldsTable.put("M", M); |
70 this.fieldsTable.put("Q", Q); | 71 fieldsTable.put("Q", Q); |
71 this.fieldsTable.put("H", H); | 72 fieldsTable.put("H", H); |
72 this.fieldsTable.put("J", J); | 73 fieldsTable.put("J", J); |
73 } | 74 } |
74 | 75 |
75 private class Intervall { | 76 private class Intervall { |
76 private final int teilVon; | 77 private final int teilVon; |
77 private final int teilBis; | 78 private final int teilBis; |
354 MessprogrammMmt.class); | 355 MessprogrammMmt.class); |
355 builder.and("messprogrammId", messprogramm.getId()); | 356 builder.and("messprogrammId", messprogramm.getId()); |
356 Response response = repository.filter(builder.getQuery(), "land"); | 357 Response response = repository.filter(builder.getQuery(), "land"); |
357 @SuppressWarnings("unchecked") | 358 @SuppressWarnings("unchecked") |
358 List<MessprogrammMmt> mmts = (List<MessprogrammMmt>)response.getData(); | 359 List<MessprogrammMmt> mmts = (List<MessprogrammMmt>)response.getData(); |
359 for (MessprogrammMmt mmt : mmts) { | 360 for (int i = 0; i < mmts.size(); i++) { |
361 MessprogrammMmt mmt = mmts.get(i); | |
360 Messung messung = new Messung(); | 362 Messung messung = new Messung(); |
361 messung.setFertig(false); | 363 messung.setFertig(false); |
362 messung.setGeplant(true); | 364 messung.setGeplant(true); |
363 messung.setMmtId(mmt.getMmtId()); | 365 messung.setMmtId(mmt.getMmtId()); |
364 messung.setNebenprobenNr( | 366 messung.setNebenprobenNr( |
373 wert.setMesswert(0d); | 375 wert.setMesswert(0d); |
374 wert.setMehId(1); | 376 wert.setMehId(1); |
375 repository.create(wert, "land"); | 377 repository.create(wert, "land"); |
376 } | 378 } |
377 } | 379 } |
378 if (messprogramm.getOrtId() != null && | 380 QueryBuilder<OrtszuordnungMp> builderOrt = |
379 !messprogramm.getOrtId().equals("")) { | 381 new QueryBuilder<OrtszuordnungMp>( |
380 Ortszuordnung ort = new Ortszuordnung(); | 382 repository.entityManager("land"), |
381 ort.setOrtszuordnungTyp("E"); | 383 OrtszuordnungMp.class); |
382 ort.setProbeId(probe.getId()); | 384 List<OrtszuordnungMp> orte = |
383 QueryBuilder<Ort> ortBuilder = new QueryBuilder<Ort>( | 385 repository.filterPlain(builderOrt.getQuery(), "land"); |
384 repository.entityManager("stamm"), Ort.class); | 386 for (OrtszuordnungMp ort : orte) { |
385 ortBuilder.and("id", messprogramm.getOrtId()); | 387 Ortszuordnung ortP = new Ortszuordnung(); |
386 Response ortResponse = repository.filter( | 388 ortP.setOrtszuordnungTyp(ort.getOrtszuordnungTyp()); |
387 ortBuilder.getQuery(), "stamm"); | 389 ortP.setProbeId(probe.getId()); |
388 @SuppressWarnings("unchecked") | 390 ortP.setOrtId(ort.getOrtId()); |
389 List<Ort> orte = (List<Ort>) ortResponse.getData(); | 391 ortP.setOrtszusatztext(ort.getOrtszusatztext()); |
390 if (orte != null && !orte.isEmpty()) { | 392 repository.create(ortP, "land"); |
391 ort.setOrtId(orte.get(0).getId()); | |
392 } | |
393 repository.create(ort, "land"); | |
394 } | 393 } |
395 // Reolad the probe to have the old id | 394 // Reolad the probe to have the old id |
396 probe = (Probe)repository.getById( | 395 probe = (Probe)repository.getById( |
397 Probe.class, probe.getId(), "land").getData(); | 396 Probe.class, probe.getId(), "land").getData(); |
398 return probe; | 397 return probe; |