Skip to content

Commit 20e18c8

Browse files
committed
bug fix
Adding the classification statement for copied items
1 parent 897af81 commit 20e18c8

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

R/add_id_statement.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@
1616
#' @importFrom httr POST content
1717
#' @importFrom glue glue
1818
#' @export
19+
1920
add_id_statement <- function(
20-
qid, pid, o,
21+
qid,
22+
pid,
23+
o,
2124
wikibase_type = "external-id",
2225
wikibase_api_url = "https://reprexbase.eu/demowiki/api.php",
2326
csrf) {
27+
2428
datavalue <- paste0('"', o, '"')
2529
datavalue
2630

@@ -53,7 +57,9 @@ add_id_statement <- function(
5357
handle = csrf
5458
)
5559

56-
response <- httr::content(new_claim, as = "parsed", type = "application/json")
60+
response <- httr::content(new_claim,
61+
as = "parsed",
62+
type = "application/json")
5763

5864
if ("error" %in% names(response)) {
5965
warning_message <- glue::glue("Error in 'wbcreateclaim' wrapper add_id_statement():\n", response$error$code, ": ", response$error$info)

R/copy_wikidata_item.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,18 @@ copy_wikidata_item <- function(
355355
)
356356
}
357357

358+
if (is_pid(classification_property) && is_qid(classification_id)) {
359+
## If there is a classification property like instance of or
360+
## subclass of, then try to add a statement about it.
361+
add_item_statement(
362+
qid = created_item_response$entity$id,
363+
pid = classification_property,
364+
o = classification_id,
365+
wikibase_api_url = wikibase_api_url,
366+
csrf = csrf
367+
)
368+
}
369+
358370
# Unwrap the newly created label from the response for checking...
359371
created_item_label <- created_item_response$entity$labels[1]
360372
# ... and the description, too.

0 commit comments

Comments
 (0)