Mercurial > lada > lada-server
changeset 1151:7a9bc3fe0efd
Moved probe validation to have all subobject available during validation.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 07 Nov 2016 12:30:35 +0100 |
parents | cf1eb19f896b |
children | b81a515f765d |
files | src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java |
diffstat | 1 files changed, 12 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- 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));