-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from SpeciesFileGroup/schema
Schema
- Loading branch information
Showing
15 changed files
with
276 additions
and
4,224 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| const { schema_host } = __APP_ENV__ | ||
|
|
||
| const TAXON_RANK = { | ||
| species: [ | ||
| 'http://rs.tdwg.org/ontology/voc/TaxonRank#Species', | ||
| 'http://www.wikidata.org/entity/Q7432' | ||
| ], | ||
| genus: [ | ||
| 'genus', | ||
| 'http://rs.tdwg.org/ontology/voc/TaxonRank#Genus', | ||
| 'http://www.wikidata.org/entity/Q34740' | ||
| ] | ||
| } | ||
|
|
||
| function removeEmptyProperties(obj) { | ||
| const copyObj = { ...obj } | ||
|
|
||
| for (const key in obj) { | ||
| const value = obj[key] | ||
|
|
||
| if (!value || (Array.isArray(value) && !value.length)) { | ||
| delete copyObj[key] | ||
| } | ||
| } | ||
|
|
||
| return copyObj | ||
| } | ||
|
|
||
| function makeUrlPath(path) { | ||
| return schema_host ? `${schema_host}${path}` : '' | ||
| } | ||
|
|
||
| export function defineTaxon({ | ||
| id, | ||
| childTaxon, | ||
| parentTaxon, | ||
| taxonRank, | ||
| name, | ||
| scientificName, | ||
| identifier, | ||
| commonNames, | ||
| alternateName | ||
| }) { | ||
| return removeEmptyProperties({ | ||
| '@type': 'Taxon', | ||
| '@id': makeUrlPath(id), | ||
| 'http://purl.org/dc/terms/conformsTo': { | ||
| '@id': 'https://bioschemas.org/profiles/Taxon/1.0-RELEASE' | ||
| }, | ||
| additionalType: [ | ||
| 'dwc:Taxon', | ||
| 'http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept' | ||
| ], | ||
| 'dwc:vernacularName': defineCommonNames(commonNames), | ||
| name, | ||
| alternateName: alternateName.map((item) => item.replaceAll(/<\/?i>/g, '')), | ||
| childTaxon, | ||
| scientificName: defineTaxonName(scientificName), | ||
| identifier, | ||
| taxonRank, | ||
| parentTaxon: defineTaxonEntity(parentTaxon) | ||
| }) | ||
| } | ||
|
|
||
| function defineTaxonName({ name, author, taxonRank }) { | ||
| return removeEmptyProperties({ | ||
| '@type': 'TaxonName', | ||
| author, | ||
| name, | ||
| taxonRank | ||
| }) | ||
| } | ||
|
|
||
| function defineTaxonEntity({ name, taxonRank }) { | ||
| return { | ||
| '@type': 'Taxon', | ||
| name, | ||
| taxonRank | ||
| } | ||
| } | ||
|
|
||
| function defineCommonNames(commonNames) { | ||
| return commonNames.map(({ name, language }) => ({ | ||
| '@language': language, | ||
| '@value': name | ||
| })) | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export * from './loadCatalog' | ||
| export * from './loadDistribution' | ||
| export * from './loadTaxonomy' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import TaxonWorks from '../../services/TaxonWorks' | ||
|
|
||
| export const actionLoadTaxonomy = { | ||
| async loadTaxonomy(otuId) { | ||
| const { data } = await TaxonWorks.getTaxonomy(otuId, { | ||
| max_descendants_depth: 0, | ||
| extend: ['common_names'] | ||
| }) | ||
|
|
||
| this.taxonomy = { | ||
| commonNames: data.common_names, | ||
| synonyms: data.nomenclatural_synonyms | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.