Commit 13219f9b authored by Audrey Hamelers's avatar Audrey Hamelers
parent efde3021
Pipeline #12992 passed with stages
in 6 minutes and 16 seconds
......@@ -168,14 +168,19 @@ async function createMetadataXML(tmpPath, manuscript) {
manuscript['meta,publicationDates'].length > 0
? manuscript['meta,publicationDates']
.map(pDate => {
let dateStr = `<pub-date pub-type="${pDate.type}">`
let dateStr = `<pub-date pub-type="${pDate.type}">\n `
if (pDate.jatsDate) {
dateStr += Object.keys(pDate.jatsDate).map(
el => `<${el}>${pDate.jatsDate[el]}</${el}>`,
)
dateStr += Object.keys(pDate.jatsDate)
.sort()
.map(el =>
pDate.jatsDate[el]
? `<${el}>${pDate.jatsDate[el]}</${el}>\n `
: '',
)
.join('')
} else {
dateStr += moment(pDate.date).format(
'[<day>]DD[</day>\n<month>]MM[</month>\n<year>]YYYY[</year>]',
'[<day>]DD[</day>\n <month>]MM[</month>\n <year>]YYYY[</year>]',
)
}
dateStr += '</pub-date>'
......@@ -190,9 +195,9 @@ async function createMetadataXML(tmpPath, manuscript) {
audit =>
audit.objectType === 'file' && audit.changes.type === 'manuscript',
).created
xml += `<pub-date pub-type="nihms-submitted">
xml += ` <pub-date pub-type="nihms-submitted">
${moment(submittedDate).format(
'[<day>]DD[</day>\n<month>]MM[</month>\n<year>]YYYY[</year>]',
'[<day>]DD[</day>\n <month>]MM[</month>\n <year>]YYYY[</year>]',
)}
</pub-date>\n`
} catch (ignored) {
......
......@@ -34,7 +34,7 @@ async function uploadCitation(_, { manuscriptId }, { user }) {
articleIds.length > 0
? articleIds
.map(
aid => `<article-id pub-id-type="${aid.pubIdType}">${
aid => `\n<article-id pub-id-type="${aid.pubIdType}">${
aid.id
}</article-id>
`,
......@@ -44,29 +44,21 @@ async function uploadCitation(_, { manuscriptId }, { user }) {
}${
publicationDates.length > 0
? publicationDates
.map(pd => {
const { year, month, day, season } = pd.jatsDate
return `<pub-date pub-type="${pd.type}">${year &&
`
<year>${year}</year>`}${
month
? `
<month>${month}</month>`
: ''
}${
day
? `
<day>${day}</day>`
: ''
}${
season
? `
<season>${season}</season>`
: ''
}
</pub-date>`
})
.join('')
.map(pDate =>
pDate.jatsDate
? `<pub-date pub-type="${pDate.type}">\n ${Object.keys(
pDate.jatsDate,
)
.sort()
.map(el =>
pDate.jatsDate[el]
? `<${el}>${pDate.jatsDate[el]}</${el}>\n `
: '',
)
.join('')}</pub-date>`
: '',
)
.join('\n ')
: ''
}${
citerefUrl
......
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