From 0f6c4a1ef7f79580caeb8fee52a1e379baccbda0 Mon Sep 17 00:00:00 2001 From: Christopher Hubert Date: Thu, 2 May 2024 10:13:58 -0400 Subject: [PATCH] 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; }