diff --git a/src/main/java/de/muenchen/dave/controller/MessstelleController.java b/src/main/java/de/muenchen/dave/controller/MessstelleController.java index ba49a4f0..88a86e0f 100644 --- a/src/main/java/de/muenchen/dave/controller/MessstelleController.java +++ b/src/main/java/de/muenchen/dave/controller/MessstelleController.java @@ -31,16 +31,18 @@ public class MessstelleController { private static final String REQUEST_PARAMETER_ID = "id"; + private static final String REQUEST_PARAMETER_MSTID = "mstid"; private final MessstelleService messstelleService; @PreAuthorize( "hasAnyRole(T(de.muenchen.dave.security.AuthoritiesEnum).ANWENDER.name(), " + "T(de.muenchen.dave.security.AuthoritiesEnum).POWERUSER.name())" ) - @GetMapping(value = "/info", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(value = "/info", params = REQUEST_PARAMETER_ID, produces = MediaType.APPLICATION_JSON_VALUE) @Transactional(readOnly = true) - public ResponseEntity readMessstelleInfo(@RequestParam(value = REQUEST_PARAMETER_ID) final String messstelleId) { - log.debug("#readMessstelleInfo with id {}", messstelleId); + public ResponseEntity readMessstelleInfoById( + @RequestParam(value = REQUEST_PARAMETER_ID) final String messstelleId) { + log.debug("#readMessstelleInfoById with id {}", messstelleId); try { final ReadMessstelleInfoDTO readMessstelleDTO = this.messstelleService.readMessstelleInfo(messstelleId); return ResponseEntity.ok(readMessstelleDTO); @@ -53,6 +55,23 @@ public ResponseEntity readMessstelleInfo(@RequestParam(va } } + @GetMapping(value = "/info", params = REQUEST_PARAMETER_MSTID, produces = MediaType.APPLICATION_JSON_VALUE) + @Transactional(readOnly = true) + public ResponseEntity readMessstelleInfoByMstId( + @RequestParam(value = REQUEST_PARAMETER_MSTID) final String mstId) { + log.debug("#readMessstelleInfoByMstId with id {}", mstId); + try { + final ReadMessstelleInfoDTO readMessstelleDTO = this.messstelleService.readMessstelleInfoByMstId(mstId); + return ResponseEntity.ok(readMessstelleDTO); + } catch (final ResourceNotFoundException e) { + log.error("Fehler im MessstelleController, Messstelle konnte nicht gefunden werden. ID: {}", mstId, e); + throw e; + } catch (final Exception e) { + log.error("Unerwarteter Fehler im MessstelleController beim Laden der Messstelle mit der ID: {}", mstId, e); + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Es ist ein unerwarteter Fehler beim Laden der Messstelle aufgetreten."); + } + } + /** * Diese Methode erlaubt das Aktualisieren einer Messstelle. * diff --git a/src/main/java/de/muenchen/dave/services/messstelle/MessstelleService.java b/src/main/java/de/muenchen/dave/services/messstelle/MessstelleService.java index 711cf8bb..e7cc0f9d 100644 --- a/src/main/java/de/muenchen/dave/services/messstelle/MessstelleService.java +++ b/src/main/java/de/muenchen/dave/services/messstelle/MessstelleService.java @@ -50,6 +50,11 @@ public ReadMessstelleInfoDTO readMessstelleInfo(final String messstelleId) { return messstelleMapper.bean2readDto(byIdOrThrowException, stadtbezirkMapper); } + public ReadMessstelleInfoDTO readMessstelleInfoByMstId(final String mstId) { + final Messstelle byIdOrThrowException = messstelleIndexService.findByMstIdOrThrowException(mstId); + return messstelleMapper.bean2readDto(byIdOrThrowException, stadtbezirkMapper); + } + public EditMessstelleDTO getMessstelleToEdit(final String messstelleId) { final Messstelle byIdOrThrowException = messstelleIndexService.findByIdOrThrowException(messstelleId); byIdOrThrowException.setMessfaehigkeiten(