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

270 Missing fields when drafting DataCite DOI #305

Merged
merged 5 commits into from
Jan 29, 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
6 changes: 6 additions & 0 deletions src/__testData__/expectedDataCiteStructure.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ const expectedDataCiteStructure = {
},
],
"publisher": "Royal Roads University",
"fundingReferences": [
{
"funderName": "Royal Roads University",
},
],
"publicationYear": 2023,
"subjects": [
{
Expand All @@ -49,6 +54,7 @@ const expectedDataCiteStructure = {
"subject": "abondance et biomasse",
},
],
"version": "1.1",
"dates": [
{
"date": "2023-10-01T19:00:00.000Z",
Expand Down
3 changes: 2 additions & 1 deletion src/__testData__/mockMetadataRecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const mockMetadataRecord = {
"verticalExtentMax": "",
"datePublished": "2023-10-26T19:00:00.000Z",
"dateRevised": null,
"edition": "",
"edition": "1.1",
"recordID": "-Nhi6_2lQjNwKkzdv_Qu",
"instruments": [],
"platform": "",
Expand Down Expand Up @@ -80,6 +80,7 @@ const mockMetadataRecord = {
{
"role": [
"publisher",
"funder",
],
"orgName": "Royal Roads University",
"orgEmail": "",
Expand Down
30 changes: 29 additions & 1 deletion src/utils/recordToDataCite.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ function recordToDataCite(metadata, language, region) {
const publisher = metadata.contacts.find((contact) =>
contact.role.includes("publisher")
);

// Filter all contacts with the role of 'funder'
const funders = metadata.contacts.filter((contact) =>
contact.role.includes("funder")
);

// Get the publication year from the datePublished field
let publicationYear;
Expand Down Expand Up @@ -104,7 +109,7 @@ function recordToDataCite(metadata, language, region) {
dateInformation: "Date when the data was last revised",
});
}

// Look up the license information
const licenseInfo = licenses[metadata.license];

Expand Down Expand Up @@ -174,6 +179,23 @@ function recordToDataCite(metadata, language, region) {
publisher.orgName || publisher.indName;
}

// Add funders list if it exists
if (funders && funders.length > 0) {
mappedDataCiteObject.data.attributes.fundingReferences = funders.map(funder => {
const fundingReference = {
funderName: funder.orgName,
};

// Add ROR information if available
if (funder.orgRor) {
fundingReference.funderIdentifier = funder.orgRor;
fundingReference.funderIdentifierType = "ROR";
}

return fundingReference;
});
}

// Add publication year if it exists
if (metadata.datePublished) {
mappedDataCiteObject.data.attributes.publicationYear = publicationYear;
Expand All @@ -184,6 +206,12 @@ function recordToDataCite(metadata, language, region) {
mappedDataCiteObject.data.attributes.subjects = subjects;
}

// add Version if it exists
if (metadata.edition) {
mappedDataCiteObject.data.attributes.version = metadata.edition;
}


// Add dates if they exist
if (dates.length > 0) {
mappedDataCiteObject.data.attributes.dates = dates;
Expand Down
Loading