Skip to contents

Upload rows to CatMapper's uploadInputNodes endpoint using authenticated write requests.

Usage

upload_rows(
  df,
  database,
  form_data = list(),
  action = "add_node",
  add_options = list(district = FALSE, recordyear = FALSE),
  properties = NULL,
  merging_type = "0",
  api_key = NULL,
  poll_interval_seconds = 1,
  timeout_seconds = 600,
  url = NULL
)

Arguments

df

Data frame or list of row objects to upload.

database

Target database, typically "SocioMap" or "ArchaMap".

form_data

Named list matching CatMapper edit-page formData.

action

Upload action option. Supported values map directly to the CatMapperJS Edit-page advanced upload options:

  • "add_node" = "Adding new node for every row"

  • "node_add" = "Updating existing Node properties–add or add to properties"

  • "node_replace" = "Updating existing Node properties–replace one property"

  • "add_uses" = "Adding new uses ties (with old or new nodes)"

  • "update_add" = "Updating existing USES only–add or add to properties"

  • "update_replace" = "Updating existing USES only–replace one property"

  • "add_merging" = "Adding new merging ties for every row"

  • "merging_add" = "Updating existing Merging tie properties–add or add to properties"

  • "merging_replace" = "Updating existing Merging tie properties–replace one property"

add_options

Named list with district and recordyear booleans.

properties

Optional vector/list of upload property names to include.

merging_type

Optional merging mode used by merge upload workflows.

api_key

API key used for authenticated write actions. If NULL, CATMAPR_API_KEY is used.

poll_interval_seconds

Polling interval in seconds while waiting for queued upload tasks.

timeout_seconds

Maximum seconds to wait for upload completion.

url

API URL override. If NULL, CATMAPR_API_URL is used when set.

Value

A data frame built from the upload task result rows returned by the API. The function always triggers a background updateWaitingUSES refresh after upload completion; refresh trigger errors are suppressed.

Examples

if (FALSE) { # \dontrun{
result <- upload_rows(
  df = data.frame(
    CMName = "Yoruba",
    Name = "Yoruba",
    CMID = "",
    Key = "Type == Adamana Brown",
    datasetID = "SD1",
    label = "ETHNICITY",
    stringsAsFactors = FALSE
  ),
  database = "SocioMap",
  form_data = list(
    domain = "ETHNICITY",
    subdomain = "ETHNICITY",
    datasetID = "SD1",
    cmNameColumn = "CMName",
    categoryNamesColumn = "Name",
    alternateCategoryNamesColumns = character(0),
    cmidColumn = "CMID",
    keyColumn = "Key"
  ),
  action = "add_uses",
  properties = c("variable"),
  api_key = Sys.getenv("CATMAPR_API_KEY")
)
head(result)
} # }