Skip to content

Commit

Permalink
MAT-7148: include librarySet query (#70)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
chubert-sb authored May 2, 2024
1 parent 0c3cbcb commit 50dc3a4
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 @@ -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;
}

0 comments on commit 50dc3a4

Please sign in to comment.