Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xpub-epmc
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Literature-services
public-projects
xpub-epmc
Commits
c4e37d42
Commit
c4e37d42
authored
6 years ago
by
Yogmatee Roochun
Browse files
Options
Downloads
Patches
Plain Diff
reverted
parent
3138edbd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!114
Shared data model
,
!115
Dev
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/ftp-integration/taggedXML.js
+7
-49
7 additions, 49 deletions
server/ftp-integration/taggedXML.js
server/utils/user.js
+20
-4
20 additions, 4 deletions
server/utils/user.js
with
27 additions
and
53 deletions
server/ftp-integration/taggedXML.js
+
7
−
49
View file @
c4e37d42
...
...
@@ -7,9 +7,7 @@ const db = require('../utils/db.js')
const
{
execSync
}
=
require
(
'
child_process
'
)
const
uuidv4
=
require
(
'
uuid/v4
'
)
const
config
=
require
(
'
config
'
)
const
Manuscript
=
require
(
'
../xpub-model/entities/manuscript/data-access
'
)
// const manuscriptModel = require('../xpub-model/entities/manuscript')
const
Team
=
require
(
'
../xpub-model/entities/team/data-access
'
)
const
manuscriptModel
=
require
(
'
../xpub-model/entities/manuscript/data-access
'
)
const
ftpTagger
=
config
.
get
(
'
ftp_tagger
'
)
const
{
...
...
@@ -18,10 +16,10 @@ const {
errorDevEmail
,
}
=
require
(
'
../email
'
)
// const parentRootPath = '/home/yogmatee/projects/PLAY/chokidar/ftp_mock'
const
parentRootPath
=
`
${
process
.
env
.
HOME
}
/
${
config
.
get
(
'
ftp_directory
'
)}
/
${
ftpTagger
.
username
}
`
const
rootPath
=
`
${
parentRootPath
}
/Done`
const
ignoreNewFolder
=
`
${
parentRootPath
}
/New`
...
...
@@ -76,9 +74,7 @@ async function processFile(path) {
try
{
logger
.
info
(
`Processing tagged XML packages:
${
path
}
`
)
const
user
=
await
getUser
.
getFTPUser
()
const
userId
=
user
.
id
const
user
=
await
getUser
.
getFTPUser
(
rootPath
,
path
)
const
tmpPath
=
await
tar
.
createTempDir
()
const
extractedFilePath
=
await
tar
.
untar
(
path
,
tmpPath
)
const
manifestFilename
=
await
files
.
getManifestFilename
(
extractedFilePath
)
...
...
@@ -86,17 +82,7 @@ async function processFile(path) {
extractedFilePath
,
manifestFilename
,
)
const
filesArr
=
await
files
.
checkFiles
(
filesData
,
tmpPath
,
userId
)
// create team
/* await Team.insert(
{
manuscriptId,
userId,
roleName: 'reviewer',
},
userId,
)*/
const
filesArr
=
await
files
.
checkFiles
(
filesData
,
tmpPath
,
user
)
// delete current existing 'tagging' files
await
db
.
deleteTaggingFiles
(
manuscriptId
,
user
)
...
...
@@ -113,13 +99,6 @@ async function processFile(path) {
)
}
const
rows
=
await
Manuscript
.
findByFieldEager
(
'
id
'
,
manuscriptId
,
'
[files]
'
,
)
const
manuscript
=
rows
[
0
]
const
dbFilesArr
=
filesArr
.
map
(
obj
=>
{
obj
.
url
=
`/download/
${
obj
.
minioFileName
}
`
delete
obj
.
extension
...
...
@@ -127,40 +106,19 @@ async function processFile(path) {
return
obj
})
manuscript
.
files
=
manuscript
.
files
.
concat
(
dbFilesArr
)
// create rows in 'file' table
// await db.createTaggersFiles(dbFilesArr)
manuscript
.
pdfDepositState
=
'
WAITING_FOR_PDF_CONVERSION
'
//await manuscriptModel.updatePdfDepositState(manuscriptId)
const
manuscriptDb
=
await
new
Manuscript
(
manuscript
).
saveWithUserAndRole
(
{
relate
:
true
,
unrelate
:
true
,
},
userId
,
'
tagger
'
,
)
/*
manuscriptModel.update(
{ id: manuscriptId, pdfDepositState: 'WAITING_FOR_PDF_CONVERSION' },
user.id,
)
*/
await
db
.
createTaggersFiles
(
dbFilesArr
)
await
files
.
renameFile
(
path
)
logger
.
info
(
'
Uploading to Minio and the database has been completed.
'
)
//
const manuscriptObj = await manuscriptModel.getManuscriptById(manuscriptId)
const
manuscriptObj
=
await
manuscriptModel
.
getManuscriptById
(
manuscriptId
)
// send email to taggers
processedTaggerEmail
(
ftpTagger
.
email
,
manuscriptId
,
manuscript
Db
[
'
meta,title
'
],
manuscript
Obj
[
0
]
[
'
meta,title
'
],
`
${
path
}
`
,
)
// clean up tmp folder
...
...
This diff is collapsed.
Click to expand it.
server/utils/user.js
+
20
−
4
View file @
c4e37d42
...
...
@@ -5,11 +5,27 @@ const Identity = rfr('server/xpub-model/entities/identity/data-access')
const
User
=
rfr
(
'
server/xpub-model/entities/user/data-access
'
)
const
ftpUsers
=
config
.
get
(
'
users
'
)
module
.
exports
.
getFTPUser
=
function
getFTPUser
()
{
module
.
exports
.
getFTPUser
=
function
getFTPUser
(
rootPath
,
filename
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
User
.
findByEmail
(
'
taggers@internal.ebi.ac.uk
'
)
.
then
(
user
=>
{
resolve
(
user
)
const
userName
=
'
taggers
'
Identity
.
findByFieldEager
(
'
meta
'
,
`{"ftpUserName": "
${
userName
}
"}`
,
'
[user]
'
,
)
.
then
(
identityDb
=>
{
const
user
=
ftpUsers
.
find
(
user
=>
user
.
identities
.
filter
(
identity
=>
identity
.
meta
)
.
find
(
identity
=>
identity
.
meta
.
ftpUserName
===
userName
),
)
const
identity
=
user
.
identities
.
filter
(
identity
=>
identity
.
meta
)
.
find
(
identity
=>
identity
.
meta
.
ftpUserName
===
userName
)
/* eslint-disable dot-notation */
identity
[
'
userId
'
]
=
identityDb
[
0
].
userId
resolve
(
identity
)
})
.
catch
(
error
=>
reject
(
error
))
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment