Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAT-7148: include librarySet query #70

Merged
merged 3 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<List<LibraryListDTO>> getCqlLibraries(
Expand All @@ -53,6 +56,12 @@ public ResponseEntity<List<LibraryListDTO>> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Loading