Skip to content

Commit bd8b4db

Browse files
committed
#387 support for review
1 parent 2067a4c commit bd8b4db

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed

R/geoflow_action.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ register_actions <- function(){
386386
depositMetadataPattern = list(def = "A regular expression to filter metadata files to upload in Zenodo", class = "character", default = ""),
387387
zipEachDataFile = list(def = "Indicates if each data file should be zipped (to be used in case of large data files", class = "logical", default = FALSE),
388388
publish = list(def = "Indicates if the action should publish the deposit. Requires 'depositWithFiles' set to TRUE", class = "logical", default = FALSE),
389+
review = list(def = "Indicates if the action should submit the record to a review/publication by a community. Requires 'publish' set to TRUE, and a community", class = "logical", default = FALSE),
389390
strategy = list(def = "Strategy to use when handling published records, either 'newversion' (default) or 'edition'", class = "character", choices = list("newversion", "edition"), default = "newversion"),
390391
deleteOldFiles = list(def = "Indicates if the action should delete old files prior upload new files", class = "logical", default = TRUE),
391392
update_metadata = list(def = "For an existing deposit, indicates if metadata elements should be updated", class = "logical", default = TRUE),

inst/actions/zen4R_deposit_record.R

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ function(action, entity, config){
2727
depositMetadataPattern <- action$getOption("depositMetadataPattern")
2828
zipEachDataFile <- action$getOption("zipEachDataFile")
2929
publish <- action$getOption("publish")
30+
review <- action$getOption("review")
3031
strategy <- action$getOption("strategy")
3132
deleteOldFiles <- action$getOption("deleteOldFiles")
3233
update_metadata <- action$getOption("update_metadata")
@@ -416,7 +417,10 @@ function(action, entity, config){
416417
out <- switch(record_status,
417418
"draft" = {
418419
config$logger.info(sprintf("Deposit draft record with id '%s' - publish = %s", zenodo_metadata$id, tolower(as.character(publish))))
419-
ZENODO$depositRecord(zenodo_metadata, publish = publish)
420+
ZENODO$depositRecord(
421+
zenodo_metadata,
422+
publish = FALSE #management of publication later
423+
)
420424
},
421425
"published" = {
422426
switch(strategy,
@@ -450,7 +454,7 @@ function(action, entity, config){
450454
record = zenodo_metadata,
451455
delete_latest_files = deleteOldFiles,
452456
files = files_to_upload,
453-
publish = publish
457+
publish = FALSE #management of publication later
454458
)
455459
}
456460
)
@@ -483,7 +487,7 @@ function(action, entity, config){
483487
record = zenodo_metadata,
484488
delete_latest_files = deleteOldFiles,
485489
files = files_to_upload,
486-
publish = publish
490+
publish = FALSE #management of publication later
487491
)
488492
}
489493
)
@@ -494,7 +498,40 @@ function(action, entity, config){
494498
config$logger.error(errMsg)
495499
stop(errMsg)
496500
}else{
497-
#business logic for communities
501+
502+
if(publish){
503+
if(review){
504+
#publication is delegated to a review procedure by a community
505+
config$logger.info("Delegated record publication (through community review)")
506+
goReview = FALSE
507+
if(length(communities)>0){
508+
zen_com = ZENODO$getCommunityById(communities[1])
509+
if(!is.null(zen_com)){
510+
goReview = TRUE
511+
}else{
512+
config$logger.warn(sprintf("Community '%s' doesn't exist, aborting submission of record for review", communities[1]))
513+
}
514+
}else{
515+
config$logger.warn(sprintf("No community defined, aborting submission of record for review"))
516+
}
517+
518+
if(goReview){
519+
ZENODO$createReviewRequest(out, community = communities[1])
520+
submitted_for_review = ZENODO$submitRecordForReview(out$id)
521+
if(!submitted_for_review){
522+
config$logger.warn(sprintf("Record submission for review to community '%s' didn't work as expected, aborting...", communities[1]))
523+
ZENDO$deleteReviewRequest(out)
524+
}
525+
}
526+
}else{
527+
#direct publication without review by a community
528+
config$logger.info("Direct record publication (without review)")
529+
out = ZENODO$publishRecord(out$id)
530+
}
531+
}
532+
533+
534+
#business logic for communities linkage to published records
498535
#check that record is not yet associated to community
499536
#If ok, then check there is no pending request
500537
#If ok, we submit it to the community
@@ -539,14 +576,14 @@ function(action, entity, config){
539576
if(regexpr("zenodo", doi)>0){
540577
config$metadata$content$entities[[i]]$identifiers[["zenodo_doi_to_save"]] <- out$getDOI()
541578
config$metadata$content$entities[[i]]$identifiers[["zenodo_conceptdoi_to_save"]] <- out$getConceptDOI()
542-
config$metadata$content$entities[[i]]$setStatus("zenodo", ifelse(publish, "published", "draft"))
579+
config$metadata$content$entities[[i]]$setStatus("zenodo", ifelse(publish, if(review) "under review" else "published", "draft"))
543580
}
544581
break;
545582
}
546583
}
547584
entity$identifiers[["zenodo_doi_to_save"]] <- out$getDOI()
548585
entity$identifiers[["zenodo_conceptdoi_to_save"]] <- out$getConceptDOI()
549-
entity$setStatus("zenodo", ifelse(publish, "published", "draft"))
586+
entity$setStatus("zenodo", ifelse(publish, if(review) "under review" else "published", "draft"))
550587

551588
#if publish, we save all
552589
if(publish){

0 commit comments

Comments
 (0)