From 9674a249793775153a5fdec27103937ba39741f7 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Mon, 6 Nov 2023 13:20:59 +0530 Subject: [PATCH] #640 - change address map id from title --- .../service/SubjectMigrationService.java | 2 +- .../web/SubjectMigrationController.java | 15 +++++------- .../web/request/SubjectMigrationRequest.java | 24 +++---------------- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/avni-server-api/src/main/java/org/avni/server/service/SubjectMigrationService.java b/avni-server-api/src/main/java/org/avni/server/service/SubjectMigrationService.java index 62dbd6157..ffd839e57 100644 --- a/avni-server-api/src/main/java/org/avni/server/service/SubjectMigrationService.java +++ b/avni-server-api/src/main/java/org/avni/server/service/SubjectMigrationService.java @@ -110,8 +110,8 @@ public void markSubjectMigrationIfRequired(String individualUuid, AddressLevel n encounterRepository.updateSyncAttributesForIndividual(individual.getId(), newAddressLevel.getId(), newObsSingleStringValueSyncConcept1, newObsSingleStringValueSyncConcept2); programEnrolmentRepository.updateSyncAttributesForIndividual(individual.getId(), newAddressLevel.getId(), newObsSingleStringValueSyncConcept1, newObsSingleStringValueSyncConcept2); programEncounterRepository.updateSyncAttributes(individual.getId(), newAddressLevel.getId(), newObsSingleStringValueSyncConcept1, newObsSingleStringValueSyncConcept2); + groupSubjectRepository.updateSyncAttributesForGroupSubject(individual.getId(), newAddressLevel.getId(), newObsSingleStringValueSyncConcept1, newObsSingleStringValueSyncConcept2); if (!executingInBulk) { - groupSubjectRepository.updateSyncAttributesForGroupSubject(individual.getId(), newAddressLevel.getId(), newObsSingleStringValueSyncConcept1, newObsSingleStringValueSyncConcept2); groupSubjectRepository.updateSyncAttributesForMemberSubject(individual.getId(), newAddressLevel.getId()); } entityApprovalStatusRepository.updateSyncAttributesForIndividual(individual.getId(), newAddressLevel.getId(), newObsSingleStringValueSyncConcept1, newObsSingleStringValueSyncConcept2); diff --git a/avni-server-api/src/main/java/org/avni/server/web/SubjectMigrationController.java b/avni-server-api/src/main/java/org/avni/server/web/SubjectMigrationController.java index 48f07187d..2c7f4a623 100644 --- a/avni-server-api/src/main/java/org/avni/server/web/SubjectMigrationController.java +++ b/avni-server-api/src/main/java/org/avni/server/web/SubjectMigrationController.java @@ -100,17 +100,14 @@ public Resource process(Resource resource) { @RequestMapping(value = "/subjectMigration/bulk", method = RequestMethod.POST) @PreAuthorize(value = "hasAnyAuthority('user')") public void migrate(@RequestBody SubjectMigrationRequest subjectMigrationRequest) { - Map destinationAddresses = subjectMigrationRequest.getDestinationAddresses(); + Map destinationAddresses = subjectMigrationRequest.getDestinationAddresses(); - AddressLevelType sourceType = addressLevelTypeRepository.findOne(subjectMigrationRequest.getSourceAddressTypeId()); - AddressLevelType destType = addressLevelTypeRepository.findOne(subjectMigrationRequest.getDestAddressTypeId()); + for (Map.Entry destinationAddressEntry : destinationAddresses.entrySet()) { + Long source = destinationAddressEntry.getKey(); + Long dest = destinationAddressEntry.getValue(); - for (Map.Entry destinationAddressEntry : destinationAddresses.entrySet()) { - String source = destinationAddressEntry.getKey(); - String dest = destinationAddressEntry.getValue(); - - AddressLevel sourceAddressLevel = locationRepository.findByTitleAndTypeAndIsVoidedFalse(source, sourceType); - AddressLevel destAddressLevel = locationRepository.findByTitleAndTypeAndIsVoidedFalse(dest, destType); + AddressLevel sourceAddressLevel = locationRepository.findOne(source); + AddressLevel destAddressLevel = locationRepository.findOne(dest); subjectMigrationRequest.getSubjectTypeIds().forEach(subjectTypeId -> { SubjectType subjectType = subjectTypeRepository.findOne(subjectTypeId); diff --git a/avni-server-api/src/main/java/org/avni/server/web/request/SubjectMigrationRequest.java b/avni-server-api/src/main/java/org/avni/server/web/request/SubjectMigrationRequest.java index 1b8bb085b..85f50b95c 100644 --- a/avni-server-api/src/main/java/org/avni/server/web/request/SubjectMigrationRequest.java +++ b/avni-server-api/src/main/java/org/avni/server/web/request/SubjectMigrationRequest.java @@ -4,27 +4,9 @@ import java.util.Map; public class SubjectMigrationRequest { - private Map destinationAddresses; - private long sourceAddressTypeId; - private long destAddressTypeId; + private Map destinationAddresses; private List subjectTypeIds; - public long getSourceAddressTypeId() { - return sourceAddressTypeId; - } - - public void setSourceAddressTypeId(long sourceAddressTypeId) { - this.sourceAddressTypeId = sourceAddressTypeId; - } - - public long getDestAddressTypeId() { - return destAddressTypeId; - } - - public void setDestAddressTypeId(long destAddressTypeId) { - this.destAddressTypeId = destAddressTypeId; - } - public List getSubjectTypeIds() { return subjectTypeIds; } @@ -33,11 +15,11 @@ public void setSubjectTypeIds(List subjectTypeIds) { this.subjectTypeIds = subjectTypeIds; } - public Map getDestinationAddresses() { + public Map getDestinationAddresses() { return destinationAddresses; } - public void setDestinationAddresses(Map destinationAddresses) { + public void setDestinationAddresses(Map destinationAddresses) { this.destinationAddresses = destinationAddresses; } }