Skip to content

Commit

Permalink
Merge pull request #331 from Breeding-Insight/bug/BI-1911
Browse files Browse the repository at this point in the history
[BI-1911] Environment Year Missing from Exp table
  • Loading branch information
dmeidlin authored Oct 3, 2023
2 parents 8ca7d86 + c200f88 commit 4c6d2c2
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 95 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,6 @@
"vue-cli-plugin-axios": "0.0.4",
"vue-template-compiler": "^2.6.10"
},

"versionInfo": "https://github.com/Breeding-Insight/bi-web/commit/87faca99d768a53d44bc2e0f4684e1eaea88c71b"
}
18 changes: 8 additions & 10 deletions src/breeding-insight/dao/ExperimentDAO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class ExperimentDAO {
return ResultGenerator.err(error);
}
}
static getDatasetById(programId: string, experimentId: string, datasetId: string, stats: boolean): Promise<Result<Error, DatasetModel>> {
static async getDatasetById(programId: string, experimentId: string, datasetId: string, stats: boolean): Promise<Result<Error, DatasetModel>> {
const config: any = {};
config.url = `${process.env.VUE_APP_BI_API_V1_PATH}/programs/${programId}/experiments/${experimentId}/dataset/${datasetId}`;
config.method = 'get';
Expand All @@ -48,15 +48,13 @@ export class ExperimentDAO {
config.params = {
stats : stats,
};
return new Promise<Result<Error, DatasetModel>>(((resolve, reject) => {
api.call(config)
.then((response: any) => {
const biResponse = new BiResponse(response.data);
resolve(biResponse);
}).catch((error) => {
reject(error);
})
}))
try {
const res = await api.call(config) as Response;
let { result } = res.data;
return ResultGenerator.success(result);
} catch (error) {
return ResultGenerator.err(error);
}
}

}
6 changes: 3 additions & 3 deletions src/breeding-insight/model/ObservationUnit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import {ExternalReferences} from "@/breeding-insight/brapi/model/externalReferen
export class ObservationUnit {
observationUnitDbId: string;
germplasmDbId?: string;
germplasmName: string;
germplasmName?: string;
locationDbI?: string;
locationName: string;
locationName?: string;
observationUnitName?: string;
observationUnitPUI?: string;
programDbId?: string;
programName?: string;
studyDbId?: string;
studyName: string;
studyName?: string;
trialDbId?: string;
trialName?: string;
observationUnitPosition?: ObservationUnitPosition;
Expand Down
21 changes: 11 additions & 10 deletions src/breeding-insight/model/Sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,6 @@ export enum GermplasmSortField {
UserName = "createdByUserName"
}

export class GermplasmSort {
field: GermplasmSortField;
order: SortOrder;

constructor(field: GermplasmSortField, order: SortOrder) {
this.field = field;
this.order = order;
}
}

// experiments
export enum ExperimentSortField {
Name = "name",
Expand All @@ -198,6 +188,17 @@ export class ExperimentSort {
}
}

// germplasm
export class GermplasmSort {
field: GermplasmSortField;
order: SortOrder;

constructor(field: GermplasmSortField, order: SortOrder) {
this.field = field;
this.order = order;
}
}

export enum GermplasmListSortField {
Name = "name",
Description = "description",
Expand Down
7 changes: 5 additions & 2 deletions src/breeding-insight/model/Study.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class Study {
location?: string;
active?: boolean;
externalReferences?: ExternalReferences;
seasons?: string[];


constructor(id?: string,
Expand All @@ -37,7 +38,8 @@ export class Study {
endDate?: string,
location?: string,
active?: boolean,
externalReferences?: ExternalReferences
externalReferences?: ExternalReferences,
seasons?: string[]
) {
this.id = id;
this.name = name;
Expand All @@ -56,13 +58,14 @@ export class Study {
this.active = true;
}
this.externalReferences = externalReferences;
this.seasons = seasons;
}

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, study.externalReferences);
return new Study(study.id, study.name, study.description, study.type, start, end, study.location, study.active, study.externalReferences, study.seasons);
}

equals(study?: Study): boolean {
Expand Down
3 changes: 2 additions & 1 deletion src/breeding-insight/service/BrAPIService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {SortOrder} from "@/breeding-insight/model/Sort";
export enum BrAPIType {
GERMPLASM = "germplasm",
EXPERIMENT = "trials",
LIST = "lists"
LIST = "lists",
SEASON = "seasons"
}

export class BrAPIService {
Expand Down
12 changes: 11 additions & 1 deletion src/breeding-insight/service/StudyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,17 @@ 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, study.externalReferences);
return new Study(
study.studyDbId,
study.studyName,
study.studyDescription,
study.studyType,
study.startDate,
study.endDate,
study.locationName,
study.active,
study.externalReferences,
study.seasons);
});

let newPagination;
Expand Down
2 changes: 0 additions & 2 deletions src/components/experiments/ExperimentsObservationsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ export default class ExperimentsObservationsTable extends Vue {
// Account for brapi 0 indexing of paging
this.paginationController.currentPage = this.paginationController.currentPage.valueOf() + 1;
this.experiments = response.result.data;
console.log( this.experiments);
this.experimentsLoading = false;

} catch (err) {
Expand All @@ -206,7 +205,6 @@ export default class ExperimentsObservationsTable extends Vue {
this.downloadExperiment = experiment;
this.downloadModalTitle = "Download " + experiment.trialName;
this.downloadTrialId = BrAPIUtils.getBreedingInsightId(experiment.externalReferences!, '/trials');
console.log(this.downloadTrialId);
}

setSort(field: string, order: string) {
Expand Down
22 changes: 20 additions & 2 deletions src/views/germplasm/BreedingMethods.vue
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,16 @@ export default class BreedingMethods extends ProgramsBase {
this.getBreedingMethods();
this.$emit('show-success-notification', 'Breeding method created successfully');
} catch (e) {
this.$emit('show-error-notification', 'Error while trying to create breeding method');
if (e.response.status == 400 && e.response && e.response.data) {
this.$emit('show-error-notification', e.response.data);
}
else{
if( e.response && e.response.data ) {
//This message may also appear in the bi_api log
console.error(e.response.data);
}
this.$emit('show-error-notification', 'Error while trying to create breeding method');
}
} finally {
this.newMethodFormState.bus.$emit(DataFormEventBusHandler.SAVE_COMPLETE_EVENT);
}
Expand All @@ -576,7 +585,16 @@ export default class BreedingMethods extends ProgramsBase {
this.getBreedingMethods();
this.$emit('show-success-notification', 'Breeding method updated successfully');
} catch (e) {
this.$emit('show-error-notification', 'Error while trying to update breeding method');
if (e.response.status == 400 && e.response && e.response.data) {
this.$emit('show-error-notification', e.response.data);
}
else{
if( e.response && e.response.data ) {
//This message may also appear in the bi_api log
console.error(e.response.data);
}
this.$emit('show-error-notification', 'Error while trying to create breeding method');
}
} finally {
this.editMethodFormState.bus.$emit(DataFormEventBusHandler.SAVE_COMPLETE_EVENT)
}
Expand Down
Loading

0 comments on commit 4c6d2c2

Please sign in to comment.