From d4dfbdd179ad1c79a2815b22ee20205e676ac1f4 Mon Sep 17 00:00:00 2001 From: Bogdan Cochior <bogdan.cochior@thinslices.com> Date: Wed, 31 Oct 2018 14:49:42 +0800 Subject: [PATCH] feat(mts): update xml for recommendations --- packages/component-mts-package/src/MTS.js | 8 + packages/component-mts-package/tests/mocks.js | 156 ++++++++++++++- .../tests/sampleUpdated.json | 182 ++++++++++++++++++ .../tests/sampleUpdated.xml | 131 +++++++++++++ 4 files changed, 476 insertions(+), 1 deletion(-) create mode 100644 packages/component-mts-package/tests/sampleUpdated.json create mode 100644 packages/component-mts-package/tests/sampleUpdated.xml diff --git a/packages/component-mts-package/src/MTS.js b/packages/component-mts-package/src/MTS.js index 22d862896..5db0c4870 100644 --- a/packages/component-mts-package/src/MTS.js +++ b/packages/component-mts-package/src/MTS.js @@ -39,6 +39,14 @@ class MTS { return content } + 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)) + } + convertToXML(json = {}) { const content = convert.json2xml(json, this.options) const customId = get( diff --git a/packages/component-mts-package/tests/mocks.js b/packages/component-mts-package/tests/mocks.js index 20519ab02..1eb94b697 100644 --- a/packages/component-mts-package/tests/mocks.js +++ b/packages/component-mts-package/tests/mocks.js @@ -84,7 +84,161 @@ const fragment = { ], } +const fragmentWithRecommendations = { + type: 'fragment', + files: { + coverLetter: [], + manuscripts: [ + { + id: + '9de6c313-1c3e-49eb-bc76-b5d2d045b271/f9916cb6-97a4-4d4c-8a2a-a89b0d10bbdf', + name: 'scimakelatex.2898.adrian+onofrei.pdf', + size: 76051, + originalName: 'scimakelatex.2898.adrian+onofrei.pdf', + }, + ], + supplementary: [], + }, + owners: ['34b0f0be-ea6a-4f5c-81b2-8eca299bdd51'], + authors: [ + { + id: '34b0f0be-ea6a-4f5c-81b2-8eca299bdd51', + email: 'adrian.onofrei+auth1@thinslices.com', + title: 'mr', + country: 'AL', + lastName: 'Adi', + firstName: 'Auth', + affiliation: 'TS', + isSubmitting: true, + isCorresponding: true, + }, + ], + created: '2018-10-18T11:39:40.722Z', + version: 1, + metadata: { + customId: '9999999', + type: 'research', + title: 'Approve by he', + journal: 'Bioinorganic Chemistry and Applications', + abstract: 'test', + }, + conflicts: { + hasFunding: '', + hasConflicts: 'no', + hasDataAvailability: '', + }, + submitted: 1539862801961, + invitations: [ + { + id: '625d7cef-201a-429a-8a91-97404e5e2f31', + role: 'reviewer', + type: 'invitation', + userId: '41ccfd11-9ff8-49b7-a513-58bfede153e8', + hasAnswer: true, + invitedOn: 1539863340777, + isAccepted: true, + respondedOn: 1539863456467, + }, + ], + collectionId: '9c9d9cf1-179f-4f7a-87fa-6e70cffbd3f3', + declarations: { + agree: true, + }, + fragmentType: 'version', + recommendations: [ + { + id: '9e77f9a8-ad88-4996-ae02-7bd2d7b42a00', + userId: '41ccfd11-9ff8-49b7-a513-58bfede153e8', + comments: [ + { + files: [], + public: true, + content: 'revision pls - rev report', + }, + { + files: [], + public: false, + content: 'Rev confidential note for ET', + }, + ], + createdOn: 1539863473823, + updatedOn: 1539863502691, + submittedOn: 1539863502506, + recommendation: 'major', + recommendationType: 'review', + }, + { + id: 'eb4abe60-6484-40e2-b31e-4bf1f1592278', + userId: '46841a2c-0b37-47c0-8847-9cedcaeeb082', + comments: [ + { + files: [], + public: true, + content: 'Author publish message', + }, + { + files: [], + public: false, + content: 'EiC publish message', + }, + ], + createdOn: 1539863568158, + updatedOn: 1539863568158, + recommendation: 'publish', + recommendationType: 'editorRecommendation', + }, + { + id: '6e8cf67c-a969-48d3-9d90-52d02975a65a', + userId: 'f12e0a14-4b6b-4d22-a506-d03c0ac7562f', + comments: [ + { + public: false, + content: 'HE you have to change this', + }, + ], + createdOn: 1539863677902, + updatedOn: 1539863677902, + recommendation: 'return-to-handling-editor', + recommendationType: 'editorRecommendation', + }, + { + id: '0e48444f-dd21-4e91-9b88-cdcfd9cc84d7', + userId: '46841a2c-0b37-47c0-8847-9cedcaeeb082', + comments: [ + { + files: [], + public: true, + content: 'reject author', + }, + { + files: [], + public: false, + content: 'reject eic', + }, + ], + createdOn: 1539863792764, + updatedOn: 1539863792764, + recommendation: 'reject', + recommendationType: 'editorRecommendation', + }, + { + id: '9730b9b0-fd37-46f6-943c-f3666984e2ab', + userId: 'f12e0a14-4b6b-4d22-a506-d03c0ac7562f', + comments: [ + { + public: true, + content: 'shit man', + }, + ], + createdOn: 1539864067558, + updatedOn: 1539864067558, + recommendation: 'reject', + recommendationType: 'editorRecommendation', + }, + ], +} + module.exports = { - fragment, + fragment: fragmentWithRecommendations, config, } diff --git a/packages/component-mts-package/tests/sampleUpdated.json b/packages/component-mts-package/tests/sampleUpdated.json new file mode 100644 index 000000000..760cf8f00 --- /dev/null +++ b/packages/component-mts-package/tests/sampleUpdated.json @@ -0,0 +1,182 @@ +{ + "_declaration": { "_attributes": { "version": "1.0", "encoding": "utf-8" } }, + "_doctype": "article SYSTEM \"JATS-archivearticle1-mathml3.dtd\"", + "article": { + "_attributes": { + "dtd-version": "1.1d1", + "article-type": "Research Article" + }, + "front": { + "journal-meta": { + "journal-id": [ + { "_attributes": { "journal-id-type": "publisher" }, "_text": "BCA" }, + { + "_attributes": { "journal-id-type": "email" }, + "_text": "bca.support@hindawi.com" + } + ], + "journal-title-group": { + "journal-title": { + "_text": "Bioinorganic Chemistry and Applications" + } + }, + "issn": [ + { "_attributes": { "pub-type": "ppub" }, "_text": "2474-7394" }, + { "_attributes": { "pub-type": "epub" } } + ] + }, + "article-meta": { + "article-id": [ + { + "_attributes": { "pub-id-type": "publisher-id" }, + "_text": "BCA-5402665" + }, + { + "_attributes": { "pub-id-type": "manuscript" }, + "_text": "BCA-5402665" + } + ], + "article-categories": { + "subj-group": { + "_attributes": { "subj-group-type": "Article Type" }, + "subject": { "_text": "Review Article" } + } + }, + "title-group": { + "article-title": { + "_text": "Advances in iron compounds as biological agents" + } + }, + "contrib-group": { + "contrib": { + "_attributes": { "contrib-type": "author", "corresp": "Yes" }, + "role": { "_attributes": { "content-type": "1" } }, + "name": { + "surname": { "_text": "Ayodele" }, + "given-names": { "_text": "Odularu" }, + "prefix": { "_text": "dr" } + }, + "email": { "_text": "201106223@ufh.ac.za" }, + "xref": { "_attributes": { "ref-type": "aff", "rid": "aff1" } } + }, + "aff": { + "_attributes": { "id": "aff1" }, + "country": { "_text": "ZA" }, + "addr-line": { + "_text": "University of Fort Hare, Alice 5700, South Africa" + } + } + }, + "history": { + "date": { + "_attributes": { "date-type": "received" }, + "day": { "_text": "24" }, + "month": { "_text": "10" }, + "year": { "_text": "2018" } + } + }, + "abstract": { + "_text": + "Abstract\nThis mini review gives a report of the progresses in the use of iron compounds as biological agents. Review entails coordination of ligands in form of pharmaceutical drugs, reagents used directly as supplied, synthesized organic compounds and natural products from plants to iron(II) or iron(III) ions to yield compounds which were applied as antibacterial, iron natural product, antioxidant and anticancer agents. In addition, in the aspect of material chemistry, holistic application of iron nanoparticles was assessed in relation to health. Iron nanoparticles are best approaches to apply as biological agents when compared to bulk materials because of its affordable, biocompatibity, biodegradability, simple approach to synthesis, ease of modification and non-toxic nature.\n\nKeywords: history of iron; chemistry of iron, uses of iron compounds, iron nanoparticles; biological screening techniques\n" + }, + "funding-group": {} + }, + "rev-group": { + "rev": [ + { + "_attributes": { "rev-type": "reviewer" }, + "name": { + "surname": { "_text": "Mohammed" }, + "given-names": { "_text": "Rizk" }, + "prefix": { "_text": "dr" } + }, + "email": { "_text": "mohammed.rizk@hindawi.com" }, + "date": [ + { + "_attributes": { "date-type": "assignment" }, + "day": { "_text": "24" }, + "month": { "_text": "10" }, + "year": { "_text": "2018" } + }, + { + "_attributes": { "date-type": "submission" }, + "day": { "_text": "24" }, + "month": { "_text": "10" }, + "year": { "_text": "2018" } + } + ], + "comment": { + "_attributes": { "comment-type": "" }, + "_text": + "\n This article is really great! well written and does not need any update. Please publish it as such\n " + } + }, + { + "_attributes": { "rev-type": "editor" }, + "name": { + "surname": { "_text": "Matt" }, + "given-names": { "_text": "Green" }, + "prefix": { "_text": "dr" } + }, + "email": { "_text": "matt.green@hindawi.com" }, + "date": [ + { + "_attributes": { "date-type": "assignment" }, + "day": { "_text": "24" }, + "month": { "_text": "10" }, + "year": { "_text": "2018" } + }, + { + "_attributes": { "date-type": "submission" }, + "day": { "_text": "24" }, + "month": { "_text": "10" }, + "year": { "_text": "2018" } + } + ], + "comment": { + "_attributes": { "comment-type": "" }, + "_text": + "\n This article is really great! well written and does not need any update. Please publish it as such\n " + } + } + ], + "aff": { + "_attributes": { "id": "aff1" }, + "country": { "_text": "ZA" }, + "addr-line": { + "_text": "University of Fort Hare, Alice 5700, South Africa" + } + } + }, + "files": { + "file": { + "item_type": { "_text": "manuscripts" }, + "item_description": { "_text": "23 2018.docx" }, + "item_name": { "_text": "23 2018.docx" } + } + }, + "questions": { + "question": [ + { + "_attributes": { "type": "COI" }, + "answer": { "_text": "No" }, + "statement": {} + }, + { + "_attributes": { "type": "DA" }, + "answer": { "_text": "No" }, + "statement": { + "_text": + "The authors for this paper did not provide a data availability statement" + } + }, + { + "_attributes": { "type": "Fund" }, + "answer": { "_text": "Yes" }, + "statement": {} + } + ] + } + } + } +} diff --git a/packages/component-mts-package/tests/sampleUpdated.xml b/packages/component-mts-package/tests/sampleUpdated.xml new file mode 100644 index 000000000..ef088637d --- /dev/null +++ b/packages/component-mts-package/tests/sampleUpdated.xml @@ -0,0 +1,131 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE article SYSTEM "JATS-archivearticle1-mathml3.dtd"> +<article dtd-version="1.1d1" article-type="Research Article"> + <front> + <journal-meta> + <journal-id journal-id-type="publisher">BCA</journal-id> + <journal-id journal-id-type="email">bca.support@hindawi.com</journal-id> + <journal-title-group> + <journal-title>Bioinorganic Chemistry and Applications</journal-title> + </journal-title-group> + <issn pub-type="ppub">2474-7394</issn> + <issn pub-type="epub"></issn> + </journal-meta> + <article-meta> + <article-id pub-id-type="publisher-id">BCA-5402665</article-id> + <article-id pub-id-type="manuscript">BCA-5402665</article-id> + <article-categories> + <subj-group subj-group-type="Article Type"> + <subject>Review Article</subject> + </subj-group> + </article-categories> + <title-group> + <article-title>Advances in iron compounds as biological agents</article-title> + </title-group> + <contrib-group> + <contrib contrib-type="author" corresp="Yes"> + <role content-type="1"></role> + <name> + <surname>Ayodele</surname> + <given-names>Odularu</given-names> + <prefix>dr</prefix> + </name> + <email>201106223@ufh.ac.za</email> + <xref ref-type="aff" rid="aff1"></xref> + </contrib> + <aff id="aff1"> + <country>ZA</country> + <addr-line>University of Fort Hare, Alice 5700, South Africa</addr-line> + </aff> + </contrib-group> + <history> + <date date-type="received"> + <day>24</day> + <month>10</month> + <year>2018</year> + </date> + </history> + <abstract>Abstract +This mini review gives a report of the progresses in the use of iron compounds as biological agents. Review entails coordination of ligands in form of pharmaceutical drugs, reagents used directly as supplied, synthesized organic compounds and natural products from plants to iron(II) or iron(III) ions to yield compounds which were applied as antibacterial, iron natural product, antioxidant and anticancer agents. In addition, in the aspect of material chemistry, holistic application of iron nanoparticles was assessed in relation to health. Iron nanoparticles are best approaches to apply as biological agents when compared to bulk materials because of its affordable, biocompatibity, biodegradability, simple approach to synthesis, ease of modification and non-toxic nature. + +Keywords: history of iron; chemistry of iron, uses of iron compounds, iron nanoparticles; biological screening techniques +</abstract> + <funding-group></funding-group> + </article-meta> + + <rev-group> + <rev rev-type="reviewer"> + + <name> + <surname>Mohammed</surname> + <given-names>Rizk</given-names> + <prefix>dr</prefix> + </name> + <email>mohammed.rizk@hindawi.com</email> + <date date-type="assignment"> + <day>24</day> + <month>10</month> + <year>2018</year> + </date> + <date date-type="submission"> + <day>24</day> + <month>10</month> + <year>2018</year> + </date> + <comment comment-type=""> + This article is really great! well written and does not need any update. Please publish it as such + </comment> + </rev> + <rev rev-type="editor"> + + <name> + <surname>Matt</surname> + <given-names>Green</given-names> + <prefix>dr</prefix> + </name> + <email>matt.green@hindawi.com</email> + <date date-type="assignment"> + <day>24</day> + <month>10</month> + <year>2018</year> + </date> + <date date-type="submission"> + <day>24</day> + <month>10</month> + <year>2018</year> + </date> + <comment comment-type=""> + This article is really great! well written and does not need any update. Please publish it as such + </comment> + + + </rev> + <aff id="aff1"> + <country>ZA</country> + <addr-line>University of Fort Hare, Alice 5700, South Africa</addr-line> + </aff> + </rev-group> + + <files> + <file> + <item_type>manuscripts</item_type> + <item_description>23 2018.docx</item_description> + <item_name>23 2018.docx</item_name> + </file> + </files> + <questions> + <question type="COI"> + <answer>No</answer> + <statement></statement> + </question> + <question type="DA"> + <answer>No</answer> + <statement>The authors for this paper did not provide a data availability statement</statement> + </question> + <question type="Fund"> + <answer>Yes</answer> + <statement></statement> + </question> + </questions> + </front> +</article> \ No newline at end of file -- GitLab