diff --git a/src/assets/scss/main.scss b/src/assets/scss/main.scss index 3946d5641..6003102f3 100644 --- a/src/assets/scss/main.scss +++ b/src/assets/scss/main.scss @@ -900,3 +900,9 @@ tr:nth-child(odd) td.db-filled { display: block; } } + +label.environment-option-label { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} diff --git a/src/breeding-insight/dao/ExperimentDAO.ts b/src/breeding-insight/dao/ExperimentDAO.ts index 42b336b0f..c344fa5c8 100644 --- a/src/breeding-insight/dao/ExperimentDAO.ts +++ b/src/breeding-insight/dao/ExperimentDAO.ts @@ -19,8 +19,6 @@ import {BiResponse, Response} from "@/breeding-insight/model/BiResponse"; import * as api from "@/util/api"; import {Result, ResultGenerator} from "@/breeding-insight/model/Result"; import {Trial} from "@/breeding-insight/model/Trial.ts"; -import * as UUID from "uuid"; -import {PaginationQuery} from "@/breeding-insight/model/PaginationQuery"; import {DatasetModel} from "@/breeding-insight/model/DatasetModel"; export class ExperimentDAO { diff --git a/src/breeding-insight/dao/StudyDAO.ts b/src/breeding-insight/dao/StudyDAO.ts index 0d2e5e928..331444d7e 100644 --- a/src/breeding-insight/dao/StudyDAO.ts +++ b/src/breeding-insight/dao/StudyDAO.ts @@ -23,15 +23,18 @@ import {BrAPIDAOUtil} from "@/breeding-insight/dao/BrAPIDAOUtil"; export class StudyDAO { - static async getAllForTrial(programId: string, trialId: string): Promise> { + static async getAllForTrial(programId: string, externalReferenceId: 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`, + pageSize: 1000000 } + }) as Response; - const body = { - trialDbIds: [ - trialId - ] - }; - - return await BrAPIDAOUtil.search(`${process.env.VUE_APP_BI_API_V1_PATH}/programs/${programId}/brapi/v2/search/studies`, body); + return ResultGenerator.success(new BiResponse(data)); } static async getAll(programId: string, paginationQuery: PaginationQuery, full : boolean): Promise> { diff --git a/src/breeding-insight/model/EnvironmentOption.ts b/src/breeding-insight/model/EnvironmentOption.ts deleted file mode 100644 index a7646bafe..000000000 --- a/src/breeding-insight/model/EnvironmentOption.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * See the NOTICE file distributed with this work for additional information - * regarding copyright ownership. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {SelectOption} from "@/breeding-insight/model/SelectOption"; - -export class EnvironmentOption implements SelectOption { - static all = new EnvironmentOption("All", "all"); - - name: string; - id: string; - - constructor(name: string, id: string) { - this.name = name; - this.id = id; - } -} \ No newline at end of file diff --git a/src/breeding-insight/model/ExperimentExportOptions.ts b/src/breeding-insight/model/ExperimentExportOptions.ts index c1c7734ab..6476c079a 100644 --- a/src/breeding-insight/model/ExperimentExportOptions.ts +++ b/src/breeding-insight/model/ExperimentExportOptions.ts @@ -17,15 +17,15 @@ import {FileTypeOption} from "@/breeding-insight/model/FileTypeOption"; import {ExperimentDatasetOption} from "@/breeding-insight/model/ExperimentDatasetOption"; -import {EnvironmentOption} from "@/breeding-insight/model/EnvironmentOption"; // Stores the user selected options for Experiment Observation file export. export class ExperimentExportOptions { public fileExtension: string = FileTypeOption.xls.id; public dataset: string = ExperimentDatasetOption.observations.id; - public environments: string[] = [EnvironmentOption.all.id]; - public includeTimestamps: string = 'Yes'; + public environments: string[] = []; + public allEnvironments: boolean = false; + public includeTimestamps: string = 'No'; public timestampsTrueFalseString(): string { if (this.includeTimestamps.toLowerCase() === 'yes') diff --git a/src/breeding-insight/model/Study.ts b/src/breeding-insight/model/Study.ts index 56861c702..c3fcea8d0 100644 --- a/src/breeding-insight/model/Study.ts +++ b/src/breeding-insight/model/Study.ts @@ -15,6 +15,8 @@ * limitations under the License. */ +import {ExternalReferences} from "@/breeding-insight/brapi/model/externalReferences"; + export class Study { id?: string; name?: string; @@ -24,6 +26,8 @@ export class Study { endDate?: Date | null; location?: string; active?: boolean; + externalReferences?: ExternalReferences; + constructor(id?: string, name?: string, @@ -32,7 +36,8 @@ export class Study { startDate?: string, endDate?: string, location?: string, - active?: boolean + active?: boolean, + externalReferences?: ExternalReferences ) { this.id = id; this.name = name; @@ -50,13 +55,14 @@ export class Study { } else { this.active = true; } + this.externalReferences = externalReferences; } static assign(study: Study): Study { const start: string | undefined = study.startDate ? study.startDate.toISOString() : undefined; const end: string | undefined = study.endDate ? study.endDate.toISOString() : undefined; - return new Study(study.id, study.name, study.description, study.type, start, end, study.location, study.active); + return new Study(study.id, study.name, study.description, study.type, start, end, study.location, study.active, study.externalReferences); } equals(study?: Study): boolean { diff --git a/src/breeding-insight/service/BrAPIService.ts b/src/breeding-insight/service/BrAPIService.ts index 94dcb115e..cc277d0b7 100644 --- a/src/breeding-insight/service/BrAPIService.ts +++ b/src/breeding-insight/service/BrAPIService.ts @@ -44,7 +44,7 @@ export class BrAPIService { params['sortOrder'] = sort.order; } if (pagination.page || pagination.page == 0) { //have to account for 0-index pagination since 0 falsy - params ['page'] = pagination.page; + params['page'] = pagination.page; } if (pagination.pageSize) { params['pageSize'] = pagination.pageSize; diff --git a/src/breeding-insight/service/ProgramService.ts b/src/breeding-insight/service/ProgramService.ts index ec20f3e2d..7bcacff21 100644 --- a/src/breeding-insight/service/ProgramService.ts +++ b/src/breeding-insight/service/ProgramService.ts @@ -38,7 +38,7 @@ export class ProgramService { if (program.id === undefined) { ProgramDAO.create(program).then((biResponse) => { const result: any = biResponse.result; - const newProgram = new Program(result.id, result.name, result.species.id, result.numUsers, result.brapiUrl); + const newProgram = new Program(result.id, result.name, result.species.id, result.numUsers, result.brapiUrl, result.key); resolve(newProgram); }).catch((error) => { @@ -68,7 +68,7 @@ export class ProgramService { if (program.id) { ProgramDAO.update(program.id, program).then((biResponse) => { const result: any = biResponse.result; - const newProgram = new Program(result.id, result.name, result.species.id, result.numUsers, result.brapiUrl); + const newProgram = new Program(result.id, result.name, result.species.id, result.numUsers, result.brapiUrl, result.key); resolve(newProgram); }).catch((error) => reject(error)); @@ -125,7 +125,7 @@ export class ProgramService { ProgramDAO.getOne(programId).then((biResponse) => { const result = biResponse.result; - const program = new Program(result.id, result.name, result.species.id, result.numUsers, result.brapiUrl); + const program = new Program(result.id, result.name, result.species.id, result.numUsers, result.brapiUrl, result.key); resolve(program); }).catch((error) => reject(error)); diff --git a/src/breeding-insight/service/StudyService.ts b/src/breeding-insight/service/StudyService.ts index 85a9f643c..6eb4eb408 100644 --- a/src/breeding-insight/service/StudyService.ts +++ b/src/breeding-insight/service/StudyService.ts @@ -21,10 +21,11 @@ import {BiResponse, Metadata} from "@/breeding-insight/model/BiResponse"; 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, trialId?: string, paginationQuery?: PaginationQuery, full?: boolean): Promise> { + static async getAll(programId: string, trial?: Trial, paginationQuery?: PaginationQuery, full?: boolean): Promise> { if (paginationQuery === undefined){ paginationQuery = new PaginationQuery(0, 0, true); @@ -38,8 +39,11 @@ export class StudyService { if(!programId) throw new Error('missing or invalid program id'); let response: Result; - if (trialId) { - response = await StudyDAO.getAllForTrial(programId, trialId) as Result; + if (trial !== undefined && trial.externalReferences !== undefined) { + 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; } else { response = await StudyDAO.getAll(programId, paginationQuery, full) as Result; } @@ -52,7 +56,7 @@ export class StudyService { data = PaginationUtilities.mockSortRecords(data); studies = data.map((study: any) => { - return new Study(study.studyDbId, study.studyName, study.studyDescription, study.studyType, study.startDate, study.endDate, study.locationName, study.active); + return new Study(study.studyDbId, study.studyName, study.studyDescription, study.studyType, study.startDate, study.endDate, study.locationName, study.active, study.externalReferences); }); let newPagination; diff --git a/src/components/experiments/ExperimentObservationsDownloadButton.vue b/src/components/experiments/ExperimentObservationsDownloadButton.vue index af899fa31..14f87d0fe 100644 --- a/src/components/experiments/ExperimentObservationsDownloadButton.vue +++ b/src/components/experiments/ExperimentObservationsDownloadButton.vue @@ -17,7 +17,7 @@