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 {
@JsonView(JSONView.GnpISFields.class)
List<String> getTaxonCommonNames();
@JsonView(JSONView.GnpISFields.class)
String getTaxonComment();
@JsonView(JSONView.GnpISFields.class)
String getGeneticNature();
......
......@@ -55,6 +55,7 @@ public class GermplasmVO
private List<String> taxonSynonyms;
private List<String> taxonCommonNames;
private String taxonComment;
private String geneticNature;
private String comment;
private PhotoVO photo;
......@@ -354,6 +355,15 @@ public class GermplasmVO
this.taxonCommonNames = taxonCommonNames;
}
@Override
public String getTaxonComment() {
return taxonComment;
}
public void setTaxonComment(String taxonComment) {
this.taxonComment = taxonComment;
}
@Override
public String getGeneticNature() {
return geneticNature;
......
......@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
import { BrapiService } from '../brapi.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 { DataDiscoverySource } from '../models/data-discovery.model';
......@@ -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;
germplasmPedigree: BrapiGermplasmPedigree;
germplasmProgeny: Children[];
......@@ -36,20 +42,14 @@ export class GermplasmCardComponent implements OnInit {
germplasmLocations: BrapiLocation[] = [];
germplasmId: string;
germplasmPuid: string;
germplasmTaxon: string;
germplasmTaxonAuthor: string;
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>;
loading = true;
ngOnInit() {
this.germplasmId = this.route.snapshot.queryParams.id;
this.germplasmPuid = this.route.snapshot.queryParams.pui;
......@@ -101,6 +101,7 @@ export class GermplasmCardComponent implements OnInit {
// Get germplasm source
const sourceURI = germplasmGnpis['schema:includedInDataCatalog'];
this.getGermplasmSource(sourceURI);
this.getTaxon(germplasmGnpis);
this.reformatData(germplasmGnpis);
});
return germplasm$;
......@@ -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) {
if (germplasmGnpis.children) {
......@@ -133,10 +152,13 @@ export class GermplasmCardComponent implements OnInit {
this.germplasmGnpis.donors.sort(this.compareDonorInstitutes);
}
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) {
this.germplasmGnpis.panel.sort(this.compareCollectionPanel);
this.germplasmGnpis.panel.sort(this.compareCollectionPopulationPanel);
}
if (this.germplasmGnpis.collectingSite) {
this.siteToBrapiLocation(this.germplasmGnpis.collectingSite);
......@@ -149,9 +171,11 @@ export class GermplasmCardComponent implements OnInit {
this.siteToBrapiLocation(site);
}
}
if (this.germplasmGnpis.taxonIds && germplasmGnpis.taxonId.length > 0) {
this.addRefURL(this.germplasmGnpis.taxonIds);
}
}
siteToBrapiLocation(site: Site) {
if (site && site.siteId && site.latitude && site.longitude) {
this.germplasmLocations.push({
......@@ -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)
checkProgeny() {
return (this.germplasmProgeny
......@@ -189,7 +230,6 @@ export class GermplasmCardComponent implements OnInit {
);
}
checkCollectorInstituteObject() {
return (
this.germplasmGnpis.collector
......@@ -209,10 +249,8 @@ export class GermplasmCardComponent implements OnInit {
);
}
checkOriginCollecting() {
return (this.germplasmGnpis.originSite && this.germplasmGnpis.originSite.siteName)
|| (this.germplasmGnpis.collectingSite && this.germplasmGnpis.collectingSite.siteName)
checkCollecting() {
return (this.germplasmGnpis.collectingSite && this.germplasmGnpis.collectingSite.siteName)
|| (this.checkCollectorInstituteObject() || this.checkCollectorInstituteFields());
}
......@@ -236,7 +274,7 @@ export class GermplasmCardComponent implements OnInit {
return 0;
}
compareCollectionPanel(a, b) {
compareCollectionPopulationPanel(a, b) {
if (a.name < b.name) {
return -1;
}
......
......@@ -139,6 +139,7 @@ export interface BrapiGermplasm extends BrapiHasDocumentationURL {
export interface BrapiTaxonIds {
sourceName: string;
taxonId: string;
url: string;
}
export interface BrapiDonor {
......
......@@ -5,6 +5,7 @@ export interface Germplasm extends BrapiGermplasm {
genusSpeciesSubtaxa: string;
taxonSynonyms: string[];
taxonCommonNames: string[];
taxonComment: string;
geneticNature: string;
comment: string;
photo: Photo;
......
......@@ -248,7 +248,6 @@
</ng-template>
</gpds-card-section>
<!--XRefs part -->
<gpds-xrefs [xrefId]="study.studyDbId"></gpds-xrefs>
</ng-container>
......@@ -159,7 +159,7 @@
"template-conditional-complexity": true,
"template-cyclomatic-complexity": [
true,
10
11
],
"templates-no-negated-async": 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