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; }