diff --git a/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/repository/LocationRepository.java b/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/repository/LocationRepository.java index f1dcd937c4f..22661d93fe5 100644 --- a/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/repository/LocationRepository.java +++ b/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/repository/LocationRepository.java @@ -145,10 +145,6 @@ List findLocationByHierarchyLevelStartsWith(Short hierarchyLevel, Stri @Query("FROM Location l WHERE l.name=?1 AND l.hierarchyLevel=?2 AND l.langCode=?3 AND NOT code=?4") List findByNameAndLevelLangCodeNotCode(String name,Short hierarchyLevel, String langCode, String code); - - @Query("FROM Location l WHERE l.name=?1 AND l.parentLocCode=?2 AND l.hierarchyLevel=?3 AND l.langCode=?4 AND l.isActive=true AND NOT code=?5" ) - List findByNameParentLoccodeAndLevelLangCodeNotCode(String name, String parentCode,Short hierarchyLevel, String langCode, String code); - /** * give list of the immediate Locations for the given parent location code * diff --git a/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/service/impl/LocationServiceImpl.java b/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/service/impl/LocationServiceImpl.java index b0c92a37b31..64416859674 100644 --- a/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/service/impl/LocationServiceImpl.java +++ b/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/service/impl/LocationServiceImpl.java @@ -313,8 +313,7 @@ public LocationPutResponseDto updateLocationDetails(LocationDto locationDto) { throw new RequestException(LocationErrorCode.INVALID_HIERARCY_LEVEL.getErrorCode(), LocationErrorCode.INVALID_HIERARCY_LEVEL.getErrorMessage()); } - List list = (null!=locationDto.getParentLocCode() && !locationDto.getParentLocCode().isEmpty())? locationRepository.findByNameParentLoccodeAndLevelLangCodeNotCode(locationDto.getName(), - locationDto.getParentLocCode(), locationDto.getHierarchyLevel(), locationDto.getLangCode(), locationDto.getCode()): locationRepository.findByNameAndLevelLangCodeNotCode(locationDto.getName(), + List list = locationRepository.findByNameAndLevelLangCodeNotCode(locationDto.getName(), locationDto.getHierarchyLevel(), locationDto.getLangCode(), locationDto.getCode()); if (list != null && !list.isEmpty()) { auditUtil.auditRequest( diff --git a/admin/kernel-masterdata-service/src/test/java/io/mosip/kernel/masterdata/test/integration/LocationControllerIntegrationTest.java b/admin/kernel-masterdata-service/src/test/java/io/mosip/kernel/masterdata/test/integration/LocationControllerIntegrationTest.java index 19a05e6aa87..ec0a59c4581 100644 --- a/admin/kernel-masterdata-service/src/test/java/io/mosip/kernel/masterdata/test/integration/LocationControllerIntegrationTest.java +++ b/admin/kernel-masterdata-service/src/test/java/io/mosip/kernel/masterdata/test/integration/LocationControllerIntegrationTest.java @@ -243,8 +243,6 @@ public void updateLocationAlreadyExistsUnderHeirarchyExceptionTest() throws Exce dto1.setIsActive(true); request.setRequest(dto1); String requestJson = mapper.writeValueAsString(request); - when(repo.findByNameParentLoccodeAndLevelLangCodeNotCode(Mockito.any(),Mockito.any(),Mockito.any(),Mockito.any(), Mockito.any())) - .thenReturn(Arrays.asList(location1)); when(repo.findLocationHierarchyByCodeAndLanguageCode(Mockito.any(), Mockito.any())) .thenReturn(Arrays.asList(location1)); when(repo.findByNameAndLevelLangCodeNotCode(Mockito.any(),Mockito.any(),Mockito.any(), Mockito.any())).thenReturn(Arrays.asList(location1));