From b086797b7c5ca6d859743c15abc5e38671253da0 Mon Sep 17 00:00:00 2001 From: Joy A Date: Thu, 3 Oct 2024 10:41:52 +0530 Subject: [PATCH] avniproject/avni-webapp#1290 | Rename Address level type on deletion so name can be reused --- .../java/org/avni/server/web/AddressLevelTypeController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/avni-server-api/src/main/java/org/avni/server/web/AddressLevelTypeController.java b/avni-server-api/src/main/java/org/avni/server/web/AddressLevelTypeController.java index 5a41c7a73..4eb6c1b9c 100644 --- a/avni-server-api/src/main/java/org/avni/server/web/AddressLevelTypeController.java +++ b/avni-server-api/src/main/java/org/avni/server/web/AddressLevelTypeController.java @@ -4,6 +4,7 @@ import org.avni.server.domain.AddressLevel; import org.avni.server.domain.AddressLevelType; import org.avni.server.domain.accessControl.PrivilegeType; +import org.avni.server.domain.util.EntityUtil; import org.avni.server.service.LocationService; import org.avni.server.service.accessControl.AccessControlService; import org.avni.server.util.ReactAdminUtil; @@ -120,6 +121,7 @@ public ResponseEntity voidAddressLevelType(@PathVariable("id") Long id) { return ResponseEntity.badRequest().body(ReactAdminUtil.generateJsonError( String.format("Cannot delete '%s'. Sub location types or locations of this type exist. Please delete them to proceed.", addressLevelType.getName()))); } + addressLevelType.setName(EntityUtil.getVoidedName(addressLevelType.getName(), addressLevelType.getId())); addressLevelType.setVoided(true); return new ResponseEntity<>(addressLevelType, HttpStatus.OK); }