Commit abc40c01 authored by Maxime Chaillet's avatar Maxime Chaillet

handle special case when there is a single author. It fixes #78.

parent eb5cdb51
This diff is collapsed.
......@@ -28,8 +28,14 @@ GoogleMetadataObject.prototype.setLicense = function () {
GoogleMetadataObject.prototype.setDescription = function () {
if (this.data.name) {
if (!this.data.description) {
if (this.data.author && this.data.author instanceof Array) {
var authors = this.data.author.map(function (author) { return author.name; }).join();
if (this.data.author) {
var authors = "";
if (this.data.author instanceof Array) {
authors = this.data.author.map(function (author) { return author.name; }).join();
} else {
authors = this.data.author.name;
}
var trailingMessage = 'There is currently no additional information regarding the description of this DOI.';
this.data.description = this.data.name + '; ' + authors + '; ' + trailingMessage;
}
......
......@@ -55,5 +55,36 @@ module.exports = {
"@type": "Organization",
"name": "DataCite"
}
},
googleMetadata2: {
"@context": "http://schema.org",
"@type": "Dataset",
"@id": "https://doi.org/10.15151/esrf-es-94374108",
"identifier": {
"@type": "PropertyValue",
"propertyID": "DOI",
"value": "https://doi.org/10.15151/esrf-es-94374108"
},
"url": "https://doi.esrf.fr/10.15151/ESRF-ES-94374108",
"additionalType": "Experiment Session",
"name": "High resolution 3-D structure of Thyroglobulin.",
"author": {
"name": "Didier NURIZZO",
"givenName": "Didier",
"familyName": "NURIZZO",
"@type": "Person"
},
"keywords": "Macromolecular Crystallography, MX-2038, cm01",
"inLanguage": "eng",
"datePublished": "2021",
"schemaVersion": "http://datacite.org/schema/kernel-3",
"publisher": {
"@type": "Organization",
"name": "European Synchrotron Radiation Facility"
},
"provider": {
"@type": "Organization",
"name": "DataCite"
}
}
}
\ No newline at end of file
......@@ -74,7 +74,7 @@ module.exports = {
],
setDescription: [
{
aboutThisTest: 'description is a copy of the name',
aboutThisTest: 'description made using title, authors as array and additional message',
data: library.googleMetadata1,
expected: {
"@context": "http://schema.org",
......@@ -134,6 +134,42 @@ module.exports = {
},
"description": "Nanoscopic Metal Composition of Phagosomal Compartments during Engulfment of E. coli by Professional Phagocytes.; Björn DE SAMBER,Constantin URBAN,Bart VEKEMANS,Gerald FALKENBERG,Ella DE PAUW; There is currently no additional information regarding the description of this DOI.",
}
},
{
aboutThisTest: 'description made using the title, the single author and the additional message',
data: library.googleMetadata2,
expected: {
"@context": "http://schema.org",
"@type": "Dataset",
"@id": "https://doi.org/10.15151/esrf-es-94374108",
"identifier": {
"@type": "PropertyValue",
"propertyID": "DOI",
"value": "https://doi.org/10.15151/esrf-es-94374108"
},
"url": "https://doi.esrf.fr/10.15151/ESRF-ES-94374108",
"additionalType": "Experiment Session",
"name": "High resolution 3-D structure of Thyroglobulin.",
"author": {
"name": "Didier NURIZZO",
"givenName": "Didier",
"familyName": "NURIZZO",
"@type": "Person"
},
"keywords": "Macromolecular Crystallography, MX-2038, cm01",
"inLanguage": "eng",
"datePublished": "2021",
"schemaVersion": "http://datacite.org/schema/kernel-3",
"publisher": {
"@type": "Organization",
"name": "European Synchrotron Radiation Facility"
},
"provider": {
"@type": "Organization",
"name": "DataCite"
},
"description": "High resolution 3-D structure of Thyroglobulin.; Didier NURIZZO; There is currently no additional information regarding the description of this DOI."
}
}
]
};
\ No newline at end of file
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