Skip to content
Snippets Groups Projects
Commit abeab643 authored by Sebastian Mihalache's avatar Sebastian Mihalache :hammer_pick:
Browse files

feat(mts-package): handled case for multiple versions

parent c834517e
No related branches found
No related tags found
3 merge requests!160Update staging with master features,!156Develop,!148Hin 1098
......@@ -156,7 +156,7 @@ class Fragment {
recommendations.map(async rec => {
const user = await UserModel.find(rec.userId)
let assignmentDate, submissionDate, isReviewer
let assignmentDate, isReviewer
if (rec.recommendationType === confRecommendations.type.editor) {
if (user.id === collection.handlingEditor.id) {
......@@ -174,19 +174,20 @@ class Fragment {
inv => inv.userId === user.id,
)
assignmentDate = reviewerInvitation.respondedOn
submissionDate = rec.createdOn
isReviewer = true
}
return {
isReviewer,
submissionDate,
assignmentDate,
email: user.email,
title: user.title,
recommendation: rec,
country: user.country,
lastName: user.lastName,
firstName: user.firstName,
submissionDate: rec.createdOn,
affiliation: user.affiliation,
}
}),
)
......
......@@ -94,16 +94,22 @@ module.exports = models => async (req, res) => {
// the manuscript has not yet passed through the EQA process so we need to upload it to the FTP server
if (isEditorInChief && recommendation === 'publish' && !hasEQA) {
if (features.mts) {
const fragmentUsers = await fragmentHelper.getReviewersAndEditorsData({
collection,
UserModel: models.User,
})
await sendMTSPackage({
collection,
fragment,
isEQA: true,
fragmentUsers,
collection.fragments.forEach(async fragmentId => {
const fragment = await models.Fragment.find(fragmentId)
fragmentHelper.fragment = fragment
const fragmentUsers = await fragmentHelper.getReviewersAndEditorsData(
{
collection,
UserModel: models.User,
},
)
await sendMTSPackage({
collection,
fragment,
isEQA: true,
fragmentUsers,
})
})
}
......
......@@ -41,7 +41,7 @@ module.exports = {
}).then(() => {
const packageName = get(xmlFile, 'name', '').replace('.xml', '')
const filename = isEQA
? `ACCEPTED_${packageName}.zip`
? `ACCEPTED_${packageName}.${fragment.version}.zip`
: `${packageName}.zip`
return PackageManager.uploadFiles({
......@@ -52,11 +52,3 @@ module.exports = {
})
},
}
// const convertSample = filePath => {
// const fs = require('fs')
// const xml = fs.readFileSync(filePath, 'utf8')
// const result = convert.xml2js(xml, this.options)
// const newFile = filePath.replace('.xml', '.json')
// return fs.writeFile(newFile, JSON.stringify(result))
// }
......@@ -22,7 +22,7 @@ const createFilesPackage = (s3Config, archiver = nodeArchiver) => {
const { files = {} } = fragment
let packageName = get(xmlFile, 'name', '').replace('.xml', '')
if (isEQA) {
packageName = `ACCEPTED_${packageName}`
packageName = `ACCEPTED_${packageName}.${fragment.version}`
}
try {
const s3FileIDs = Object.values(files)
......
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
process.env.SUPPRESS_NO_CONFIG_WARNING = true
// const MTSService = require('../src/MTS')
// const mocks = require('./mocks')
jest.mock('xml-js', () => ({
json2xml: jest.fn(),
xml2js: jest.fn(),
}))
describe('MTS integration', () => {
// let MTS
// beforeEach(() => {
// MTS = new MTSService(mocks.config.defaultConfig)
// })
// it('should be instantiated', () => {
// const result = MTS
// expect(result).toBeDefined()
// })
// it('should return basic json for XML parsing', () => {
// const result = MTS.composeJson({})
// expect(result).toHaveProperty('article')
// })
// it('should contain configured journal name ', () => {
// const result = MTS.composeJson({ fragment: mocks.fragment })
// expect(result).toHaveProperty(
// 'article.front.journal-meta.journal-title-group.journal-title._text',
// 'Bioinorganic Chemistry and Applications',
// )
// })
})
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