Skip to content
Open
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 @@ -114,6 +114,7 @@ public HttpResponse<Response<DataResponse<List<BrAPIStudy>>>> getStudies(
return ResponseUtils.getBrapiQueryResponse(authorizedStudies, studyQueryMapper, queryParams, searchRequest);
}

// TODO: Instead of getting all studies for a program and filtering, doing the filtering on brapi side
List<BrAPIStudy> studies = studyService.getStudies(programId)
.stream()
.peek(this::setDbIds)
Expand Down Expand Up @@ -172,10 +173,6 @@ private void setDbIds(BrAPIStudy study) {
.orElseThrow(() -> new IllegalStateException("No BI external reference found"))
.getReferenceID());

study.trialDbId(Utilities.getExternalReference(study.getExternalReferences(), Utilities.generateReferenceSource(referenceSource, ExternalReferenceSource.TRIALS))
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of a get ahead of the curve change. It might be able to remain as is, but might be tough to find later on when we use trialDbIds directly for studies.

.orElseThrow(() -> new IllegalStateException("No BI external reference found"))
.getReferenceID());

//TODO update locationDbId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.micronaut.security.rules.SecurityRule;
import lombok.extern.slf4j.Slf4j;
import org.brapi.client.v2.model.exceptions.ApiException;
import org.brapi.v2.model.BrAPIExternalReference;
import org.brapi.v2.model.core.BrAPITrial;
import org.brapi.v2.model.core.response.BrAPITrialSingleResponse;
import org.breedinginsight.api.auth.*;
Expand Down Expand Up @@ -158,10 +159,8 @@ public HttpResponse<?> trialsTrialDbIdPut(@PathVariable("programId") UUID progra
return HttpResponse.notFound();
}

// TODO: Remove for trialDbId once cache is removed for that entity
private void setDbIds(BrAPITrial trial) {
trial.trialDbId(Utilities.getExternalReference(trial.getExternalReferences(), Utilities.generateReferenceSource(referenceSource, ExternalReferenceSource.TRIALS))
Copy link
Copy Markdown
Collaborator Author

@jloux-brapi jloux-brapi May 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was preventing the frontend effectively from being able to use brapiTrialDbIds in the router. Bit of a nasty bugger. Expecting more changes like this in the future for other entities.

.orElseThrow(() -> new IllegalStateException("No BI external reference found"))
.getReferenceID());
trial.programDbId(Utilities.getExternalReference(trial.getExternalReferences(), Utilities.generateReferenceSource(referenceSource, ExternalReferenceSource.PROGRAMS))
.orElseThrow(() -> new IllegalStateException("No BI external reference found"))
.getReferenceID());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public List<BrAPIStudy> getStudiesByName(List<String> studyNames, Program progra
}

public List<BrAPIStudy> getStudiesByExperimentID(@NotNull UUID experimentId, Program program) throws ApiException {
// TODO: This should look up on trialDbId, and the trialDbId should be passed thru
BrAPIStudySearchRequest studySearch = new BrAPIStudySearchRequest();
studySearch.programDbIds(List.of(program.getBrapiProgram().getProgramDbId()));
studySearch.addExternalReferenceIdsItem(experimentId.toString());
Expand Down Expand Up @@ -167,11 +168,7 @@ public List<BrAPIStudy> getStudiesByEnvironmentIds(@NotNull Collection<UUID> env
public List<BrAPIStudy> getStudiesByExperimentIds(@NotNull Collection<UUID> experimentIds, Program program) throws ApiException {
BrAPIStudySearchRequest studySearch = new BrAPIStudySearchRequest();
studySearch.programDbIds(List.of(program.getBrapiProgram().getProgramDbId()));
// Add all experimentIds as xref ID search terms.
for (UUID experimentId : experimentIds) {
studySearch.addExternalReferenceIdsItem(experimentId.toString());
}
studySearch.addExternalReferenceSourcesItem(Utilities.generateReferenceSource(referenceSource, ExternalReferenceSource.TRIALS));
studySearch.trialDbIds(experimentIds.stream().map(UUID::toString).collect(Collectors.toList()));
StudiesApi api = brAPIEndpointProvider.get(programDAO.getCoreClient(program.getId()), StudiesApi.class);
return new ArrayList<>(processStudyForDisplay(brAPIDAOUtil.search(
api::searchStudiesPost,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,9 @@ List<BrAPITrial> createBrAPITrials(List<BrAPITrial> brAPITrialList, UUID program

Optional<BrAPITrial> getTrialById(UUID programId, UUID trialId) throws ApiException, DoesNotExistException;

Optional<BrAPITrial> getTrialByDbId(String trialDbId, Program program) throws ApiException;

List<BrAPITrial> getTrialsByDbIds(Collection<String> trialDbIds, Program program) throws ApiException;

List<BrAPITrial> getTrialsByExperimentIds(Collection<UUID> experimentIds, Program program) throws ApiException;

void deleteBrAPITrial(Program program, BrAPITrial trial, boolean hard) throws ApiException;

void repopulateCache(UUID programId);
}
Loading
Loading