Commit 00ba78e7 authored by Célia Michotey's avatar Célia Michotey
Browse files

Create popup for taxon information. Remove static URL. Refactor institutes popups. GNP-5096

parent b863ad68
...@@ -20,6 +20,9 @@ public interface ExtendedGermplasm extends BrapiGermplasm, GnpISInternal { ...@@ -20,6 +20,9 @@ public interface ExtendedGermplasm extends BrapiGermplasm, GnpISInternal {
@JsonView(JSONView.GnpISFields.class) @JsonView(JSONView.GnpISFields.class)
List<String> getTaxonCommonNames(); List<String> getTaxonCommonNames();
@JsonView(JSONView.GnpISFields.class)
String getTaxonComment();
@JsonView(JSONView.GnpISFields.class) @JsonView(JSONView.GnpISFields.class)
String getGeneticNature(); String getGeneticNature();
......
...@@ -55,6 +55,7 @@ public class GermplasmVO ...@@ -55,6 +55,7 @@ public class GermplasmVO
private List<String> taxonSynonyms; private List<String> taxonSynonyms;
private List<String> taxonCommonNames; private List<String> taxonCommonNames;
private String taxonComment;
private String geneticNature; private String geneticNature;
private String comment; private String comment;
private PhotoVO photo; private PhotoVO photo;
...@@ -354,6 +355,15 @@ public class GermplasmVO ...@@ -354,6 +355,15 @@ public class GermplasmVO
this.taxonCommonNames = taxonCommonNames; this.taxonCommonNames = taxonCommonNames;
} }
@Override
public String getTaxonComment() {
return taxonComment;
}
public void setTaxonComment(String taxonComment) {
this.taxonComment = taxonComment;
}
@Override @Override
public String getGeneticNature() { public String getGeneticNature() {
return geneticNature; return geneticNature;
......
...@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; ...@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'; import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
import { BrapiService } from '../brapi.service'; import { BrapiService } from '../brapi.service';
import { GnpisService } from '../gnpis.service'; import { GnpisService } from '../gnpis.service';
import { BrapiAttributeData, BrapiGermplasmPedigree, BrapiLocation } from '../models/brapi.model'; import {BrapiAttributeData, BrapiGermplasmPedigree, BrapiLocation, BrapiTaxonIds} from '../models/brapi.model';
import { Children, Germplasm, Site } from '../models/gnpis.model'; import { Children, Germplasm, Site } from '../models/gnpis.model';
import { DataDiscoverySource } from '../models/data-discovery.model'; import { DataDiscoverySource } from '../models/data-discovery.model';
...@@ -29,6 +29,12 @@ export class GermplasmCardComponent implements OnInit { ...@@ -29,6 +29,12 @@ export class GermplasmCardComponent implements OnInit {
}); });
} }
NCBI_URL = "https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=";
THEPLANTLIST_URL = "http://www.theplantlist.org/tpl1.1/record/";
TAXREF_URL = "https://inpn.mnhn.fr/espece/cd_nom/";
CATALOGUEOFLIFE_URL = "http://www.catalogueoflife.org/col/details/species/id/";
taxonIdsWithURL: BrapiTaxonIds[] = [];
germplasmGnpis: Germplasm; germplasmGnpis: Germplasm;
germplasmPedigree: BrapiGermplasmPedigree; germplasmPedigree: BrapiGermplasmPedigree;
germplasmProgeny: Children[]; germplasmProgeny: Children[];
...@@ -36,20 +42,14 @@ export class GermplasmCardComponent implements OnInit { ...@@ -36,20 +42,14 @@ export class GermplasmCardComponent implements OnInit {
germplasmLocations: BrapiLocation[] = []; germplasmLocations: BrapiLocation[] = [];
germplasmId: string; germplasmId: string;
germplasmPuid: string; germplasmPuid: string;
germplasmTaxon: string;
germplasmTaxonAuthor: string;
germplasmSource: DataDiscoverySource; germplasmSource: DataDiscoverySource;
// TODO extract those url in a configuration file.
IMAGES_ACCESSION_URL = 'https://urgi.versailles.inra.fr/files/siregal/images/accession/';
IMAGES_INSTITUTION_URL = 'https://urgi.versailles.inra.fr/files/siregal/images//institution/';
IMAGES_BRC_URL = 'https://urgi.versailles.inra.fr/files/siregal/images/grc/inra_brc_en.png';
loaded: Promise<any>; loaded: Promise<any>;
loading = true; loading = true;
ngOnInit() { ngOnInit() {
this.germplasmId = this.route.snapshot.queryParams.id; this.germplasmId = this.route.snapshot.queryParams.id;
this.germplasmPuid = this.route.snapshot.queryParams.pui; this.germplasmPuid = this.route.snapshot.queryParams.pui;
...@@ -101,6 +101,7 @@ export class GermplasmCardComponent implements OnInit { ...@@ -101,6 +101,7 @@ export class GermplasmCardComponent implements OnInit {
// Get germplasm source // Get germplasm source
const sourceURI = germplasmGnpis['schema:includedInDataCatalog']; const sourceURI = germplasmGnpis['schema:includedInDataCatalog'];
this.getGermplasmSource(sourceURI); this.getGermplasmSource(sourceURI);
this.getTaxon(germplasmGnpis);
this.reformatData(germplasmGnpis); this.reformatData(germplasmGnpis);
}); });
return germplasm$; return germplasm$;
...@@ -124,6 +125,24 @@ export class GermplasmCardComponent implements OnInit { ...@@ -124,6 +125,24 @@ export class GermplasmCardComponent implements OnInit {
} }
} }
getTaxon(germplasmGnpis) {
if (germplasmGnpis.genusSpeciesSubtaxa) {
this.germplasmTaxon = germplasmGnpis.genusSpeciesSubtaxa;
this.germplasmTaxonAuthor = germplasmGnpis.subtaxaAuthority;
} else if (germplasmGnpis.genusSpecies) {
this.germplasmTaxon = germplasmGnpis.genusSpecies;
this.germplasmTaxonAuthor = germplasmGnpis.speciesAuthority;
} else if (germplasmGnpis.subtaxa) {
this.germplasmTaxon = germplasmGnpis.genus + ' ' + germplasmGnpis.species + ' ' + germplasmGnpis.subtaxa;
this.germplasmTaxonAuthor = germplasmGnpis.subtaxaAuthority;
} else if (germplasmGnpis.species) {
this.germplasmTaxon = germplasmGnpis.genus + ' ' + germplasmGnpis.species;
this.germplasmTaxonAuthor = germplasmGnpis.speciesAuthority;
} else {
this.germplasmTaxon = germplasmGnpis.genus;
this.germplasmTaxonAuthor = '';
}
}
reformatData(germplasmGnpis) { reformatData(germplasmGnpis) {
if (germplasmGnpis.children) { if (germplasmGnpis.children) {
...@@ -133,10 +152,13 @@ export class GermplasmCardComponent implements OnInit { ...@@ -133,10 +152,13 @@ export class GermplasmCardComponent implements OnInit {
this.germplasmGnpis.donors.sort(this.compareDonorInstitutes); this.germplasmGnpis.donors.sort(this.compareDonorInstitutes);
} }
if (germplasmGnpis.collection) { if (germplasmGnpis.collection) {
this.germplasmGnpis.collection.sort(this.compareCollectionPanel); this.germplasmGnpis.collection.sort(this.compareCollectionPopulationPanel);
}
if (germplasmGnpis.population) {
this.germplasmGnpis.population.sort(this.compareCollectionPopulationPanel);
} }
if (this.germplasmGnpis.panel) { if (this.germplasmGnpis.panel) {
this.germplasmGnpis.panel.sort(this.compareCollectionPanel); this.germplasmGnpis.panel.sort(this.compareCollectionPopulationPanel);
} }
if (this.germplasmGnpis.collectingSite) { if (this.germplasmGnpis.collectingSite) {
this.siteToBrapiLocation(this.germplasmGnpis.collectingSite); this.siteToBrapiLocation(this.germplasmGnpis.collectingSite);
...@@ -149,9 +171,11 @@ export class GermplasmCardComponent implements OnInit { ...@@ -149,9 +171,11 @@ export class GermplasmCardComponent implements OnInit {
this.siteToBrapiLocation(site); this.siteToBrapiLocation(site);
} }
} }
if (this.germplasmGnpis.taxonIds && germplasmGnpis.taxonId.length > 0) {
this.addRefURL(this.germplasmGnpis.taxonIds);
}
} }
siteToBrapiLocation(site: Site) { siteToBrapiLocation(site: Site) {
if (site && site.siteId && site.latitude && site.longitude) { if (site && site.siteId && site.latitude && site.longitude) {
this.germplasmLocations.push({ this.germplasmLocations.push({
...@@ -164,6 +188,23 @@ export class GermplasmCardComponent implements OnInit { ...@@ -164,6 +188,23 @@ export class GermplasmCardComponent implements OnInit {
} }
} }
addRefURL(taxonIds: BrapiTaxonIds[]) {
for (const taxonId of taxonIds) {
if (taxonId.sourceName == "NCBI") {
taxonId.url = this.NCBI_URL;
} else if (taxonId.sourceName == "ThePlantList") {
taxonId.url = this.THEPLANTLIST_URL;
} else if (taxonId.sourceName == "TAXREF") {
taxonId.url = this.TAXREF_URL;
} else if (taxonId.sourceName == "CatalogueOfLife") {
taxonId.url = this.CATALOGUEOFLIFE_URL
} else {
taxonId.url = null;
}
this.taxonIdsWithURL.push(taxonId);
}
}
// TODO: use a generic function to get path in object (or null if non-existent) // TODO: use a generic function to get path in object (or null if non-existent)
checkProgeny() { checkProgeny() {
return (this.germplasmProgeny return (this.germplasmProgeny
...@@ -189,7 +230,6 @@ export class GermplasmCardComponent implements OnInit { ...@@ -189,7 +230,6 @@ export class GermplasmCardComponent implements OnInit {
); );
} }
checkCollectorInstituteObject() { checkCollectorInstituteObject() {
return ( return (
this.germplasmGnpis.collector this.germplasmGnpis.collector
...@@ -209,10 +249,8 @@ export class GermplasmCardComponent implements OnInit { ...@@ -209,10 +249,8 @@ export class GermplasmCardComponent implements OnInit {
); );
} }
checkOriginCollecting() { checkCollecting() {
return (this.germplasmGnpis.collectingSite && this.germplasmGnpis.collectingSite.siteName)
return (this.germplasmGnpis.originSite && this.germplasmGnpis.originSite.siteName)
|| (this.germplasmGnpis.collectingSite && this.germplasmGnpis.collectingSite.siteName)
|| (this.checkCollectorInstituteObject() || this.checkCollectorInstituteFields()); || (this.checkCollectorInstituteObject() || this.checkCollectorInstituteFields());
} }
...@@ -236,7 +274,7 @@ export class GermplasmCardComponent implements OnInit { ...@@ -236,7 +274,7 @@ export class GermplasmCardComponent implements OnInit {
return 0; return 0;
} }
compareCollectionPanel(a, b) { compareCollectionPopulationPanel(a, b) {
if (a.name < b.name) { if (a.name < b.name) {
return -1; return -1;
} }
......
...@@ -139,6 +139,7 @@ export interface BrapiGermplasm extends BrapiHasDocumentationURL { ...@@ -139,6 +139,7 @@ export interface BrapiGermplasm extends BrapiHasDocumentationURL {
export interface BrapiTaxonIds { export interface BrapiTaxonIds {
sourceName: string; sourceName: string;
taxonId: string; taxonId: string;
url: string;
} }
export interface BrapiDonor { export interface BrapiDonor {
......
...@@ -5,6 +5,7 @@ export interface Germplasm extends BrapiGermplasm { ...@@ -5,6 +5,7 @@ export interface Germplasm extends BrapiGermplasm {
genusSpeciesSubtaxa: string; genusSpeciesSubtaxa: string;
taxonSynonyms: string[]; taxonSynonyms: string[];
taxonCommonNames: string[]; taxonCommonNames: string[];
taxonComment: string;
geneticNature: string; geneticNature: string;
comment: string; comment: string;
photo: Photo; photo: Photo;
......
...@@ -248,7 +248,6 @@ ...@@ -248,7 +248,6 @@
</ng-template> </ng-template>
</gpds-card-section> </gpds-card-section>
<!--XRefs part --> <!--XRefs part -->
<gpds-xrefs [xrefId]="study.studyDbId"></gpds-xrefs> <gpds-xrefs [xrefId]="study.studyDbId"></gpds-xrefs>
</ng-container> </ng-container>
...@@ -159,7 +159,7 @@ ...@@ -159,7 +159,7 @@
"template-conditional-complexity": true, "template-conditional-complexity": true,
"template-cyclomatic-complexity": [ "template-cyclomatic-complexity": [
true, true,
10 11
], ],
"templates-no-negated-async": true, "templates-no-negated-async": true,
"use-host-property-decorator": true, "use-host-property-decorator": true,
......
Supports Markdown
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