Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix set_orcid_creators #170

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions R/editEMLfunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -2255,7 +2255,7 @@ set_data_urls <- function(eml_object, url = NULL, force = FALSE, NPS = TRUE){
#' creator_orcids <- c("1234-1234-1234-1234", NA, "4321-4321-4321-4321")
#' mymetadata <- set_creator_orcids(mymetadata, creator_orcids)
#' }
set_creator_orcids <- function(eml_object, orcids, force = FALSE, NPS = TRUE){
set_creator_orcids <- function(eml_object, orcids, force = FALSE, NPS = TRUE) {
#if NA supplied as "NA":
if (sum(stringr::str_detect(na.exclude(orcids), "NA")) > 0) {
if (force == FALSE) {
Expand Down Expand Up @@ -2293,8 +2293,12 @@ set_creator_orcids <- function(eml_object, orcids, force = FALSE, NPS = TRUE){
surName <- append(surName,
creator[[i]][["individualName"]][["surName"]])
#what if there is no orcid?
if (is.null(creator[[i]][["userId"]][["userId"]])) {
existing_orcid <- append(existing_orcid, NA)
} else {
existing_orcid <- append(existing_orcid,
creator[[i]][["userId"]][["userId"]])
}
}
}

Expand All @@ -2315,6 +2319,11 @@ set_creator_orcids <- function(eml_object, orcids, force = FALSE, NPS = TRUE){
current_orcids <- tibble::tibble(surName, existing_orcid)
#construct tibble of replacement orcids:
new_orcids <- tibble::tibble(surName, orcids)
for (i in 1:nrow(new_orcids)) {
if(!is.na(new_orcids[i,2])) {
new_orcids[i,2] <- paste0("https://orcid.org/", new_orcids[i,2])
}
}
cat("Your data package contains ORCiDs for the following creators:\n\n")
cat(format(tibble::as_tibble(current_orcids))[c(-3L, -1L)], sep = "\n")
cat("\nAre you sure you want to replace the existing ORCiDs with the following:\n\n")
Expand Down Expand Up @@ -2364,12 +2373,13 @@ set_creator_orcids <- function(eml_object, orcids, force = FALSE, NPS = TRUE){
existing_orcid <- append(existing_orcid,
next_orcid)
} else {
existing_orcid <- append(existing_orcid, "NULL")
existing_orcid <- append(existing_orcid, NA)
}
}
}
#construct tibble of existing orcids:
new_orcids <- tibble::tibble(surName, existing_orcid)
names(new_orcids) <- c("surName", "new_orcids")
cat("Your new ORCiDs are:\n")
cat(format(tibble::as_tibble(new_orcids))[c(-3L, -1L)], sep = "\n")
}
Expand Down
1 change: 1 addition & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ globalVariables(c("UnitCode",
#' var1 <- .get_user_input()
#' }
.get_user_input <- function () {

var1 <- readline(prompt = "1: Yes\n2: No\n")
return(var1)
}
Expand Down
Loading