Skip to content

Commit

Permalink
#640 - change address map id from title
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed Nov 6, 2023
1 parent f8a1770 commit 9674a24
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,14 @@ public Resource<SubjectMigration> process(Resource<SubjectMigration> resource) {
@RequestMapping(value = "/subjectMigration/bulk", method = RequestMethod.POST)
@PreAuthorize(value = "hasAnyAuthority('user')")
public void migrate(@RequestBody SubjectMigrationRequest subjectMigrationRequest) {
Map<String, String> destinationAddresses = subjectMigrationRequest.getDestinationAddresses();
Map<Long, Long> destinationAddresses = subjectMigrationRequest.getDestinationAddresses();

AddressLevelType sourceType = addressLevelTypeRepository.findOne(subjectMigrationRequest.getSourceAddressTypeId());
AddressLevelType destType = addressLevelTypeRepository.findOne(subjectMigrationRequest.getDestAddressTypeId());
for (Map.Entry<Long, Long> destinationAddressEntry : destinationAddresses.entrySet()) {
Long source = destinationAddressEntry.getKey();
Long dest = destinationAddressEntry.getValue();

for (Map.Entry<String, String> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,9 @@
import java.util.Map;

public class SubjectMigrationRequest {
private Map<String, String> destinationAddresses;
private long sourceAddressTypeId;
private long destAddressTypeId;
private Map<Long, Long> destinationAddresses;
private List<Long> 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<Long> getSubjectTypeIds() {
return subjectTypeIds;
}
Expand All @@ -33,11 +15,11 @@ public void setSubjectTypeIds(List<Long> subjectTypeIds) {
this.subjectTypeIds = subjectTypeIds;
}

public Map<String, String> getDestinationAddresses() {
public Map<Long, Long> getDestinationAddresses() {
return destinationAddresses;
}

public void setDestinationAddresses(Map<String, String> destinationAddresses) {
public void setDestinationAddresses(Map<Long, Long> destinationAddresses) {
this.destinationAddresses = destinationAddresses;
}
}

0 comments on commit 9674a24

Please sign in to comment.