From 2ec78cf384a29eb8616acc37a02b2245f225b7b8 Mon Sep 17 00:00:00 2001 From: himeshr Date: Wed, 21 Aug 2024 14:42:41 +0530 Subject: [PATCH] #776 | Perform Genders existence check specific to org --- .../src/main/java/org/avni/server/dao/GenderRepository.java | 1 + .../main/java/org/avni/server/service/OrganisationService.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/avni-server-api/src/main/java/org/avni/server/dao/GenderRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/GenderRepository.java index e4da3b7dd..a875043a7 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/GenderRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/GenderRepository.java @@ -9,6 +9,7 @@ @RepositoryRestResource(collectionResourceRel = "gender", path = "gender") public interface GenderRepository extends CHSRepository, CustomCHSJpaRepository, FindByLastModifiedDateTime { Gender findByName(String name); + Gender findByNameAndOrganisationId(String name, Long organisationId); Gender findByNameIgnoreCase(String name); @RestResource(exported = false) diff --git a/avni-server-api/src/main/java/org/avni/server/service/OrganisationService.java b/avni-server-api/src/main/java/org/avni/server/service/OrganisationService.java index 9b45163d0..538ffc34e 100644 --- a/avni-server-api/src/main/java/org/avni/server/service/OrganisationService.java +++ b/avni-server-api/src/main/java/org/avni/server/service/OrganisationService.java @@ -915,7 +915,7 @@ public void addGroupDashboardJson(ZipOutputStream zos) throws IOException { } private void createGender(String genderName, Organisation org) { - if (Objects.nonNull(genderRepository.findByName(genderName))) { + if (Objects.nonNull(genderRepository.findByNameAndOrganisationId(genderName, org.getId()))) { return; } Gender gender = new Gender();