Commit cb407e56 authored by Jérémy Destin's avatar Jérémy Destin Committed by Célia Michotey
Browse files

fix: Fix the test. Rename and use the good models. Minor fixes. GNP-5490

parent 21aff611
import { BrapiService } from './brapi.service';
import {
BrapiContacts, BrapiData, BrapiDonor,
BrapiGermplasm, BrapiGermplasmAttributes, BrapiGermplasmPedigree, BrapiGermplasmProgeny,
BrapiContacts,
BrapiGermplasm,
BrapiGermplasmAttributes,
BrapiGermplasmPedigree,
BrapiGermplasmProgeny,
BrapiLocation,
BrapiObservationVariable,
BrapiResult, BrapiResults, BrapiSibling,
BrapiStudy, BrapiTaxonIds,
BrapiProgeny,
BrapiResult,
BrapiResults,
BrapiSibling,
BrapiStudy,
BrapiTrial
} from './models/brapi.model';
import { DataDiscoverySource } from './models/data-discovery.model';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import {Germplasm, GermplasmInstitute, GermplasmSet, Institute, Site} from "./models/gnpis.model";
import Result = jasmine.Result;
import { Donor, Germplasm, GermplasmInstitute, GermplasmSet, Institute, Site } from './models/gnpis.model';
describe('BrapiService', () => {
......@@ -172,7 +177,14 @@ describe('BrapiService', () => {
defaultDisplayName: 'frere1'
};
const brapiProgeny: BrapiProgeny = {
germplasmDbId: 'test',
defaultDisplayName: 'progeny1',
parentType: 'parent1'
};
const brapiGermplasmPedigree: BrapiResult<BrapiGermplasmPedigree> = {
metadata: null,
result: {
germplasmDbId: 'test',
defaultDisplayName: '12',
......@@ -191,10 +203,11 @@ describe('BrapiService', () => {
};
const brapiGermplasmProgeny: BrapiResult<BrapiGermplasmProgeny> = {
metadata: null,
result: {
germplasmDbId: 'test',
defaultDisplayName: '11',
progeny: [brapiSibling]
progeny: [brapiProgeny]
}
};
......@@ -209,9 +222,9 @@ describe('BrapiService', () => {
address: '12',
logo: null
};
const origin: GermplasmInstitute = { ... institute,
const origin: GermplasmInstitute = {
...institute,
institute: institute,
germplasmPUI: '12',
accessionNumber: '12',
accessionCreationDate: '1993',
materialType: 'feuille',
......@@ -221,7 +234,7 @@ describe('BrapiService', () => {
distributionStatus: null
};
const brapiDonor: BrapiDonor = {
const brapiDonor: Donor = {
donorInstitute: institute,
donorGermplasmPUI: '12',
donorAccessionNumber: '12',
......@@ -237,10 +250,15 @@ describe('BrapiService', () => {
type: 'plan'
};
const brapiGermplasmAttributes: BrapiResult<BrapiData<BrapiGermplasmAttributes[]>> = {
const brapiGermplasmAttributes: BrapiResult<BrapiGermplasmAttributes> = {
metadata: null,
result: {
germplasmDbId: 'test',
data: [{
attributeCode: 'att',
attributeDbId: 'attr2',
attributeName: 'longueur',
determinedDate: '2019',
value: '30'
}]
}
......@@ -291,10 +309,6 @@ describe('BrapiService', () => {
population: [germplasmSet]
};
const germplasmResultTest = {
result: germplasmTest
};
let brapiService: BrapiService;
let http: HttpTestingController;
......@@ -408,7 +422,7 @@ describe('BrapiService', () => {
it('should fetch the germplasm attributes', () => {
let fetchedGermplasmAttributes: BrapiResult<BrapiData<BrapiGermplasmAttributes[]>>;
let fetchedGermplasmAttributes: BrapiResult<BrapiGermplasmAttributes>;
const germplasmDbId: string = germplasmTest.germplasmDbId;
brapiService.germplasmAttributes(germplasmDbId).subscribe(response => {
fetchedGermplasmAttributes = response;
......
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { Germplasm, GermplasmData, GermplasmResult } from './models/gnpis.germplasm.model';
import {
BrapiGermplasm, BrapiGermplasmAttributes,
BrapiGermplasm,
BrapiGermplasmAttributes,
BrapiGermplasmPedigree,
BrapiLocation,
BrapiObservationVariable,
BrapiResult,
......@@ -11,7 +12,7 @@ import {
BrapiStudy,
BrapiTrial
} from './models/brapi.model';
import { BrapiGermplasmPedigree } from './models/brapi.germplasm.model';
import { Germplasm } from './models/gnpis.model';
export const BASE_URL = 'brapi/v1';
......@@ -28,18 +29,18 @@ export class BrapiService {
.get<Germplasm>(`${BASE_URL}/germplasm/${germplasmDbId}`);
}
germplasmPedigree(germplasmDbId: string): Observable<GermplasmResult<BrapiGermplasmPedigree>> {
germplasmPedigree(germplasmDbId: string): Observable<BrapiResult<BrapiGermplasmPedigree>> {
return this.http
.get<GermplasmResult<BrapiGermplasmPedigree>>(`${BASE_URL}/germplasm/${germplasmDbId}/pedigree`);
.get<BrapiResult<BrapiGermplasmPedigree>>(`${BASE_URL}/germplasm/${germplasmDbId}/pedigree`);
}
/*germplasmProgeny(germplasmDbId: string): Observable<GermplasmResult<BrapiGermplasmProgeny>> {
return this.http.get<GermplasmResult<BrapiGermplasmProgeny>>(`${BASE_URL}/germplasm/${germplasmDbId}/progeny`);
}*/
germplasmAttributes(germplasmDbId: string): Observable<GermplasmResult<GermplasmData<BrapiGermplasmAttributes[]>>> {
germplasmAttributes(germplasmDbId: string): Observable<BrapiResult<BrapiGermplasmAttributes>> {
return this.http
.get<GermplasmResult<GermplasmData<BrapiGermplasmAttributes[]>>>(`${BASE_URL}/germplasm/${germplasmDbId}/attributes`);
.get<BrapiResult<BrapiGermplasmAttributes>>(`${BASE_URL}/germplasm/${germplasmDbId}/attributes`);
}
study(studyDbId: string): Observable<BrapiResult<BrapiStudy>> {
......
......@@ -430,10 +430,7 @@
<gpds-card-row
label="Accession creation year"
[test]="germplasmGnpis.breeder.accessionCreationDate ">
<ng-template>
{{ germplasmGnpis.breeder.accessionCreationDate }}
</ng-template>
[value]="germplasmGnpis.breeder.accessionCreationDate ">
</gpds-card-row>
<gpds-card-row
......
......@@ -14,6 +14,8 @@ import { CardSectionComponent } from '../card-section/card-section.component';
import { CardRowComponent } from '../card-row/card-row.component';
import { CardTableComponent } from '../card-table/card-table.component';
import { MapComponent } from '../map/map.component';
import { BrapiGermplasmAttributes, BrapiGermplasmPedigree, BrapiResult, BrapiSibling } from '../models/brapi.model';
import { Donor, Germplasm, GermplasmInstitute, GermplasmSet, Institute, Site } from '../models/gnpis.model';
import {
BrapiGermplasmAttributes,
BrapiGermplasmPedigree,
......@@ -111,7 +113,8 @@ describe('GermplasmCardComponent', () => {
logo: null
};
const gnpisGermplasmInstitute: GermplasmInstitute = { ... gnpisInstitute,
const gnpisGermplasmInstitute: GermplasmInstitute = {
...gnpisInstitute,
institute: gnpisInstitute,
accessionNumber: '12',
accessionCreationDate: '1993',
......@@ -208,7 +211,8 @@ describe('GermplasmCardComponent', () => {
providers: [
{ provide: BrapiService, useValue: brapiService },
{ provide: GnpisService, useValue: gnpisService },
{ provide: ActivatedRoute,
{
provide: ActivatedRoute,
useValue: {
snapshot: {
queryParams: convertToParamMap({
......
......@@ -2,9 +2,8 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
import { BrapiService } from '../brapi.service';
import { GnpisService } from '../gnpis.service';
import { Germplasm, Children, Site } from '../models/gnpis.germplasm.model';
import { BrapiGermplasmPedigree } from '../models/brapi.germplasm.model';
import { BrapiGermplasmAttributes, BrapiLocation } from '../models/brapi.model';
import { BrapiAttributeData, BrapiGermplasmPedigree, BrapiLocation } from '../models/brapi.model';
import { Children, Germplasm, Site } from '../models/gnpis.model';
@Component( {
selector: 'gpds-germplasm-card',
......@@ -32,7 +31,7 @@ export class GermplasmCardComponent implements OnInit {
germplasmGnpis: Germplasm;
germplasmPedigree: BrapiGermplasmPedigree;
germplasmProgeny: Children[];
germplasmAttributes: BrapiGermplasmAttributes[];
germplasmAttributes: BrapiAttributeData[];
germplasmLocations: BrapiLocation[] = [];
germplasmId: string;
germplasmPuid: string;
......@@ -130,15 +129,11 @@ export class GermplasmCardComponent implements OnInit {
checkBreeder() {
return (this.germplasmGnpis.breeder)
&& (this.germplasmGnpis.breeder.institute.instituteName
|| this.germplasmGnpis.breeder.germplasmPUI
|| this.germplasmGnpis.breeder.accessionNumber
&& (this.germplasmGnpis.breeder.institute
|| this.germplasmGnpis.breeder.accessionCreationDate
|| this.germplasmGnpis.breeder.materialType
|| this.germplasmGnpis.breeder.collectors
|| this.germplasmGnpis.breeder.accessionNumber
|| this.germplasmGnpis.breeder.registrationYear
|| this.germplasmGnpis.breeder.deregistrationYear
|| this.germplasmGnpis.breeder.distributionStatus);
|| this.germplasmGnpis.breeder.deregistrationYear);
}
checkPedigree() {
......@@ -161,8 +156,7 @@ export class GermplasmCardComponent implements OnInit {
checkCollectorInstituteFields() {
return (this.germplasmGnpis.collector) &&
(this.germplasmGnpis.collector.germplasmPUI
|| this.germplasmGnpis.collector.accessionNumber
(this.germplasmGnpis.collector.accessionNumber
|| this.germplasmGnpis.collector.accessionCreationDate
|| this.germplasmGnpis.collector.materialType
|| this.germplasmGnpis.collector.collectors
......
import { Germplasm, GermplasmSet, Institute, GermplasmInstitute, Site } from './models/gnpis.germplasm.model';
import { BASE_URL, BASE_URL_GERMPLASM, GnpisService } from './gnpis.service';
import {BrapiDonor, BrapiMetaData, BrapiResults} from './models/brapi.model';
import { BrapiMetaData, BrapiResults } from './models/brapi.model';
import { DataDiscoveryCriteria, DataDiscoverySource } from './models/data-discovery.model';
import { BrapiDescriptor} from './models/brapi.germplasm.model';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { Donor, Germplasm, GermplasmInstitute, GermplasmSet, Institute, Site } from './models/gnpis.model';
describe('GnpisService', () => {
......@@ -34,12 +32,6 @@ describe('GnpisService', () => {
siteType: null
};
const brapiDescriptor: BrapiDescriptor = {
name: 'caracteristique1',
pui: '12',
value: '32'
};
const brapiInstitute: Institute = {
instituteName: 'urgi',
instituteCode: 'inra',
......@@ -51,9 +43,9 @@ describe('GnpisService', () => {
logo: null
};
const brapiOrigin: GermplasmInstitute = { ...brapiInstitute,
const germplasmInstitute: GermplasmInstitute = {
...brapiInstitute,
institute: brapiInstitute,
germplasmPUI: '12',
accessionNumber: '12',
accessionCreationDate: '1993',
materialType: 'feuille',
......@@ -63,7 +55,7 @@ describe('GnpisService', () => {
distributionStatus: null
};
const brapiDonor: BrapiDonor = {
const brapiDonor: Donor = {
donorInstitute: brapiInstitute,
donorGermplasmPUI: '12',
donorAccessionNumber: '12',
......@@ -80,8 +72,6 @@ describe('GnpisService', () => {
};
const germplasmTest: Germplasm = {
url: 'www.cirad.fr',
source: 'cirad',
germplasmDbId: 'test',
defaultDisplayName: 'test',
accessionNumber: 'test',
......@@ -115,13 +105,12 @@ describe('GnpisService', () => {
holdingGenbank: brapiInstitute,
presenceStatus: null,
children: null,
descriptors: [brapiDescriptor],
originSite: site,
collectingSite: null,
evaluationSites: null,
collector: brapiOrigin,
breeder: brapiOrigin,
distributors: [brapiOrigin],
collector: germplasmInstitute,
breeder: germplasmInstitute,
distributors: [germplasmInstitute],
panel: [germplasmSet],
collection: [germplasmSet],
population: [germplasmSet]
......
import { Injectable } from '@angular/core';
import { Observable, ReplaySubject, zip } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { Germplasm } from './models/gnpis.germplasm.model';
import { DataDiscoveryCriteria, DataDiscoveryFacet, DataDiscoveryResults, DataDiscoverySource } from './models/data-discovery.model';
import { BrapiResults } from './models/brapi.model';
import { map } from 'rxjs/operators';
import { Germplasm } from './models/gnpis.model';
import { XrefResponse } from './models/xref.model';
......
import {BrapiDonor, BrapiGermplasm} from "./brapi.model";
import { BrapiDonor, BrapiGermplasm } from './brapi.model';
export interface Germplasm extends BrapiGermplasm {
genusSpecies: string;
......@@ -51,7 +51,7 @@ export interface GermplasmInstitute extends Institute {
collectors: string;
registrationYear: string;
deregistrationYear: string;
distributionStatus: string;
distributionStatus?: string;
}
export interface Photo {
......@@ -75,8 +75,8 @@ export interface Children {
}
export interface Donor extends BrapiDonor{
donorInstitute: Institute
export interface Donor extends BrapiDonor {
donorInstitute: Institute;
}
......
......@@ -12,10 +12,10 @@
</a>
</h5>
<h5>
<a class="title" *ngIf="getRouterLink() && document['@type'] == 'Phenotyping Study'" [routerLink]="getRouterLink()">
<a class="title" *ngIf="getRouterLink() && document['@type'].includes('Phenotyping Study')" [routerLink]="getRouterLink()">
(go to this {{ document["@type"] }} card)
</a>
<a class="title" *ngIf="getRouterLink() && document['@type'] != 'Phenotyping Study'" [routerLink]="getRouterLink()" [queryParams]="getQueryParam()">
<a class="title" *ngIf="getRouterLink() && !document['@type'].includes('Phenotyping Study')" [routerLink]="getRouterLink()" [queryParams]="getQueryParam()">
(go to this {{ document["@type"] }} card)
</a>
</h5>
......
import { Component, OnInit } from '@angular/core';
import { BrapiService } from '../brapi.service';
import { ActivatedRoute } from '@angular/router';
import {BrapiAdditionalInfo, BrapiLocation} from '../models/brapi.model';
import { BrapiLocation } from '../models/brapi.model';
import { KeyValueObject } from '../utils';
@Component({
......@@ -39,7 +39,17 @@ export class SiteCardComponent implements OnInit {
}
manageAdditionalInfo(keyValues: KeyValueObject[]) {
var forbiddenElements: String[] = ['Site status', 'Coordinates precision', 'Slope', 'Exposure', 'Geographical location', 'Distance to city', 'Direction from city', 'Environment type', 'Topography', 'Comment'];
const forbiddenElements: String[] = [
'Site status',
'Coordinates precision',
'Slope',
'Exposure',
'Geographical location',
'Distance to city',
'Direction from city',
'Environment type',
'Topography',
'Comment'];
for (const keyValue of keyValues) {
if (!forbiddenElements.includes(keyValue.key)) {
this.additionalInfos.push(keyValue);
......@@ -49,28 +59,27 @@ export class SiteCardComponent implements OnInit {
formatCoordinates(decimalDegrees: number, type: string): string {
if (decimalDegrees && type) {
var degree = Math.floor(decimalDegrees);
var decimalMinute = (decimalDegrees - degree) * 60;
var minute = Math.floor(decimalMinute);
var decimalSeconde = (decimalMinute - minute) * 60;
var seconde = Math.floor(decimalSeconde);
const degree = Math.floor(decimalDegrees);
const decimalMinute = (decimalDegrees - degree) * 60;
const minute = Math.floor(decimalMinute);
const decimalSeconde = (decimalMinute - minute) * 60;
const seconde = Math.floor(decimalSeconde);
var direction = '';
if (type == 'latitude') {
let direction = '';
if (type === 'latitude') {
if (decimalDegrees >= 0) {
direction = "N";
direction = 'N';
} else {
direction = "S";
direction = 'S';
}
}
else if (type == 'longitude') {
} else if (type === 'longitude') {
if (decimalDegrees >= 0) {
direction = "E";
direction = 'E';
} else {
direction = "W";
direction = 'W';
}
}
return decimalDegrees + "° (" + degree + "° " + minute + "' " + seconde + "'' " + direction + ")";
return decimalDegrees + '° (' + degree + '° ' + minute + '\' ' + seconde + '\'\' ' + direction + ')';
} else {
return null;
}
......
......@@ -48,7 +48,7 @@ describe('StudyCardComponent', () => {
}
get map() {
return this.element('gpds-map');
return this.element('div #map');
}
}
......@@ -170,18 +170,50 @@ describe('StudyCardComponent', () => {
result: {
data: [{
germplasmDbId: 'g1',
defaultDisplayName: 'germplam1',
accessionNumber: 'G_10',
germplasmName: 'germplam1',
germplasmPUI: 'urn_g1',
pedigree: null,
seedSource: 'Versaille Institute',
synonyms: null,
commonCropName: 'cheery',
instituteCode: '78',
instituteName: 'Versaille Institute',
biologicalStatusOfAccessionCode: null,
countryOfOriginCode: 'FR',
typeOfGermplasmStorageCode: null,
taxonIds: null,
genus: 'Populus',
species: 'x generosa',
subtaxa: ''
speciesAuthority: 'Pop',
subtaxa: 'subsp',
subtaxaAuthority: '',
donors: null,
acquisitionDate: 'yesterday'
}, {
germplasmDbId: 'g2',
defaultDisplayName: 'germplam2',
accessionNumber: 'G_20',
germplasmName: 'germplam2',
germplasmPUI: 'urn_g2',
pedigree: null,
seedSource: 'Versaille Institute',
synonyms: null,
commonCropName: 'cheery',
instituteCode: '78',
instituteName: 'Versaille Institute',
biologicalStatusOfAccessionCode: null,
countryOfOriginCode: 'FR',
typeOfGermplasmStorageCode: null,
taxonIds: null,
genus: 'Triticum',
species: 'aestivum',
subtaxa: 'subsp'
speciesAuthority: 'Trit',
subtaxa: 'subsp',
subtaxaAuthority: '',
donors: null,
acquisitionDate: 'today'
}],
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment