From 50dc3a43dd2d47fe1bd565b5be22eac4fc4306ba Mon Sep 17 00:00:00 2001 From: chubert-sb <85900348+chubert-sb@users.noreply.github.com> Date: Thu, 2 May 2024 11:35:53 -0400 Subject: [PATCH] MAT-7148: include librarySet query (#70) * MAT-7148: remove dbref and add the second measureSet query back * MAT-7148: remove dbref and add the second measureSet query back * MAT-7148: remove unused import --- .../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..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,8 +12,8 @@ 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; @Data @Document @@ -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; }