From 5d9e973fa5f2bcb797f5feebb3e88fedd3114270 Mon Sep 17 00:00:00 2001 From: humsika Date: Thu, 3 Sep 2026 11:21:47 -0400 Subject: [PATCH] [BI-2920] BI-2920: Replaced external reference IDs with trailDbId and studyDbId in Study flow. --- src/breeding-insight/dao/StudyDAO.ts | 5 ++--- src/breeding-insight/service/StudyService.ts | 15 ++++++++------- .../ExperimentObservationsDownloadModal.vue | 3 +-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/breeding-insight/dao/StudyDAO.ts b/src/breeding-insight/dao/StudyDAO.ts index 331444d7e..69ebdccf1 100644 --- a/src/breeding-insight/dao/StudyDAO.ts +++ b/src/breeding-insight/dao/StudyDAO.ts @@ -23,14 +23,13 @@ import {BrAPIDAOUtil} from "@/breeding-insight/dao/BrAPIDAOUtil"; export class StudyDAO { - static async getAllForTrial(programId: string, externalReferenceId: string): Promise> { + static async getAllForTrial(programId: string, trialDbId: string): Promise> { // Use GET endpoint to get all Studies for a single Trial by external reference. const { data } = await api.call({ url: `${process.env.VUE_APP_BI_API_V1_PATH}/programs/${programId}/brapi/v2/studies`, method: 'get', params: { - externalReferenceId: externalReferenceId, - externalReferenceSource: `${process.env.VUE_APP_BI_REFERENCE_SOURCE}/trials`, + trialDbId: trialDbId, pageSize: 1000000 } }) as Response; diff --git a/src/breeding-insight/service/StudyService.ts b/src/breeding-insight/service/StudyService.ts index e52bc5e3d..e9aeeb4b0 100644 --- a/src/breeding-insight/service/StudyService.ts +++ b/src/breeding-insight/service/StudyService.ts @@ -22,7 +22,6 @@ import {PaginationQuery} from "@/breeding-insight/model/PaginationQuery"; import {PaginationUtilities} from "@/breeding-insight/model/view_models/PaginationUtilities"; import {Result, ResultGenerator } from "@/breeding-insight/model/Result"; import {Trial} from "@/breeding-insight/model/Trial"; -import {BrAPIUtils} from "@/breeding-insight/utils/BrAPIUtils"; export class StudyService { static async getAll(programId: string, trial?: Trial, paginationQuery?: PaginationQuery, full?: boolean): Promise> { @@ -39,12 +38,14 @@ export class StudyService { if(!programId) throw new Error('missing or invalid program id'); let response: Result; - if (trial !== undefined && trial.externalReferences !== undefined) { - // TODO: Change to trialDbId when fixing bi-brapi study endpoint [BI-2962] - let externalReferenceId = BrAPIUtils.getBreedingInsightId(trial.externalReferences, '/trials'); - // Throw if trial is missing ExternalReferenceId. - if (externalReferenceId === undefined) throw new Error("Trial is missing external reference."); - response = await StudyDAO.getAllForTrial(programId, externalReferenceId) as Result; + if (trial !== undefined) { + let trialDbId = trial.trialDbId; //Use the real BrAPI Trial ID + + if (!trialDbId) { + throw new Error("Trial is missing a brapi dbId."); + } + + response = await StudyDAO.getAllForTrial(programId, trialDbId) as Result; } else { response = await StudyDAO.getAll(programId, paginationQuery, full) as Result; } diff --git a/src/components/experiments/ExperimentObservationsDownloadModal.vue b/src/components/experiments/ExperimentObservationsDownloadModal.vue index 653204d8d..911962ee1 100644 --- a/src/components/experiments/ExperimentObservationsDownloadModal.vue +++ b/src/components/experiments/ExperimentObservationsDownloadModal.vue @@ -163,7 +163,6 @@ import {Metadata} from "@/breeding-insight/model/BiResponse"; import {Study} from "@/breeding-insight/model/Study"; import {StudyService} from "@/breeding-insight/service/StudyService"; import {Result} from "@/breeding-insight/model/Result"; -import {BrAPIUtils} from "@/breeding-insight/utils/BrAPIUtils"; import DownloadModal from "@/components/modals/DownloadModal.vue"; import {DatasetMetadata} from "@/breeding-insight/model/DatasetMetadata"; import {ExperimentService} from "@/breeding-insight/service/ExperimentService"; @@ -215,7 +214,7 @@ export default class ExperimentObservationsDownloadModal extends Vue { if(response.isErr()) throw response.value; let [studies, metadata] = response.value; // Set environment options. - this.environmentOptions = studies.map((s) => ({id: BrAPIUtils.getBreedingInsightId(s.externalReferences!, '/studies'), name: s.name})); + this.environmentOptions = studies.map((s) => ({id: s.id, name: s.name})); this.loadingStudyOptionsComplete = true; } catch (error) { // Display error that studies cannot be loaded