# HG changeset patch # User Tom Gottfried # Date 1481304022 -3600 # Node ID 32e27cb8cfef12b2b7bd5a0049fb2284d08429fa # Parent f48be4a5c6a002ecc5efabe6d5fd5c2895112721 Use validation rule on update as well. diff -r f48be4a5c6a0 -r 32e27cb8cfef src/main/java/de/intevation/lada/rest/stamm/OrtService.java --- a/src/main/java/de/intevation/lada/rest/stamm/OrtService.java Fri Dec 09 18:15:42 2016 +0100 +++ b/src/main/java/de/intevation/lada/rest/stamm/OrtService.java Fri Dec 09 18:20:22 2016 +0100 @@ -330,21 +330,22 @@ ) { return new Response(false, 699, ort); } - QueryBuilder builder = - new QueryBuilder( - repository.entityManager("stamm"), - Ort.class - ); - builder.and("ortId", ort.getOrtId()); - builder.and("netzbetreiberId", ort.getNetzbetreiberId()); - List orte = - repository.filterPlain(builder.getQuery(), "stamm"); - if (orte.isEmpty() || - orte.get(0).getId() == ort.getId()) { - return repository.update(ort, "stamm"); + Violation violation = validator.validate(ort); + if (violation.hasErrors()) { + Response response = new Response(false, 604, ort); + response.setErrors(violation.getErrors()); + response.setWarnings(violation.getWarnings()); + return response; } - return new Response(false, 672, null); + + ortFactory.transformCoordinates(ort); + Response response = repository.update(ort, "stamm"); + if(violation.hasWarnings()) { + response.setWarnings(violation.getWarnings()); + } + + return response; } /**