Skip to content

Commit

Permalink
#640 - fixed checklist update query. use id map instead of title map …
Browse files Browse the repository at this point in the history
…for migration
  • Loading branch information
petmongrels committed Nov 6, 2023
1 parent 9674a24 commit 2dc2555
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ default boolean isEntityChanged(SyncParameters syncParameters){

@Modifying(clearAutomatically = true)
@Query(value = "update checklist_item ci set last_modified_date_time = :lastModifiedDateTime, last_modified_by_id = :lastModifiedById" +
" from program_enrolment pe, checklist c where c.id = ci.checklist_id and pe.id = c.program_enrolment_id and pe.id = :individualId", nativeQuery = true)
" from program_enrolment pe, checklist c where c.id = ci.checklist_id and pe.id = c.program_enrolment_id and pe.individual_id = :individualId", nativeQuery = true)
void setChangedForSync(Long individualId, Date lastModifiedDateTime, Long lastModifiedById);
default void setChangedForSync(Individual individual) {
this.setChangedForSync(individual.getId(), new Date(), UserContextHolder.getUserId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ default boolean isEntityChanged(SyncParameters syncParameters){

@Modifying(clearAutomatically = true)
@Query(value = "update checklist c set last_modified_date_time = :lastModifiedDateTime, last_modified_by_id = :lastModifiedById" +
" from program_enrolment pe where pe.id = c.program_enrolment_id and pe.id = :individualId", nativeQuery = true)
" from program_enrolment pe where pe.id = c.program_enrolment_id and pe.individual_id = :individualId", nativeQuery = true)
void setChangedForSync(Long individualId, Date lastModifiedDateTime, Long lastModifiedById);
default void setChangedForSync(Individual individual) {
this.setChangedForSync(individual.getId(), new Date(), UserContextHolder.getUserId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ 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<Long, Long> destinationAddresses = subjectMigrationRequest.getDestinationAddresses();
Map<String, String> destinationAddresses = subjectMigrationRequest.getDestinationAddresses();

for (Map.Entry<Long, Long> destinationAddressEntry : destinationAddresses.entrySet()) {
Long source = destinationAddressEntry.getKey();
Long dest = destinationAddressEntry.getValue();
for (Map.Entry<String, String> destinationAddressEntry : destinationAddresses.entrySet()) {
Long source = Long.parseLong(destinationAddressEntry.getKey());
Long dest = Long.parseLong(destinationAddressEntry.getValue());

AddressLevel sourceAddressLevel = locationRepository.findOne(source);
AddressLevel destAddressLevel = locationRepository.findOne(dest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.Map;

public class SubjectMigrationRequest {
private Map<Long, Long> destinationAddresses;
private Map<String, String> destinationAddresses;
private List<Long> subjectTypeIds;

public List<Long> getSubjectTypeIds() {
Expand All @@ -15,11 +15,11 @@ public void setSubjectTypeIds(List<Long> subjectTypeIds) {
this.subjectTypeIds = subjectTypeIds;
}

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

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

0 comments on commit 2dc2555

Please sign in to comment.