comparison src/main/java/de/intevation/lada/rest/stamm/OrtService.java @ 1231:32e27cb8cfef

Use validation rule on update as well.
author Tom Gottfried <tom@intevation.de>
date Fri, 09 Dec 2016 18:20:22 +0100
parents a0968660a4c5
children e49c006b9076
comparison
equal deleted inserted replaced
1230:f48be4a5c6a0 1231:32e27cb8cfef
328 RequestMethod.PUT, 328 RequestMethod.PUT,
329 Ort.class) 329 Ort.class)
330 ) { 330 ) {
331 return new Response(false, 699, ort); 331 return new Response(false, 699, ort);
332 } 332 }
333 QueryBuilder<Ort> builder = 333
334 new QueryBuilder<Ort>( 334 Violation violation = validator.validate(ort);
335 repository.entityManager("stamm"), 335 if (violation.hasErrors()) {
336 Ort.class 336 Response response = new Response(false, 604, ort);
337 ); 337 response.setErrors(violation.getErrors());
338 builder.and("ortId", ort.getOrtId()); 338 response.setWarnings(violation.getWarnings());
339 builder.and("netzbetreiberId", ort.getNetzbetreiberId()); 339 return response;
340 340 }
341 List<Ort> orte = 341
342 repository.filterPlain(builder.getQuery(), "stamm"); 342 ortFactory.transformCoordinates(ort);
343 if (orte.isEmpty() || 343 Response response = repository.update(ort, "stamm");
344 orte.get(0).getId() == ort.getId()) { 344 if(violation.hasWarnings()) {
345 return repository.update(ort, "stamm"); 345 response.setWarnings(violation.getWarnings());
346 } 346 }
347 return new Response(false, 672, null); 347
348 return response;
348 } 349 }
349 350
350 /** 351 /**
351 * Delete an existing SOrt object by id. 352 * Delete an existing SOrt object by id.
352 * <p> 353 * <p>
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)