[Lada-commits] [PATCH 2 of 2] Made validator messages more verbose for importer
Wald Commits
scm-commit at wald.intevation.org
Thu Apr 6 10:12:07 CEST 2017
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1491466239 -7200
# Node ID 18c789672b14f57bcc09055d22a6a53ee64c0736
# Parent b9eb9229df21615278f9e84434d18dc30b042ee5
Made validator messages more verbose for importer.
diff -r b9eb9229df21 -r 18c789672b14 src/main/java/de/intevation/lada/validation/rules/messung/Date.java
--- a/src/main/java/de/intevation/lada/validation/rules/messung/Date.java Thu Apr 06 10:08:47 2017 +0200
+++ b/src/main/java/de/intevation/lada/validation/rules/messung/Date.java Thu Apr 06 10:10:39 2017 +0200
@@ -50,7 +50,9 @@
if (probe.getProbeentnahmeEnde() == null ||
probe.getProbeentnahmeEnde().after(messung.getMesszeitpunkt())) {
Violation violation = new Violation();
- violation.addWarning("messzeitpunkt", 632);
+ violation.addWarning(
+ "messzeitpunkt#" + messung.getNebenprobenNr(),
+ 632);
return violation;
}
}
diff -r b9eb9229df21 -r 18c789672b14 src/main/java/de/intevation/lada/validation/rules/messung/HasPflichtmessgroessen.java
--- a/src/main/java/de/intevation/lada/validation/rules/messung/HasPflichtmessgroessen.java Thu Apr 06 10:08:47 2017 +0200
+++ b/src/main/java/de/intevation/lada/validation/rules/messung/HasPflichtmessgroessen.java Thu Apr 06 10:10:39 2017 +0200
@@ -7,12 +7,15 @@
*/
package de.intevation.lada.validation.rules.messung;
+import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import de.intevation.lada.model.land.Messung;
import de.intevation.lada.model.land.Messwert;
+import de.intevation.lada.model.land.Probe;
+import de.intevation.lada.model.stammdaten.Messgroesse;
import de.intevation.lada.model.stammdaten.PflichtMessgroesse;
import de.intevation.lada.util.annotation.RepositoryConfig;
import de.intevation.lada.util.data.QueryBuilder;
@@ -39,11 +42,14 @@
@Override
public Violation execute(Object object) {
Messung messung = (Messung)object;
+ Probe probe = repository.getByIdPlain(Probe.class, messung.getProbeId(), "land");
+
QueryBuilder<PflichtMessgroesse> builder =
new QueryBuilder<PflichtMessgroesse>(
repository.entityManager("stamm"),
PflichtMessgroesse.class);
builder.and("messMethodeId", messung.getMmtId());
+ builder.and("umwId", probe.getUmwId());
Response response = repository.filter(builder.getQuery(), "stamm");
@SuppressWarnings("unchecked")
List<PflichtMessgroesse> pflicht =
@@ -58,16 +64,20 @@
@SuppressWarnings("unchecked")
List<Messwert> messwerte = (List<Messwert>)wertResponse.getData();
Violation violation = new Violation();
- boolean missing = false;
- for (PflichtMessgroesse p : pflicht) {
- for (Messwert wert : messwerte) {
- if (!p.getMessgroesseId().equals(wert.getMessgroesseId())) {
- missing = true;
+ List<PflichtMessgroesse> tmp = new ArrayList<PflichtMessgroesse>();
+ for (Messwert wert : messwerte) {
+ for (PflichtMessgroesse p : pflicht) {
+ if (p.getMessgroesseId().equals(wert.getMessgroesseId())) {
+ tmp.add(p);
}
}
}
- if (missing) {
- violation.addWarning("pflichtmessgroesse", 631);
+ pflicht.removeAll(tmp);
+ if (!pflicht.isEmpty()) {
+ for (PflichtMessgroesse p : pflicht) {
+ Messgroesse mg = repository.getByIdPlain(Messgroesse.class, p.getMessgroesseId(), "stamm");
+ violation.addWarning("pflichtmessgroesse#" + mg.getMessgroesse(), 631);
+ }
}
return violation.hasWarnings() ? violation : null;
}
diff -r b9eb9229df21 -r 18c789672b14 src/main/java/de/intevation/lada/validation/rules/messung/MessgroesseToMessmethode.java
--- a/src/main/java/de/intevation/lada/validation/rules/messung/MessgroesseToMessmethode.java Thu Apr 06 10:08:47 2017 +0200
+++ b/src/main/java/de/intevation/lada/validation/rules/messung/MessgroesseToMessmethode.java Thu Apr 06 10:10:39 2017 +0200
@@ -16,6 +16,7 @@
import de.intevation.lada.model.land.Messung;
import de.intevation.lada.model.land.Messwert;
+import de.intevation.lada.model.stammdaten.Messgroesse;
import de.intevation.lada.model.stammdaten.MmtMessgroesse;
import de.intevation.lada.util.annotation.RepositoryConfig;
import de.intevation.lada.util.data.QueryBuilder;
@@ -73,15 +74,17 @@
for(Messwert messwert: messwerte) {
boolean hit = false;
for (MmtMessgroesse messgroesse: found) {
- logger.trace("###### mmt: " + messwert.getMessgroesseId()
- + " mmtmg: " + messgroesse.getMmtId());
if (messwert.getMessgroesseId().equals(
- messgroesse.getMmtId())) {
+ messgroesse.getMessgroesseId())) {
hit = true;
}
}
if (!hit) {
- violation.addWarning("messgroesse", 632);
+ Messgroesse mg = repository.getByIdPlain(
+ Messgroesse.class,
+ messwert.getMessgroesseId(),
+ "stamm");
+ violation.addWarning("messgroesse#" + mg.getMessgroesse(), 632);
}
}
return violation.hasWarnings() ? violation : null;
diff -r b9eb9229df21 -r 18c789672b14 src/main/java/de/intevation/lada/validation/rules/probe/DeskriptorToUmwelt.java
--- a/src/main/java/de/intevation/lada/validation/rules/probe/DeskriptorToUmwelt.java Thu Apr 06 10:08:47 2017 +0200
+++ b/src/main/java/de/intevation/lada/validation/rules/probe/DeskriptorToUmwelt.java Thu Apr 06 10:10:39 2017 +0200
@@ -104,7 +104,7 @@
if (media.size() == 0) {
Violation violation = new Violation();
- violation.addWarning("umwId", 632);
+ violation.addWarning("umwId#" + umwId, 632);
return violation;
}
@@ -121,7 +121,7 @@
List<DeskriptorUmwelt> data = (List<DeskriptorUmwelt>)response.getData();
if (data.isEmpty()) {
Violation violation = new Violation();
- violation.addWarning("umwId", 632);
+ violation.addWarning("umwId#" + umwId, 632);
return violation;
}
@@ -131,12 +131,12 @@
}
else if (unique && !umwId.equals(data.get(0).getUmwId())) {
Violation violation = new Violation();
- violation.addWarning("umwId", 632);
+ violation.addWarning("umwId#" + umwId, 632);
return violation;
}
else {
Violation violation = new Violation();
- violation.addWarning("umwId", 632);
+ violation.addWarning("umwId#" + umwId, 632);
boolean found = false;
for (int i = 0; i < data.size(); i++) {
if (!data.get(i).getUmwId().equals(umwId)) {
More information about the Lada-commits
mailing list