comparison src/main/java/de/intevation/lada/validation/rules/messung/HasPflichtmessgroessen.java @ 1336:18c789672b14

Made validator messages more verbose for importer.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 06 Apr 2017 10:10:39 +0200
parents 186d602e031a
children
comparison
equal deleted inserted replaced
1335:b9eb9229df21 1336:18c789672b14
5 * and comes with ABSOLUTELY NO WARRANTY! Check out 5 * and comes with ABSOLUTELY NO WARRANTY! Check out
6 * the documentation coming with IMIS-Labordaten-Application for details. 6 * the documentation coming with IMIS-Labordaten-Application for details.
7 */ 7 */
8 package de.intevation.lada.validation.rules.messung; 8 package de.intevation.lada.validation.rules.messung;
9 9
10 import java.util.ArrayList;
10 import java.util.List; 11 import java.util.List;
11 12
12 import javax.inject.Inject; 13 import javax.inject.Inject;
13 14
14 import de.intevation.lada.model.land.Messung; 15 import de.intevation.lada.model.land.Messung;
15 import de.intevation.lada.model.land.Messwert; 16 import de.intevation.lada.model.land.Messwert;
17 import de.intevation.lada.model.land.Probe;
18 import de.intevation.lada.model.stammdaten.Messgroesse;
16 import de.intevation.lada.model.stammdaten.PflichtMessgroesse; 19 import de.intevation.lada.model.stammdaten.PflichtMessgroesse;
17 import de.intevation.lada.util.annotation.RepositoryConfig; 20 import de.intevation.lada.util.annotation.RepositoryConfig;
18 import de.intevation.lada.util.data.QueryBuilder; 21 import de.intevation.lada.util.data.QueryBuilder;
19 import de.intevation.lada.util.data.Repository; 22 import de.intevation.lada.util.data.Repository;
20 import de.intevation.lada.util.data.RepositoryType; 23 import de.intevation.lada.util.data.RepositoryType;
37 private Repository repository; 40 private Repository repository;
38 41
39 @Override 42 @Override
40 public Violation execute(Object object) { 43 public Violation execute(Object object) {
41 Messung messung = (Messung)object; 44 Messung messung = (Messung)object;
45 Probe probe = repository.getByIdPlain(Probe.class, messung.getProbeId(), "land");
46
42 QueryBuilder<PflichtMessgroesse> builder = 47 QueryBuilder<PflichtMessgroesse> builder =
43 new QueryBuilder<PflichtMessgroesse>( 48 new QueryBuilder<PflichtMessgroesse>(
44 repository.entityManager("stamm"), 49 repository.entityManager("stamm"),
45 PflichtMessgroesse.class); 50 PflichtMessgroesse.class);
46 builder.and("messMethodeId", messung.getMmtId()); 51 builder.and("messMethodeId", messung.getMmtId());
52 builder.and("umwId", probe.getUmwId());
47 Response response = repository.filter(builder.getQuery(), "stamm"); 53 Response response = repository.filter(builder.getQuery(), "stamm");
48 @SuppressWarnings("unchecked") 54 @SuppressWarnings("unchecked")
49 List<PflichtMessgroesse> pflicht = 55 List<PflichtMessgroesse> pflicht =
50 (List<PflichtMessgroesse>)response.getData(); 56 (List<PflichtMessgroesse>)response.getData();
51 57
56 Response wertResponse = 62 Response wertResponse =
57 repository.filter(wertBuilder.getQuery(), "land"); 63 repository.filter(wertBuilder.getQuery(), "land");
58 @SuppressWarnings("unchecked") 64 @SuppressWarnings("unchecked")
59 List<Messwert> messwerte = (List<Messwert>)wertResponse.getData(); 65 List<Messwert> messwerte = (List<Messwert>)wertResponse.getData();
60 Violation violation = new Violation(); 66 Violation violation = new Violation();
61 boolean missing = false; 67 List<PflichtMessgroesse> tmp = new ArrayList<PflichtMessgroesse>();
62 for (PflichtMessgroesse p : pflicht) { 68 for (Messwert wert : messwerte) {
63 for (Messwert wert : messwerte) { 69 for (PflichtMessgroesse p : pflicht) {
64 if (!p.getMessgroesseId().equals(wert.getMessgroesseId())) { 70 if (p.getMessgroesseId().equals(wert.getMessgroesseId())) {
65 missing = true; 71 tmp.add(p);
66 } 72 }
67 } 73 }
68 } 74 }
69 if (missing) { 75 pflicht.removeAll(tmp);
70 violation.addWarning("pflichtmessgroesse", 631); 76 if (!pflicht.isEmpty()) {
77 for (PflichtMessgroesse p : pflicht) {
78 Messgroesse mg = repository.getByIdPlain(Messgroesse.class, p.getMessgroesseId(), "stamm");
79 violation.addWarning("pflichtmessgroesse#" + mg.getMessgroesse(), 631);
80 }
71 } 81 }
72 return violation.hasWarnings() ? violation : null; 82 return violation.hasWarnings() ? violation : null;
73 } 83 }
74 } 84 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)