From 0f6c4a1ef7f79580caeb8fee52a1e379baccbda0 Mon Sep 17 00:00:00 2001 From: Christopher Hubert Date: Thu, 2 May 2024 10:13:58 -0400 Subject: [PATCH 1/3] MAT-7148: remove dbref and add the second measureSet query back --- .../controllers/CqlLibraryController.java | 9 +++++++++ .../cms/madie/cqllibraryservice/dto/LibraryListDTO.java | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/gov/cms/madie/cqllibraryservice/controllers/CqlLibraryController.java b/src/main/java/gov/cms/madie/cqllibraryservice/controllers/CqlLibraryController.java index 08ade16..e63366d 100644 --- a/src/main/java/gov/cms/madie/cqllibraryservice/controllers/CqlLibraryController.java +++ b/src/main/java/gov/cms/madie/cqllibraryservice/controllers/CqlLibraryController.java @@ -3,6 +3,7 @@ import gov.cms.madie.cqllibraryservice.dto.LibraryListDTO; import gov.cms.madie.cqllibraryservice.exceptions.InvalidIdException; import gov.cms.madie.cqllibraryservice.exceptions.InvalidResourceStateException; +import gov.cms.madie.cqllibraryservice.repositories.LibrarySetRepository; import gov.cms.madie.cqllibraryservice.services.ActionLogService; import gov.cms.madie.cqllibraryservice.services.LibrarySetService; import gov.cms.madie.cqllibraryservice.utils.AuthUtils; @@ -19,6 +20,7 @@ import java.util.Optional; import java.util.UUID; +import gov.cms.madie.models.library.LibrarySet; import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; @@ -42,6 +44,7 @@ public class CqlLibraryController { private final VersionService versionService; private final CqlLibraryService cqlLibraryService; private final LibrarySetService librarySetService; + private final LibrarySetRepository librarySetRepository; @GetMapping public ResponseEntity> getCqlLibraries( @@ -53,6 +56,12 @@ public ResponseEntity> getCqlLibraries( filterByCurrentUser ? cqlLibraryRepository.findAllLibrariesByUser(username) : cqlLibraryRepository.findAllProjected(); + cqlLibraries.forEach( + l -> { + LibrarySet librarySet = + librarySetRepository.findByLibrarySetId(l.getLibrarySetId()).orElse(null); + l.setLibrarySet(librarySet); + }); return ResponseEntity.ok(cqlLibraries); } diff --git a/src/main/java/gov/cms/madie/cqllibraryservice/dto/LibraryListDTO.java b/src/main/java/gov/cms/madie/cqllibraryservice/dto/LibraryListDTO.java index e0bcc38..a97acf8 100644 --- a/src/main/java/gov/cms/madie/cqllibraryservice/dto/LibraryListDTO.java +++ b/src/main/java/gov/cms/madie/cqllibraryservice/dto/LibraryListDTO.java @@ -14,9 +14,9 @@ import lombok.experimental.SuperBuilder; import org.springframework.data.mongodb.core.mapping.DBRef; import org.springframework.data.mongodb.core.mapping.Document; +import org.springframework.data.mongodb.core.mapping.DocumentReference; @Data -@Document @SuperBuilder(toBuilder = true) @NoArgsConstructor public class LibraryListDTO { @@ -37,7 +37,7 @@ public class LibraryListDTO { @JsonDeserialize(using = VersionJsonSerializer.VersionDeserializer.class) private Version version; - @DBRef private LibrarySet librarySet; + @DocumentReference private LibrarySet librarySet; private boolean draft; } From 63e595e4472088519a6457b8f5a58c42424ada72 Mon Sep 17 00:00:00 2001 From: Christopher Hubert Date: Thu, 2 May 2024 10:21:03 -0400 Subject: [PATCH 2/3] MAT-7148: remove dbref and add the second measureSet query back --- .../java/gov/cms/madie/cqllibraryservice/dto/LibraryListDTO.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/gov/cms/madie/cqllibraryservice/dto/LibraryListDTO.java b/src/main/java/gov/cms/madie/cqllibraryservice/dto/LibraryListDTO.java index a97acf8..ac71ddc 100644 --- a/src/main/java/gov/cms/madie/cqllibraryservice/dto/LibraryListDTO.java +++ b/src/main/java/gov/cms/madie/cqllibraryservice/dto/LibraryListDTO.java @@ -17,6 +17,7 @@ import org.springframework.data.mongodb.core.mapping.DocumentReference; @Data +@Document @SuperBuilder(toBuilder = true) @NoArgsConstructor public class LibraryListDTO { From 645a2e650f4ef077a72c86845abcafd84e7440fe Mon Sep 17 00:00:00 2001 From: Christopher Hubert Date: Thu, 2 May 2024 10:21:56 -0400 Subject: [PATCH 3/3] MAT-7148: remove unused import --- .../java/gov/cms/madie/cqllibraryservice/dto/LibraryListDTO.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/gov/cms/madie/cqllibraryservice/dto/LibraryListDTO.java b/src/main/java/gov/cms/madie/cqllibraryservice/dto/LibraryListDTO.java index ac71ddc..d0d4d4e 100644 --- a/src/main/java/gov/cms/madie/cqllibraryservice/dto/LibraryListDTO.java +++ b/src/main/java/gov/cms/madie/cqllibraryservice/dto/LibraryListDTO.java @@ -12,7 +12,6 @@ import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; -import org.springframework.data.mongodb.core.mapping.DBRef; import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.DocumentReference;