[Lada-commits] [PATCH] Moved probe validation to have all subobject available during validation
Wald Commits
scm-commit at wald.intevation.org
Mon Nov 7 12:30:43 CET 2016
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1478518235 -3600
# Node ID 7a9bc3fe0efdc0bb098a8d6896bed5fa937f4cfc
# Parent cf1eb19f896b8ebb15d022a75ae7731688ee68fa
Moved probe validation to have all subobject available during validation.
diff -r cf1eb19f896b -r 7a9bc3fe0efd src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java
--- a/src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java Mon Nov 07 11:06:23 2016 +0100
+++ b/src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java Mon Nov 07 12:30:35 2016 +0100
@@ -152,12 +152,6 @@
if(i == Identified.UPDATE) {
merger.merge(old, probe);
newProbe = old;
- Violation violation = probeValidator.validate(newProbe);
- for (Entry<String, List<Integer>> warn : violation.getWarnings().entrySet()) {
- for (Integer code : warn.getValue()) {
- currentWarnings.add(new ReportItem("validation", warn.getKey(), code));
- }
- }
}
// Probe was found but some data does not match
else if(i == Identified.REJECT){
@@ -179,15 +173,13 @@
// It is a brand new probe!
else if(i == Identified.NEW){
Violation violation = probeValidator.validate(probe);
- for (Entry<String, List<Integer>> err : violation.getErrors().entrySet()) {
- for (Integer code : err.getValue()) {
- currentErrors.add(new ReportItem("validation", err.getKey(), code));
+ if (violation.hasErrors()) {
+ for (Entry<String, List<Integer>> err : violation.getErrors().entrySet()) {
+ for (Integer code : err.getValue()) {
+ currentErrors.add(new ReportItem("validation", err.getKey(), code));
+ }
}
- }
- for (Entry<String, List<Integer>> warn : violation.getWarnings().entrySet()) {
- for (Integer code : warn.getValue()) {
- currentWarnings.add(new ReportItem("validation", warn.getKey(), code));
- }
+ return;
}
Response created = repository.create(probe, "land");
newProbe = ((Probe)created.getData());
@@ -252,6 +244,12 @@
for (int i = 0; i < object.getMessungen().size(); i++) {
create(object.getMessungen().get(i), newProbe.getId(), newProbe.getMstId());
}
+ Violation violation = probeValidator.validate(newProbe);
+ for (Entry<String, List<Integer>> warn : violation.getWarnings().entrySet()) {
+ for (Integer code : warn.getValue()) {
+ currentWarnings.add(new ReportItem("validation", warn.getKey(), code));
+ }
+ }
if (currentErrors.size() > 0) {
errors.put(object.getIdentifier(),
new ArrayList<ReportItem>(currentErrors));
More information about the Lada-commits
mailing list