Skip to content
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
5 changes: 2 additions & 3 deletions src/breeding-insight/dao/StudyDAO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ import {BrAPIDAOUtil} from "@/breeding-insight/dao/BrAPIDAOUtil";

export class StudyDAO {

static async getAllForTrial(programId: string, externalReferenceId: string): Promise<Result<Error, BiResponse>> {
static async getAllForTrial(programId: string, trialDbId: string): Promise<Result<Error, BiResponse>> {
// 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;

Expand Down
15 changes: 8 additions & 7 deletions src/breeding-insight/service/StudyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Result<Error, [Study[], Metadata]>> {
Expand All @@ -39,12 +38,14 @@ export class StudyService {
if(!programId) throw new Error('missing or invalid program id');

let response: Result<Error, BiResponse>;
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<Error, BiResponse>;
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<Error, BiResponse>;
} else {
response = await StudyDAO.getAll(programId, paginationQuery, full) as Result<Error, BiResponse>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
Loading