Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct empty occurenceID so that it is blank, not urn:catalog::: #148

Merged
merged 5 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
227 changes: 227 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"yargs": "^15.4.1"
},
"devDependencies": {
"@shinnn/eslint-config": "^7.0.0",
"ajv": "^6.12.2",
"chai": "^4.2.0",
"esdoc": "^1.1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/wrappers/SpecimenWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ 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 = {
Expand Down Expand Up @@ -159,7 +159,7 @@ class SpecimenWrapper {
*/
get occurrenceID() {
// Return the occurrenceID if it exists.
if (has(this.specimen, 'occurrenceID') && this.specimen.occurrenceID.trim() !== '') {
if (has(this.specimen, 'occurrenceID')) {
return this.specimen.occurrenceID.trim();
}

Expand Down
6 changes: 3 additions & 3 deletions test/scripts/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ describe('bin/resolve.js', function () {
]);

expect(resultObj.Alligatoridae[0].resolved).to.include({
'@id': 'https://tree.opentreeoflife.org/opentree/argus/opentree14.9@ott195670',
'@id': 'https://tree.opentreeoflife.org/opentree/argus/opentree15.1@ott195670',
label: 'Alligatoridae',
});
expect(resultObj.Alligatorinae[0].resolved).to.include({
'@id': 'https://tree.opentreeoflife.org/opentree/argus/opentree14.9@ott151255',
'@id': 'https://tree.opentreeoflife.org/opentree/argus/opentree15.1@ott151255',
label: 'Alligatorinae',
});
expect(resultObj.Crocodylidae[0].resolved).to.include({
'@id': 'https://tree.opentreeoflife.org/opentree/argus/opentree14.9@ott1092501',
'@id': 'https://tree.opentreeoflife.org/opentree/argus/opentree15.1@ott1092501',
label: 'Longirostres',
});
expect(resultObj.Diplocynodontinae[0]).to.include({
Expand Down
6 changes: 6 additions & 0 deletions test/specimens.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ describe('SpecimenWrapper', function () {
expect(wrapped).to.be.an.instanceOf(phyx.SpecimenWrapper);
expect(wrapped.occurrenceID).to.be.undefined;
});
it('should be able to wrap a specimen with an empty occurenceID', function () {
const wrapped = new phyx.SpecimenWrapper(phyx.SpecimenWrapper.fromOccurrenceID(''));

expect(wrapped).to.be.an.instanceOf(phyx.SpecimenWrapper);
expect(wrapped.occurrenceID).to.equal('');
});
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)',
Expand Down
Loading