Add Catalogue of Life as an external tag vocabulary

Close #43
This commit is contained in:
2025-09-23 13:37:05 +02:00
parent 785fc6dcad
commit 69cb033f1f
3 changed files with 39 additions and 6 deletions

View File

@@ -57,6 +57,7 @@ final class MDNodaRepositoriesSet extends MDValueSet {
'aat',
'ackerbau',
'allgemein',
'col',
'bne',
'bnf',
'gnd',

View File

@@ -16,6 +16,7 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
case ackerbau;
case bne;
case bnf;
case col;
case cona;
case editionhumboldtdigital;
case gnd;
@@ -58,6 +59,8 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
'ackerbau' => self::ackerbau,
'bne' => self::bne,
'bnf' => self::bnf,
'col',
'catalogue of life' => self::col,
'cona' => self::cona,
'edition humboldt digital' => self::editionhumboldtdigital,
'gnd',
@@ -72,6 +75,7 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
'http://d-nb.info/gnd/',
'd-nb.info',
'd-nb',
'Gemeinsame Normdatei',
'https://portal.dnb.de',
'https://explore.gnd.network/gnd/' => self::gnd,
'grobsystematik' => self::grobsystematik,
@@ -148,6 +152,7 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
self::ackerbau => 'ackerbau',
self::bne => 'bne',
self::bnf => 'bnf',
self::col => 'col',
self::cona => 'cona',
self::editionhumboldtdigital => 'edition humboldt digital',
self::gnd => 'gnd',
@@ -190,6 +195,7 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
self::ackerbau => 'Ackerbau-Thesaurus',
self::bne => 'Biblioteca Nacional de España (BNE)',
self::bnf => 'Bibliothèque nationale de France (BNF)',
self::col => 'Catalogue of Life',
self::cona => 'Cultural Objects Name Authority (CONA)',
self::editionhumboldtdigital => 'Edition Humboldt Digital',
self::gnd => 'GND (Gemeinsame Normdatei)',
@@ -232,6 +238,7 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
self::ackerbau => 'https://term.museum-digital.de/ackerbau/tag/',
self::bne => 'http://datos.bne.es/persona/',
self::bnf => "https://catalogue.bnf.fr/ark:/12148/cb",
self::col => 'https://www.catalogueoflife.org/data/taxon/',
self::cona => 'https://vocab.getty.edu/page/cona/',
self::editionhumboldtdigital => 'https://edition-humboldt.de/register/personen/detail.xql?normid=http://d-nb.info/gnd/',
self::gnd => 'https://d-nb.info/gnd/',
@@ -293,6 +300,7 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
self::ackerbau => 'https://term.museum-digital.de/redir.php?search=' . urlencode($searchTerm) . '&kind=tag|ackerbau',
self::bne => 'http://datos.bne.es/persona/' . urlencode($searchTerm),
self::bnf => 'https://catalogue.bnf.fr/resultats-auteur.do?nomAuteur=' . urlencode($searchTerm) . '+&filtre=1&pageRech=rau',
self::col => 'https://www.catalogueoflife.org/data/search?q=' . urlencode($searchTerm),
self::cona => 'http://vocab.getty.edu/page/cona/' . urlencode($searchTerm),
self::editionhumboldtdigital => 'https://edition-humboldt.de/suche/ergebnisRegistersuche.xql?indexType=&q_text=' . urlencode($searchTerm),
self::gnd => 'https://explore.gnd.network/search?term=' . urlencode($searchTerm),
@@ -539,6 +547,24 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
}
/**
* Validates catalogue of life IDs.
*
* @param string $id ID to validate.
*
* @return string|false
*/
private static function validateColId(string $id):string|false {
$id = strtr(trim($id, '/'), [
"http://www.catalogueoflife.org/data/taxon/" => "",
"https://www.catalogueoflife.org/data/taxon/" => "",
]);
return preg_match('/^([A-Z0-9]{2}|[A-Z0-9]{3}|[A-Z0-9]{4}|[A-Z0-9]{5})$/', $id) ? $id : false;
}
/**
* Validates OrCID IDs.
*
@@ -692,6 +718,7 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
self::ackerbau => self::validateNumericId($id, ['https://term.museum-digital.de/ackerbau/tag/']),
self::bne => self::validateBneId($id, ['http://datos.bne.es/persona/', 'https://datos.bne.es/persona/']),
self::bnf => self::validateBnfId($id),
self::col => self::validateColId($id),
self::cona => self::validateNumericId($id, ['http://vocab.getty.edu/page/cona/', 'https://vocab.getty.edu/page/cona/']),
self::editionhumboldtdigital => self::validateGndId($id, ['https://edition-humboldt.de/register/personen/detail.xql?normid=http://d-nb.info/gnd/']),
self::gnd => self::validateGndId($id, ['http://d-nb.info/gnd/', 'https://d-nb.info/gnd/', 'https://explore.gnd.network/gnd/']),

View File

@@ -80,5 +80,10 @@ final class MDNodaRepositoryTest extends TestCase {
self::assertEquals("land/123", MDNodaRepository::ndp_ikmk->validateId("land/123"));
self::assertEquals(false, MDNodaRepository::ndp_ikmk->validateId("123123"));
# Catalogue of Life
self::assertEquals(false, MDNodaRepository::col->validateId("123123"));
self::assertEquals("C46V", MDNodaRepository::col->validateId("https://www.catalogueoflife.org/data/taxon/C46V"));
self::assertEquals("CRLT8", MDNodaRepository::col->validateId("https://www.catalogueoflife.org/data/taxon/CRLT8"));
}
}