From 7710b7d50a464631205283bf325ae11add27033e Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Wed, 19 Jun 2024 00:14:28 -0400 Subject: [PATCH 1/3] Updated dwc:basisOfRecord to basisOfRecord. That's what the publication says we should use. I think we previously had dwc: prefixes everywhere, but we didn't notice that this was still around for basisOfRecord until just now. --- src/wrappers/SpecimenWrapper.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wrappers/SpecimenWrapper.js b/src/wrappers/SpecimenWrapper.js index ce8ab8f..5103391 100644 --- a/src/wrappers/SpecimenWrapper.js +++ b/src/wrappers/SpecimenWrapper.js @@ -10,8 +10,8 @@ const { PhyxCacheManager } = require('../utils/PhyxCacheManager'); * * - TaxonomicUnitWrapper.TYPE_SPECIMEN: A specimen. * - Based on http://rs.tdwg.org/dwc/terms/Occurrence - * - Should have a dwc:occurrenceID with the occurrence identifier. - * - Should have a dwc:basisOfRecord to indicate what sort of occurrence this is. + * - Should have a occurrenceID with the occurrence identifier. + * - Should have a basisOfRecord to indicate what sort of occurrence this is. * * Since TaxonNameWrapper follows the TDWG ontology, we'd love to do the same for * SpecimenWrapper, but unfortunately the TaxonOccurrence ontology has been deprecated @@ -38,7 +38,7 @@ class SpecimenWrapper { const normalizedSpecimen = { '@type': SpecimenWrapper.TYPE_SPECIMEN, label: wrapped.label, - 'dwc:basisOfRecord': wrapped.basisOfRecord, + basisOfRecord: wrapped.basisOfRecord, occurrenceID: wrapped.occurrenceID, catalogNumber: wrapped.catalogNumber, institutionCode: wrapped.institutionCode, @@ -62,7 +62,7 @@ class SpecimenWrapper { // Prepare the specimen. const specimen = { '@type': SpecimenWrapper.TYPE_SPECIMEN, - 'dwc:basisOfRecord': basisOfRecord, + basisOfRecord: basisOfRecord, occurrenceID: occurID, }; @@ -185,7 +185,7 @@ class SpecimenWrapper { * Return the basis of record, if one is present. */ get basisOfRecord() { - if (has(this.specimen, 'dwc:basisOfRecord')) return this.specimen['dwc:basisOfRecord']; + if (has(this.specimen, 'basisOfRecord')) return this.specimen.basisOfRecord; return undefined; } @@ -194,7 +194,7 @@ class SpecimenWrapper { * recommended values. */ set basisOfRecord(bor) { - this.specimen['dwc:basisOfRecord'] = bor; + this.specimen.basisOfRecord = bor; } /** Return this specimen as a taxon concept if it contains taxon name information. */ From afc7f9b669b9b6a631f4658f6aebc64ea01dd6ee Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Wed, 19 Jun 2024 00:29:16 -0400 Subject: [PATCH 2/3] Minor fixes. --- src/wrappers/SpecimenWrapper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wrappers/SpecimenWrapper.js b/src/wrappers/SpecimenWrapper.js index 5103391..a919804 100644 --- a/src/wrappers/SpecimenWrapper.js +++ b/src/wrappers/SpecimenWrapper.js @@ -57,12 +57,12 @@ class SpecimenWrapper { static fromOccurrenceID(occurrenceID, basisOfRecord = 'PreservedSpecimen') { // Copy the occurrence ID so we can truncate it if necessary. let occurID = occurrenceID; - if (occurID.startsWith('urn:catalog:')) occurID = occurID.substr(12); + if (occurID.startsWith('urn:catalog:')) occurID = occurID.substring(12); // Prepare the specimen. const specimen = { '@type': SpecimenWrapper.TYPE_SPECIMEN, - basisOfRecord: basisOfRecord, + basisOfRecord, occurrenceID: occurID, }; From fac126971aca9a32db6b9c708b06e88e9047e721 Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Wed, 19 Jun 2024 00:31:55 -0400 Subject: [PATCH 3/3] Updated tests. --- test/specimens.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/specimens.js b/test/specimens.js index 5ef11b5..027c209 100644 --- a/test/specimens.js +++ b/test/specimens.js @@ -24,7 +24,7 @@ describe('SpecimenWrapper', function () { it('should be able to extract an occurenceID and catalogNumber from simple specimen IDs', function () { const wrapper = new phyx.SpecimenWrapper({ occurrenceID: 'Wall 2527, Fiji (uc)', - 'dwc:basisOfRecord': 'PreservedSpecimen', + basisOfRecord: 'PreservedSpecimen', }); expect(wrapper.occurrenceID).to.equal('Wall 2527, Fiji (uc)'); expect(wrapper.catalogNumber).to.equal('Wall 2527, Fiji (uc)'); @@ -33,7 +33,7 @@ describe('SpecimenWrapper', function () { it('should extract institutionCode and catalogNumber from a institutionCode:catalogNumber combination', function () { const wrapper = new phyx.SpecimenWrapper({ occurrenceID: 'FMNH:PR 2081', - 'dwc:basisOfRecord': 'PreservedSpecimen', + basisOfRecord: 'PreservedSpecimen', }); expect(wrapper.occurrenceID).to.equal('FMNH:PR 2081'); expect(wrapper.institutionCode).to.equal('FMNH'); @@ -80,7 +80,7 @@ describe('SpecimenWrapper', function () { expect(specimen.institutionCode).to.equal('FMNH'); expect(specimen.collectionCode).to.equal('PR'); expect(specimen.catalogNumber).to.equal('2081'); - expect(specimen['dwc:basisOfRecord']).to.equal('PreservedSpecimen'); + expect(specimen.basisOfRecord).to.equal('PreservedSpecimen'); }); }); });