Skip to content

Commit

Permalink
MAT-7148: remove dbref and add the second measureSet query back
Browse files Browse the repository at this point in the history
  • Loading branch information
chubert-sb committed May 2, 2024
1 parent 0c3cbcb commit 0f6c4a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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 @@ -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 {
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;
}

0 comments on commit 0f6c4a1

Please sign in to comment.