Commit 50513533 authored by Jérémy Destin's avatar Jérémy Destin
Browse files

Merge branch 'feat/taxon_ids' into 'master'

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

See merge request urgi-is/gpds!19
parents b863ad68 bc13eb99
......@@ -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;
......
......@@ -8,10 +8,10 @@ import fr.inra.urgi.gpds.domain.JSONView;
*/
public interface Photo {
@JsonView(JSONView.GnpISFields.class)
String getFileName();
String getFile();
@JsonView(JSONView.GnpISFields.class)
String getThumbnailFileName();
String getThumbnailFile();
@JsonView(JSONView.GnpISFields.class)
String getPhotoName();
......
......@@ -6,28 +6,28 @@ public class PhotoVO implements Serializable, Photo {
private static final long serialVersionUID = -4993890419772211643L;
private String fileName;
private String thumbnailFileName;
private String file;
private String thumbnailFile;
private String photoName;
private String description;
private String copyright;
@Override
public String getFileName() {
return fileName;
public String getFile() {
return file;
}
public void setFileName(String fileName) {
this.fileName = fileName;
public void setFile(String file) {
this.file = file;
}
@Override
public String getThumbnailFileName() {
return thumbnailFileName;
public String getThumbnailFile() {
return thumbnailFile;
}
public void setThumbnailFileName(String thumbnailFileName) {
this.thumbnailFileName = thumbnailFileName;
public void setThumbnailFile(String thumbnailFile) {
this.thumbnailFile = thumbnailFile;
}
@Override
......
This diff is collapsed.
......@@ -291,6 +291,7 @@ describe('BrapiService', () => {
genusSpeciesSubtaxa: null,
taxonSynonyms: ['pomme', 'api'],
taxonCommonNames: ['pomme', 'api'],
taxonComment: null,
geneticNature: null,
comment: null,
photo: null,
......
......@@ -177,6 +177,7 @@ describe('GermplasmCardComponent', () => {
genusSpeciesSubtaxa: null,
taxonSynonyms: ['pomme', 'api'],
taxonCommonNames: ['pomme', 'api'],
taxonComment: null,
geneticNature: null,
comment: null,
photo: null,
......
......@@ -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?mode=Info&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,8 +171,10 @@ export class GermplasmCardComponent implements OnInit {
this.siteToBrapiLocation(site);
}
}
if (this.germplasmGnpis.taxonIds && this.germplasmGnpis.taxonIds.length > 0) {
this.addRefURL(this.germplasmGnpis.taxonIds);
}
}
siteToBrapiLocation(site: Site) {
if (site && site.siteId && site.latitude && site.longitude) {
......@@ -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 + taxonId.taxonId;
} else if (taxonId.sourceName === 'ThePlantList') {
taxonId.url = this.THEPLANTLIST_URL + taxonId.taxonId;
} else if (taxonId.sourceName === 'TAXREF') {
taxonId.url = this.TAXREF_URL + taxonId.taxonId;
} else if (taxonId.sourceName === 'CatalogueOfLife') {
taxonId.url = this.CATALOGUEOFLIFE_URL + taxonId.taxonId;
} 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;
}
......
......@@ -98,6 +98,7 @@ describe('GnpisService', () => {
genusSpeciesSubtaxa: null,
taxonSynonyms: ['pomme', 'api'],
taxonCommonNames: ['pomme', 'api'],
taxonComment: null,
geneticNature: null,
comment: null,
photo: null,
......
......@@ -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;
......@@ -57,9 +58,9 @@ export interface GermplasmInstitute extends Institute {
export interface Photo {
copyright: string;
description: string;
fileName: string;
file: string;
photoName: string;
thumbnailFileName: string;
thumbnailFile: string;
}
......
......@@ -248,7 +248,6 @@
</ng-template>
</gpds-card-section>
<!--XRefs part -->
<gpds-xrefs [xrefId]="study.studyDbId"></gpds-xrefs>
</ng-container>
......@@ -15,7 +15,7 @@
],
"template-cyclomatic-complexity": [
true,
10
11
]
}
}
......@@ -159,7 +159,7 @@
"template-conditional-complexity": true,
"template-cyclomatic-complexity": [
true,
10
11
],
"templates-no-negated-async": true,
"use-host-property-decorator": true,
......
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