Skip to content

Commit

Permalink
Update DOI to metadata blob transform to handle not having a journal
Browse files Browse the repository at this point in the history
  • Loading branch information
markpatton committed Oct 16, 2023
1 parent 3ba5202 commit 30947e7
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions app/services/doi.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,29 +97,32 @@ export default class DoiService extends Service {

// Add issns key in expected format by parsing journal issns.
doiCopy.issns = [];
if (isArray(journal.get('issns'))) {
journal.get('issns').forEach((s) => {
let i = s.indexOf(':');
let value = {};

if (i == -1) {
value.issn = s;
} else {
let prefix = s.substring(0, i);

if (prefix === 'Print') {
value.pubType = 'Print';
} else if (prefix === 'Online') {
value.pubType = 'Online';
}

value.issn = s.substring(i + 1);
}
if (journal) {
if (isArray(journal.get('issns'))) {
journal.get('issns').forEach((s) => {
let i = s.indexOf(':');
let value = {};

if (value.issn.length > 0) {
doiCopy.issns.push(value);
}
});
if (i == -1) {
value.issn = s;
} else {
let prefix = s.substring(0, i);

if (prefix === 'Print') {
value.pubType = 'Print';
} else if (prefix === 'Online') {
value.pubType = 'Online';
}

value.issn = s.substring(i + 1);
}

if (value.issn.length > 0) {
doiCopy.issns.push(value);
}
});
}
}

// Massage 'authors' information
Expand All @@ -138,7 +141,7 @@ export default class DoiService extends Service {
// Misc manual translation
if (doiCopy.nlmta) {
doiCopy['journal-NLMTA-ID'] = doiCopy.nlmta;
} else if (journal.get('nlmta')) {
} else if (journal && journal.get('nlmta')) {
doiCopy['journal-NLMTA-ID'] = journal.get('nlmta');
}
if (doiCopy['container-title-short']) {
Expand Down

0 comments on commit 30947e7

Please sign in to comment.