Skip to content

Commit

Permalink
various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed May 15, 2024
1 parent 30c5443 commit 32f44ff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
7 changes: 4 additions & 3 deletions R/ZenodoManager.R
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ ZenodoManager <- R6Class("ZenodoManager",
result <- self$getDepositions(q = query, all_versions = TRUE, exact = TRUE)
if(length(result)>0){
result <- result[[1]]
if(result$pids$doi$identifier == doi){
if(result$getDOI() == doi){
infoMsg = sprintf("Successfully fetched record for DOI '%s'!",doi)
cli::cli_alert_success(infoMsg)
self$INFO(infoMsg)
Expand Down Expand Up @@ -1467,8 +1467,9 @@ ZenodoManager <- R6Class("ZenodoManager",
logger = self$loggerType)
zenReq$execute()
out <- NULL
if(zenReq$getStatus() == 201){
out <- ZenodoRecord$new(obj = zenReq$getResponse())
if(zenReq$getStatus() == 200){
resp <- zenReq$getResponse()
out <- resp$entries
infoMsg = sprintf("Successful fetched file(s) for record '%s'", recordId)
cli::cli_alert_success(infoMsg)
self$INFO(infoMsg)
Expand Down
10 changes: 10 additions & 0 deletions R/ZenodoRecord.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,21 @@ ZenodoRecord <- R6Class("ZenodoRecord",
})
self$id = obj$id
self$metadata = obj$metadata
#special metadata treatments
resource_type = self$metadata$resource_type
if(!is.null(resource_type)){
resource_type_id = resource_type$id
self$metadata$resource_type = list(id = resource_type_id)
}
self$metadata$related_identifiers = lapply(self$metadata$related_identifiers, function(identifier){
#map DataCite term to zenodo lowercase term
#TODO investigate this is needed
id = identifier
if(is.null(identifier$relation_type) && !is.null(identifier$relation)){
id$relation_type = list(id = tolower(identifier$relation))
}
return(id)
})
self$pids = obj$pids
self$parent = obj$parent

Expand Down
2 changes: 2 additions & 0 deletions R/ZenodoRequest.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ZenodoRequest <- R6Class("ZenodoRequest",
exception = NA,
result = NA,
token = NULL,
accept = "application/vnd.inveniordm.v1+json",
agent = paste0("zen4R_", as(packageVersion("zen4R"),"character")),

prepareData = function(data){
Expand Down Expand Up @@ -224,6 +225,7 @@ ZenodoRequest <- R6Class("ZenodoRequest",
private$file = file
private$progress = progress
private$token = token
private$accept = accept

},

Expand Down

0 comments on commit 32f44ff

Please sign in to comment.