Package 'ruODK'

Title: An R Client for the ODK Central API
Description: Access and tidy up data from the 'ODK Central' API. 'ODK Central' is a clearinghouse for digitally captured data using ODK <https://docs.getodk.org/central-intro/>. It manages user accounts and permissions, stores form definitions, and allows data collection clients like 'ODK Collect' to connect to it for form download and submission upload. The 'ODK Central' API is documented at <https://docs.getodk.org/central-api/>.
Authors: Florian W. Mayer [aut, cre] , Maëlle Salmon [rev] , Karissa Whiting [rev] , Jason Taylor [rev], Marcelo Tyszler [ctb] , Hélène Langet [ctb] , DBCA [cph, fnd], NWSFTCP [fnd]
Maintainer: Florian W. Mayer <[email protected]>
License: GPL-3
Version: 1.5.1
Built: 2024-11-06 10:20:15 UTC
Source: https://github.com/ropensci/ruODK

Help Index


Download attachments and return the local path.

Description

[Stable]

Usage

attachment_get(
  sid,
  fn,
  local_dir = "media",
  separate = FALSE,
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  verbose = get_ru_verbose()
)

Arguments

sid

One or many ODK submission UUIDs, an MD5 hash.

fn

One or many ODK form attachment filenames, e.g. "1558330537199.jpg".

local_dir

The local folder to save the downloaded files to, default: "media".

separate

(logical) Whether to separate locally downloaded files into a subfolder named after the submission uuid within local_dir, default: FALSE. The defaults mirror the behaviour of submission_export, which keeps all attachment files together in a folder media. Enable this option if downloaded files collide on idential names. This can happen if two data collection devices by chance generate the same filename for two respective media files, e.g. DCIM0001.jpg.

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

Details

This function is the workhorse for handle_ru_attachments. This function is vectorised and can handle either one or many records. Parameters submission_uuid and attachment_filename accept single or exactly the same number of multiple values. The other parameters are automatically repeated.

The media attachments are downloaded into a folder given by local_dir:

workdir/media/filename1.jpg

workdir/media/filename2.jpg

workdir/media/filename3.jpg

Value

The relative file path for the downloaded attachment(s)

See Also

https://docs.getodk.org/central-api-form-management/#downloading-a-form-attachment

https://docs.getodk.org/central-api-submission-management/#downloading-an-attachment

Other utilities: attachment_link(), attachment_url(), drop_null_coords(), form_schema_parse(), get_one_attachment(), get_one_submission(), get_one_submission_att_list(), get_one_submission_audit(), handle_ru_attachments(), handle_ru_datetimes(), handle_ru_geopoints(), handle_ru_geoshapes(), handle_ru_geotraces(), isodt_to_local(), odata_submission_rectangle(), predict_ruodk_name(), prepend_uuid(), split_geopoint(), split_geoshape(), split_geotrace(), strip_uuid(), tidyeval, unnest_all()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

a_local_dir <- here::here()

# Step 2: Get unparsed submissions
fresh_raw <- odata_submission_get(parse = FALSE)

# Step 3: Get attachment field "my_photo"
fresh_parsed <- fresh_raw %>%
  odata_submission_rectangle() %>%
  dplyr::mutate(
    my_photo = attachment_get(id,
      my_photo,
      local_dir = a_local_dir,
      verbose = TRUE
    )
    # Repeat for all other attachment fields
  )

## End(Not run)

List all attachments for a list of submission instances.

Description

List all attachments for a list of submission instances.

Usage

attachment_list(
  iid,
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries()
)

Arguments

iid

A list of submission instance IDs, e.g. from submission_list$instance_id.

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Value

A tibble containing some high-level details of the submission attachments. One row per submission attachment, columns are submission attributes:

    * name: The attachment filename, e.g. 12345.jpg
    * exists: Whether the attachment for that submission exists on the
      server.

See Also

https://docs.getodk.org/central-api-submission-management/#listing-expected-submission-attachments

https://docs.getodk.org/central-api-form-management/#listing-form-attachments

Other submission-management: encryption_key_list(), submission_audit_get(), submission_detail(), submission_export(), submission_get(), submission_list()

Examples

## Not run: 
# Step 1: Setup ruODK with OData Service URL (has url, pid, fid)
ruODK::ru_setup(svc = "...")

# Step 2: List all submissions of form
sl <- submission_list()

# Step 3a: Get attachment list for first submission
al <- get_one_submission_att_list(sl$instance_id[[1]])

# Ste 3b: Get all attachments for all submissions
all <- attachment_list(sl$instance_id)

## End(Not run)

Get server audit log entries.

Description

[Stable]

Usage

audit_get(
  action = NULL,
  start = NULL,
  end = NULL,
  limit = NULL,
  offset = NULL,
  url = Sys.getenv("ODKC_URL"),
  un = Sys.getenv("ODKC_UN"),
  pw = Sys.getenv("ODKC_PW"),
  retries = get_retries()
)

Arguments

action

string. The action to filter the logs, e.g. "user.create". See https://docs.getodk.org/central-api-system-endpoints/#getting-audit-log-entries for the full list of available actions.

start

string. The ISO8601 timestamp of the earliest log entry to return. E.g. ⁠2000-01-01z⁠ or ⁠2000-12-31T23:59.999z⁠, ⁠2000-01-01T12:12:12+08⁠ or 2000-01-01+08.

end

string. The ISO8601 timestamp of the last log entry to return.

limit

integer. The max number of log entries to return.

offset

integer. The number of log entries to skip.

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Details

Parameters to filter the audit logs: ⁠action=form.create&start=2000-01-01z&end=2000-12-31T23%3A59.999z⁠

Value

A tibble containing server audit logs. One row per audited action, columns are submission attributes:

  • actor_id: integer. The ID of the actor, if any, that initiated the action.

  • action: string. The action that was taken.

  • actee_id: uuid, string. The ID of the permissioning object against which the action was taken.

  • details: list. Additional details about the action that vary according to the type of action.

  • logged_at: dttm. Time of action on server.

See Also

https://docs.getodk.org/central-api-system-endpoints/#getting-audit-log-entries

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

logs <- audit_get()

# With search parameters
logs <- audit_get(
  action = "project.update",
  start = "2019-08-01Z",
  end = "2019-08-31Z",
  limit = 100,
  offset = 0
)

# With partial search parameters
logs <- audit_get(
  limit = 100,
  offset = 0
)

logs %>% knitr::kable(.)

# audit_get returns a tibble
class(logs)
# > c("tbl_df", "tbl", "data.frame")

# Audit details
names(logs)
# > "actor_id" "action" "actee_id" "details" "logged_at"

## End(Not run)

Drop any NULL coordinates from a GeoJSON geometry.

Description

This helper patches a bug/feature in ODK Central (versions 0.7-0.9), where geotrace / geoshape GeoJSON contains a last coordinate pair with NULL lat/lon (no alt/acc), and WKT ends in ⁠, undefined NaN⁠.

Usage

drop_null_coords(x)

Arguments

x

A GeoJSON geometry parsed as nested list. E.g. geo_gj$path_location_path_gps.

Details

While split_geotrace and split_geoshape modify the WKT inline, it is more maintainable to separate the GeoJSON cleaner into this function.

This helper drops the last element of a GeoJSON coordinate list if it is list(NULL, NULL).

Value

The nested list minus the last element (if NULL).

See Also

Other utilities: attachment_get(), attachment_link(), attachment_url(), form_schema_parse(), get_one_attachment(), get_one_submission(), get_one_submission_att_list(), get_one_submission_audit(), handle_ru_attachments(), handle_ru_datetimes(), handle_ru_geopoints(), handle_ru_geoshapes(), handle_ru_geotraces(), isodt_to_local(), odata_submission_rectangle(), predict_ruodk_name(), prepend_uuid(), split_geopoint(), split_geoshape(), split_geotrace(), strip_uuid(), tidyeval, unnest_all()

Examples

# A snapshot of geo data with trailing empty coordinates.
data("geo_gj88")

len_coords <- length(geo_gj88$path_location_path_gps[[1]]$coordinates)

length(geo_gj88$path_location_path_gps[[1]]$coordinates[[len_coords]]) %>%
  testthat::expect_equal(2)

geo_gj88$path_location_path_gps[[1]]$coordinates[[len_coords]][[1]] %>%
  testthat::expect_null()

geo_gj88$path_location_path_gps[[1]]$coordinates[[len_coords]][[2]] %>%
  testthat::expect_null()

# The last coordinate pair is a list(NULL, NULL).
# Invalid coordinates like these are a choking hazard for geospatial
# packages. We should remove them before we can convert ODK data into native
# spatial formats, such as sf.
str(geo_gj88$path_location_path_gps[[1]]$coordinates[[len_coords]])

geo_gj_repaired <- geo_gj88 %>%
  dplyr::mutate(
    path_location_path_gps = path_location_path_gps %>%
      purrr::map(drop_null_coords)
  )

len_coords_repaired <- length(
  geo_gj_repaired$path_location_path_gps[[1]]$coordinates
)
testthat::expect_equal(len_coords_repaired + 1, len_coords)

List all encryption keys for a form.

Description

[Maturing]

Usage

encryption_key_list(
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Details

This endpoint provides a listing of all known encryption keys needed to decrypt all Submissions for a given Form. It will return at least the base64RsaPublicKey property (as column public) of all known versions of the form that have submissions against them. If managed keys are being used and a hint was provided, that will be returned as well.

Value

A tibble of encryption keys.

See Also

https://docs.getodk.org/central-api-encryption/

https://docs.getodk.org/central-api-submission-management/#listing-encryption-keys

Other submission-management: attachment_list(), submission_audit_get(), submission_detail(), submission_export(), submission_get(), submission_list()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

x <- encryption_key_list(
  pid = Sys.getenv("ODKC_TEST_PID_ENC"),
  fid = Sys.getenv("ODKC_TEST_FID_ENC"),
  url = get_test_url(),
  un = get_test_un(),
  pw = get_test_pw()
)

names(x)
# > [1] "id" "public" "managed" "hint" "created_at"

## End(Not run)

Return server audit logs of one Entity.

Description

[Maturing]

Usage

entity_audits(
  pid = get_default_pid(),
  did = "",
  eid = "",
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

did

(chr) The name of the Entity List, internally called Dataset. The function will error if this parameter is not given. Default: "".

eid

(chr) The UUID of an Entity, which can be retrieved by entity_list(). The function will error if this parameter is not given. Default: "".

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Details

This returns Server Audit Logs relating to an Entity. The most recent log is returned first.

The authenticated user must have permissions on ODK Central to retrieve audit logs.

Value

A tibble with one row per audit log. See https://docs.getodk.org/central-api-entity-management/#entity-audit-log for the full schema. Top level list elements are renamed from ODK's camelCase to snake_case.

See Also

https://docs.getodk.org/central-api-entity-management/#entity-audit-log

Other entity-management: entity_changes(), entity_create(), entity_delete(), entity_detail(), entity_list(), entity_update(), entity_versions(), entitylist_detail(), entitylist_download(), entitylist_list(), entitylist_update(), odata_entitylist_data_get(), odata_entitylist_metadata_get(), odata_entitylist_service_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

el <- entitylist_list()

# Entity List name (dataset ID, did)
did <- el$name[1]

# All Entities of Entity List
en <- entity_list(did = did)

ed <- entity_detail(did = did, eid = en$uuid[1])

e_label <- ed$current_version$label

# This example updates one field which exists in the example form.
# Your own Entity will have different fields to update.
e_data <- list(
  details = paste0(
    ed$current_version$data$details, ". Updated on ", Sys.time()
  )
)

# Update the Entity (implicitly forced update)
eu <- entity_update(
  did = did,
  eid = en$uuid[1],
  label = e_label,
  data = e_data
)

# Return the server audit logs
ea <- entity_audits(did = did, eid = en$uuid[1])
ea

## End(Not run)

List changes to one Entity.

Description

[Maturing]

Usage

entity_changes(
  pid = get_default_pid(),
  did = "",
  eid = "",
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

did

(chr) The name of the Entity List, internally called Dataset. The function will error if this parameter is not given. Default: "".

eid

(chr) The UUID of an Entity, which can be retrieved by entity_list(). The function will error if this parameter is not given. Default: "".

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Details

This returns the changes, or edits, between different versions of an Entity. These changes are returned as a list of lists. Between two Entities, there is a list of objects representing how each property changed. This change object contains the old and new values, as well as the property name.

Value

A tibble where rows correspond to each Entity update with three columns:

  • old old value

  • new new value

  • propertyName name of changed entity property

See Also

https://docs.getodk.org/central-api-entity-management/#getting-changes-between-versions

Other entity-management: entity_audits(), entity_create(), entity_delete(), entity_detail(), entity_list(), entity_update(), entity_versions(), entitylist_detail(), entitylist_download(), entitylist_list(), entitylist_update(), odata_entitylist_data_get(), odata_entitylist_metadata_get(), odata_entitylist_service_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

el <- entitylist_list()

# Entity List name (dataset ID, did)
did <- el$name[1]

# All Entities of Entity List
en <- entity_list(did = did)

ed <- entity_detail(did = did, eid = en$uuid[1])

e_label <- ed$current_version$label

# This example updates one field which exists in the example form.
# Your own Entity will have different fields to update.
e_data <- list(
  details = paste0(
    ed$current_version$data$details, ". Updated on ", Sys.time()
  )
)

# Update the Entity (implicitly forced update)
eu <- entity_update(
  did = did,
  eid = en$uuid[1],
  label = e_label,
  data = e_data
)

ec <- entity_changes(did = did, eid = en$uuid[1])
ec

## End(Not run)

Creates exactly one Entity in the Dataset.

Description

[Experimental]

Usage

entity_create(
  pid = get_default_pid(),
  did = "",
  label = "",
  uuid = "",
  notes = "",
  data = list(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

did

(chr) The name of the Entity List, internally called Dataset. The function will error if this parameter is not given. Default: "".

label

(character) The Entity label which must be a non-empty string. If the label is given, a single entity is created using data, notes, and uuid if given. If the label is kept at the default (or omitted), multiple entities are created using data and notes and ignoring uuid. Default: "".

uuid

(character) A single UUID to assign to the entity. Default: "". With the default, Central will create and assign a UUID. This parameter is only used when creating a single entity (label non-empty) and ignored when creating multiple entities (label empty).

notes

(character) Metadata about the request which can be retrieved using the entity audit log. Default: "".

data

(list) A named list of Entity properties to create a single Entity, or a nested list with an array of Entity data to create multiple Entities. The nested lists representing individual entities must be valid as in they must contain a label, valid data for the respective entity properties, and can contain an optional UUID. See details and the ODK documentation for the exact format. Default: list().

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Details

Creating a single Entity

For creating a single Entity, include

  • An optional uuid. If skipped, Central will create a UUID for the Entity.

  • The Entity label must be non-empty.

  • A named list data representing the Entity's fields. The value type of all properties is string.

uuid = "..." label = "John Doe" data = list("firstName" = "John", "age" = "22")

This translates to JSON

⁠{ "label": "John Doe", "data": { "firstName": "John", "age": "22" } }⁠

Creating multiple Entities

For creating multiple Entities in bulk, the request body takes an array entities containing a list of Entity objects as described above. The bulk entity version also takes a source property with a required name field and optional size, for example to capture the file name and size of a bulk upload source (in MB).

data=list(
    "entities" = c(
      list("label" = "Entity 1", "data" = list("field1" = "value1")),
      list("label" = "Entity 2", "data" = list("field1" = "value2"))
    ),
    "source" = list("name" = "file.csv", "size" = 100)
  )

This translates to JSON

⁠{ "entities": [...], "source": {"name": "file.csv", "size": 100} }⁠

You can provide notes to store the metadata about the request. The metadata is included in the POST request as header X-Action-Notes and can retrieved using Entity Audit Log.

Value

A nested list identical to the return value of entity_detail. See https://docs.getodk.org/central-api-entity-management/#creating-entities for the full schema. Top level list elements are renamed from ODK's camelCase to snake_case. Nested list elements have the original camelCase.

See Also

https://docs.getodk.org/central-api-entity-management/#creating-entities

Other entity-management: entity_audits(), entity_changes(), entity_delete(), entity_detail(), entity_list(), entity_update(), entity_versions(), entitylist_detail(), entitylist_download(), entitylist_list(), entitylist_update(), odata_entitylist_data_get(), odata_entitylist_metadata_get(), odata_entitylist_service_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

el <- entitylist_list()

# Entity List name (dataset ID, did)
did <- el$name[1]

# All Entities of Entity List
en <- entity_list(did = did)

# Create a single entity
ec <- entity_create(
  did = did,
  label = "Entity label",
  notes = "Metadata about the created entity",
  data = list("field1" = "value1", "field2" = "value1")
)
ec

# Create multiple entities, example: test form "problems"
label <- c(
  glue::glue(
    "Entity {nrow(en) + 1} created by ruODK package test on {Sys.time()}"
  ),
  glue::glue(
    "Entity {nrow(en) + 2} created by ruODK package test on {Sys.time()}"
  )
)
notes <- glue::glue("Two entities created by ruODK package test on {Sys.time()}")
status <- c("needs_followup", "needs_followup")
details <- c("ruODK package test", "ruODK package test")
geometry <- c("-33.2 115.0 0.0 0.0", "-33.2 115.0 0.0 0.0")
data <- data.frame(status, details, geometry, stringsAsFactors = FALSE)
request_data <- list(
  "entities" = data.frame(label, data = I(data), stringsAsFactors = FALSE),
  "source" = list("name" = "file.csv", "size" = 100)
)

# Compare request_data to the schema expected by Central
# https://docs.getodk.org/central-api-entity-management/#creating-entities
# jsonlite::toJSON(request_data, pretty = TRUE, auto_unbox = TRUE)

ec <- entity_create(
  did = did,
  notes = notes,
  data = request_data
)

## End(Not run)

Delete one Entity.

Description

[Maturing]

Usage

entity_delete(
  pid = get_default_pid(),
  did = "",
  eid = "",
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

did

(chr) The name of the Entity List, internally called Dataset. The function will error if this parameter is not given. Default: "".

eid

(chr) The UUID of an Entity, which can be retrieved by entity_list(). The function will error if this parameter is not given. Default: "".

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Details

This function soft-deletes one Entity, , which means it is still in Central's database and you can retrieve it via entity_list(deleted=TRUE).

Value

A list with the key "success" (lgl) indicating whether the entity was deleted.

See Also

https://docs.getodk.org/central-api-entity-management/#deleting-an-entity

Other entity-management: entity_audits(), entity_changes(), entity_create(), entity_detail(), entity_list(), entity_update(), entity_versions(), entitylist_detail(), entitylist_download(), entitylist_list(), entitylist_update(), odata_entitylist_data_get(), odata_entitylist_metadata_get(), odata_entitylist_service_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

el <- entitylist_list()

# Entity List name (dataset ID, did)
did <- el$name[1]

# All Entities of Entity List
en <- entity_list(did = did)

# View details of one Entity
ed <- entity_detail(did = did, eid = en$uuid[1])

# Delete the Entity
ed_deleted <- entity_delete(did = did, eid = ed$id)

## End(Not run)

Show metadata and current data of one Entity.

Description

[Maturing]

Usage

entity_detail(
  pid = get_default_pid(),
  did = "",
  eid = "",
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

did

(chr) The name of the Entity List, internally called Dataset. The function will error if this parameter is not given. Default: "".

eid

(chr) The UUID of an Entity, which can be retrieved by entity_list(). The function will error if this parameter is not given. Default: "".

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Details

This function returns the metadata and current data of an Entity.

The data and label of an Entity are found in the current_version columns under data and label respectively. The current_version column contains version-specific metadata fields such as version, baseVersion, details about conflicts that version introduced, etc. More details are available from entity_versions(). The Entity also contains top-level system metadata such as uuid, created_at and updated_at timestamps, and creator_id (or full creator if extended metadata is requested).

Conflicts

An Entity's metadata also has a conflict field, which indicates the current conflict status of the Entity. The value of a conflict can either be:

  • null. The Entity does not have conflicting versions.

  • soft. The Entity has a version that was based on a version other than the version immediately prior to it. (The specified base_version was not the latest version on the server.)

  • hard. The Entity has a version that was based on a version other than the version immediately prior to it. Further, that version updated the same property as another update.

If an Entity has a conflict, it can be marked as resolved. After that, the conflict field will be null until a new conflicting version is received.

Value

A nested list identical to the return value of entity_update. See https://docs.getodk.org/central-api-entity-management/#getting-entity-details for the full schema. Top level list elements are renamed from ODK's camelCase to snake_case. Nested list elements have the original camelCase.

See Also

https://docs.getodk.org/central-api-entity-management/#entities-metadata

Other entity-management: entity_audits(), entity_changes(), entity_create(), entity_delete(), entity_list(), entity_update(), entity_versions(), entitylist_detail(), entitylist_download(), entitylist_list(), entitylist_update(), odata_entitylist_data_get(), odata_entitylist_metadata_get(), odata_entitylist_service_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

el <- entitylist_list()

# Entity List name (dataset ID, did)
did <- el$name[1]

# All Entities of Entity List
en <- entity_list(did = did)

ed <- entity_detail(did = did, eid = en$uuid[1])

# The current version of the first Entity
ev <- en$current_version_version[1]

## End(Not run)

List all Entities of a kind.

Description

[Maturing]

Usage

entity_list(
  pid = get_default_pid(),
  did = "",
  deleted = FALSE,
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

did

(chr) The name of the Entity List, internally called Dataset. The function will error if this parameter is not given. Default: "".

deleted

(lgl) Whether to get only deleted entities (TRUE) or not (FALSE). Default: FALSE.

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Details

This function returns a list of the Entities of a kind (belonging to an Entity List or Dataset). Please note that this endpoint only returns metadata of the entities, not the data. If you want to get the data of all entities then please refer to the OData Dataset Service.

You can get only deleted entities with deleted=TRUE.

Value

A tibble with exactly one row for each Entity of the given project as per ODK Central API docs. Column names are renamed from ODK's camelCase to snake_case.

See Also

https://docs.getodk.org/central-api-entity-management/#entities-metadata

Other entity-management: entity_audits(), entity_changes(), entity_create(), entity_delete(), entity_detail(), entity_update(), entity_versions(), entitylist_detail(), entitylist_download(), entitylist_list(), entitylist_update(), odata_entitylist_data_get(), odata_entitylist_metadata_get(), odata_entitylist_service_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

el <- entitylist_list()

# Entity List name (dataset ID)
did <- el$name[1]

# All Entities of Entity List
en <- entity_list(did = el$name[1])

# The UUID of the first Entity
eid <- en$uuid[1]

# The current version of the first Entity
ev <- en$current_version_version[1]

## End(Not run)

Update one Entity.

Description

[Experimental]

Usage

entity_update(
  pid = get_default_pid(),
  did = "",
  eid = "",
  label = "",
  data = list(),
  base_version = NULL,
  force = is.null(base_version),
  resolve = FALSE,
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

did

(chr) The name of the Entity List, internally called Dataset. The function will error if this parameter is not given. Default: "".

eid

(chr) The UUID of an Entity, which can be retrieved by entity_list(). The function will error if this parameter is not given. Default: "".

label

(character) The Entity label which must be a non-empty string. Default: "".

data

(list) A named list of Entity properties to update. See details. Default: list().

base_version

If given, must be the current version of the Entity on the server. Optional.

force

(lgl) Whether to force an update. Defaults to be FALSE if a base_version is specified, else defaults to TRUE. Using force=TRUE and specifying a base_version will emit a warning.

resolve

(lgl)

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Details

This endpoint is used to update the label or the properties (passed as JSON in the request body) of an Entity. You only need to include the properties you wish to update. To unset the value of any property, you can set it to empty string (""). The label must be a non-empty string. Setting a property to null will throw an error. Attempting to update a property that doesn't exist in the Dataset will throw an error.

Specifying a base version

You must either provide a base_version or use force=TRUE query parameter. You cannot cause a new Entity conflict via the API, which is why when specifying base_version, it must match the current version of the Entity on the server. This acts as a check to ensure you are not trying to update based on stale data. If you wish to update the Entity regardless of the current state, then you can use the force flag.

Resolving a conflict

You can also use this endpoint to resolve an Entity conflict by passing resolve=true, in which case providing data is optional. When not providing new data, only the conflict status from the Entity will be cleared and no new version will be created. When providing data, the conflict will be cleared and an updated version of the Entity will be added.

Value

A nested list identical to the return value of entity_detail. See https://docs.getodk.org/central-api-entity-management/#updating-an-entity for the full schema. Top level list elements are renamed from ODK's camelCase to snake_case. Nested list elements have the original camelCase.

See Also

https://docs.getodk.org/central-api-entity-management/#updating-an-entity

Other entity-management: entity_audits(), entity_changes(), entity_create(), entity_delete(), entity_detail(), entity_list(), entity_versions(), entitylist_detail(), entitylist_download(), entitylist_list(), entitylist_update(), odata_entitylist_data_get(), odata_entitylist_metadata_get(), odata_entitylist_service_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

el <- entitylist_list()

# Entity List name (dataset ID, did)
did <- el$name[1]

# All Entities of Entity List
en <- entity_list(did = did)

ed <- entity_detail(did = did, eid = en$uuid[1])

e_label <- ed$current_version$label

# This example updates one field which exists in the example form.
# Your own Entity will have different fields to update.
e_data <- list(
  details = paste0(
    ed$current_version$data$details, ". Updated on ", Sys.time()
  )
)

# Update the Entity (implicitly forced update)
eu <- entity_update(
  did = did,
  eid = en$uuid[1],
  label = e_label,
  data = e_data
)
eu

## End(Not run)

List versions of one Entity.

Description

[Maturing]

Usage

entity_versions(
  pid = get_default_pid(),
  did = "",
  eid = "",
  conflict = FALSE,
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

did

(chr) The name of the Entity List, internally called Dataset. The function will error if this parameter is not given. Default: "".

eid

(chr) The UUID of an Entity, which can be retrieved by entity_list(). The function will error if this parameter is not given. Default: "".

conflict

(lgl) Whether to return all versions (FALSE) or whether to returns the subset of past versions of an Entity that are relevant to the Entity's current conflict (TRUE). This includes the latest version, the base version, the previous server version, and any other versions since the last time the Entity was in a conflict-free state. If the Entity is not in conflict, zero versions are returned. Default: FALSE (return all versions)

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Details

This returns the Entity metadata and data for every version of this Entity in ascending creation order.

The ODK Central endpoint supports retrieving extended metadata which this function always returns.

There is an optional query flag relevantToConflict that returns the subset of past versions of an Entity that are relevant to the Entity's current conflict. This includes the latest version, the base version, the previous server version, and any other versions since the last time the Entity was in a conflict-free state. If the Entity is not in conflict, zero versions are returned.

Value

A tibble with one row per version. List columns contain unstructured data. See https://docs.getodk.org/central-api-entity-management/#listing-versions for the full schema. Top level list elements are renamed from ODK's camelCase to snake_case. Nested list elements have the original camelCase.

See Also

https://docs.getodk.org/central-api-entity-management/#listing-versions

Other entity-management: entity_audits(), entity_changes(), entity_create(), entity_delete(), entity_detail(), entity_list(), entity_update(), entitylist_detail(), entitylist_download(), entitylist_list(), entitylist_update(), odata_entitylist_data_get(), odata_entitylist_metadata_get(), odata_entitylist_service_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

el <- entitylist_list()

# Entity List name (dataset ID, did)
did <- el$name[1]

# All Entities of Entity List
en <- entity_list(did = did)

ed <- entity_detail(did = did, eid = en$uuid[1])

# The current version of the first Entity
ev <- en$current_version_version[1]

## End(Not run)

Show Entity List details.

Description

[Maturing]

Usage

entitylist_detail(
  pid = get_default_pid(),
  did = "",
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

did

(chr) The name of the Entity List, internally called Dataset. The function will error if this parameter is not given. Default: "".

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Value

A list of lists following the exact format and naming of the API response. Since this nested list is so deeply nested and irregularly shaped it is not trivial to rectangle the result into a tibble.

See Also

https://docs.getodk.org/central-api-dataset-management/#datasets

Other entity-management: entity_audits(), entity_changes(), entity_create(), entity_delete(), entity_detail(), entity_list(), entity_update(), entity_versions(), entitylist_download(), entitylist_list(), entitylist_update(), odata_entitylist_data_get(), odata_entitylist_metadata_get(), odata_entitylist_service_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

ds <- entitylist_list(pid = get_default_pid())

ds1 <- entitylist_detail(pid = get_default_pid(), did = ds$name[1])

ds1 |> listviewer::jsonedit()

ds1$linked_forms |>
  purrr::list_transpose() |>
  tibble::as_tibble()

ds1$source_forms |>
  purrr::list_transpose() |>
  tibble::as_tibble()

ds1$properties |>
  purrr::list_transpose() |>
  tibble::as_tibble()

## End(Not run)

Download an Entity List as CSV.

Description

[Maturing]

Usage

entitylist_download(
  pid = get_default_pid(),
  did = "",
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  local_dir = here::here(),
  filter = NULL,
  etag = NULL,
  overwrite = TRUE,
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  orders = get_default_orders(),
  tz = get_default_tz(),
  verbose = get_ru_verbose()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

did

(chr) The name of the Entity List, internally called Dataset. The function will error if this parameter is not given. Default: "".

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

local_dir

The local folder to save the downloaded files to, default: here::here. If the folder does not exist it will be created.

filter

(str) A valid filter string. Default: NULL (no filtering, all Entities returned).

etag

(str) The etag value from a previous call to entitylist_download(). The value must be stripped of the ⁠W/\"⁠ and ⁠\"⁠, which is the format of the etag returned by entitylist_download(). If provided, only new entities will be returned. If the same local_dir is chosen and overwrite is set to TRUE, the downloaded CSV will also be overwritten, losing the previously downloaded Entities. Default: NULL (no filtering, all Entities returned).

overwrite

Whether to overwrite previously downloaded file, default: FALSE

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

Details

CSV file

The downloaded CSV file is named after the entity list name. The download location defaults to the current workdir, but can be modified to a different folder path which will be created if it doesn't exist.

Entity Lists can be used as Attachments in other Forms, but they can also be downloaded directly as a CSV file.

The CSV format closely matches the OData Dataset (Entity List) Service format, with columns for system properties such as ⁠__id⁠ (the Entity UUID), ⁠__createdAt⁠, ⁠__creatorName⁠, etc., the Entity Label, and the Dataset (Entity List) or Entity Properties themselves. If any Property for an given Entity is blank (e.g. it was not captured by that Form or was left blank), that field of the CSV is blank.

Filter

The ODK Central ⁠$filter⁠ query string parameter can be used to filter on system-level properties, similar to how filtering in the OData Dataset (Entity List) Service works. Of the OData filter specs ODK Central implements a growing set of features . ruODK provides the parameter filter (str) which, if set, will be passed on to the ODK Central endpoint as is.

Resuming downloads through ETag

The ODK Central endpoint supports the ETag header , which can be used to avoid downloading the same content more than once. When an API consumer calls this endpoint, the endpoint returns a value in the ETag header. If you pass that value in the If-None-Match header of a subsequent request, then if the Entity List has not been changed since the previous request, you will receive 304 Not Modified response; otherwise you'll get the new data. ruODK provides the parameter etag which can be set from the output of a previous call to entitylist_download(). ruODK strips the ⁠W/\"⁠ and ⁠\"⁠ from the returned etag and expects the stripped etag as parameter.

Value

A list of four items:

  • entities (tbl_df) The Entity List as tibble

  • http_status (int) The HTTP status code of the response. 200 if OK, 304 if a given etag finds no new entities created.

  • etag (str) The ETag to use in subsequent calls to entitylist_download()

  • downloaded_to (fs_path) The path to the downloaded CSV file

  • downloaded_on (POSIXct) The time of download in the local timezone

See Also

https://docs.getodk.org/central-api-dataset-management/#datasets

Other entity-management: entity_audits(), entity_changes(), entity_create(), entity_delete(), entity_detail(), entity_list(), entity_update(), entity_versions(), entitylist_detail(), entitylist_list(), entitylist_update(), odata_entitylist_data_get(), odata_entitylist_metadata_get(), odata_entitylist_service_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

ds <- entitylist_list(pid = get_default_pid())

ds1 <- entitylist_download(pid = get_default_pid(), did = ds$name[1])
# ds1$entities
# ds1$etag
# ds1$downloaded_to
# ds1$downloaded_on

ds2 <- entitylist_download(
  pid = get_default_pid(),
  did = ds$name[1],
  etag = ds1$etag
)
# ds2$http_status == 304

newest_entity_date <- as.Date(max(ds1$entities$`__createdAt`))
ds3 <- entitylist_download(
  pid = get_default_pid(),
  did = ds$name[1],
  filter = glue::glue("__createdAt le {newest_entity_date}")
)

## End(Not run)

List all Entity Lists of one Project.

Description

[Maturing]

Usage

entitylist_list(
  pid = get_default_pid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Details

The returned list is useful to retrieve the valid name of an Entity List for further use by functions of the Entity Management family.

Value

A tibble with exactly one row for each Entity List of the given Project as per ODK Central API docs. Column names are renamed from ODK Central's camelCase to snake_case.

See Also

https://docs.getodk.org/central-api-dataset-management/#datasets

Other entity-management: entity_audits(), entity_changes(), entity_create(), entity_delete(), entity_detail(), entity_list(), entity_update(), entity_versions(), entitylist_detail(), entitylist_download(), entitylist_update(), odata_entitylist_data_get(), odata_entitylist_metadata_get(), odata_entitylist_service_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "... .svc", un = "[email protected]", pw = "...")

ds <- entitylist_list(pid = get_default_pid())

ds |> knitr::kable()

## End(Not run)

Update Entity List details.

Description

[Maturing]

Usage

entitylist_update(
  pid = get_default_pid(),
  did = "",
  approval_required = FALSE,
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

did

(chr) The name of the Entity List, internally called Dataset. The function will error if this parameter is not given. Default: "".

approval_required

(lgl) The value to set approvalRequired to. If TRUE, a Submission must be approved before an Entity is created, if FALSE, an Entity is created as soon as the Submission is received by ODK Central. Default: FALSE.

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Details

You can only update approvalRequired using this endpoint. The approvalRequired flag controls the Entity creation flow; if it is true then the Submission must be approved before an Entity can be created from it and if it is false then an Entity is created as soon as the Submission is received by the ODK Central. By default approvalRequired is false for the Entity Lists created after v2023.3. Entity Lists created prior to that will have approvalRequired set to true.

Value

A list of lists following the exact format and naming of the API response for entitylist_detail. Since this nested list is so deeply nested and irregularly shaped it is not trivial to rectangle the result into a tibble.

See Also

https://docs.getodk.org/central-api-dataset-management/#datasets

Other entity-management: entity_audits(), entity_changes(), entity_create(), entity_delete(), entity_detail(), entity_list(), entity_update(), entity_versions(), entitylist_detail(), entitylist_download(), entitylist_list(), odata_entitylist_data_get(), odata_entitylist_metadata_get(), odata_entitylist_service_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

pid <- get_default_pid()

ds <- entitylist_list(pid = pid)

did <- ds$name[1]

ds1 <- entitylist_detail(pid = pid, did = did)
ds1$approvalRequired # FALSE

ds2 <- entitylist_update(pid = pid, did = did, approval_required = TRUE)
ds2$approvalRequired # TRUE

ds3 <- entitylist_update(pid = pid, did = did, approval_required = FALSE)
ds3$approvalRequired # FALSE

## End(Not run)

Show details for one form.

Description

[Stable]

Usage

form_detail(
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Value

A tibble with one row and all form metadata as columns.

See Also

https://docs.getodk.org/central-api-form-management/#getting-form-details

Other form-management: form_list(), form_schema(), form_schema_ext(), form_xml()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

# With explicit credentials, see tests
fl <- form_list()

# The first form in the test project
f <- form_detail(fid = fl$fid[[1]])

# form_detail returns exactly one row
nrow(f)
# > 1

# form_detail returns all form metadata as columns: name, xmlFormId, etc.
names(f)

# > "name" "fid" "version" "state" "submissions" "created_at"
# > "created_by_id" "created_by" "updated_at" "published_at"
# > "last_submission" "hash"

## End(Not run)

List all forms.

Description

[Stable]

Usage

form_list(
  pid = get_default_pid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Value

A tibble with one row per form and all given form metadata as cols. Column names are sanitized into snake_case. Nested columns (review start and created by) are flattened and prefixed. The column xml_form_id is replicated as fid according to ruODK naming standards.

See Also

https://docs.getodk.org/central-api-form-management/#list-all-forms

Other form-management: form_detail(), form_schema(), form_schema_ext(), form_xml()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

# With default pid
fl <- form_list()

# With explicit pid
fl <- form_list(pid = 1)

class(fl)
# > c("tbl_df", "tbl", "data.frame")

# Filter out draft forms (published_at=NA)
only_published_forms <- fl %>% dplyr::filter(is.na(published_at))

# Note: older ODK Central versions < 1.1 have published_at = NA for both
# published and draft forms. Drafts have NA for version and hash.
only_published_forms <- fl %>% dplyr::filter(is.na(version) & is.na(hash))

## End(Not run)

Show the schema of one form.

Description

[Stable]

Usage

form_schema(
  flatten = FALSE,
  odata = FALSE,
  parse = TRUE,
  draft = FALSE,
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  odkc_version = get_default_odkc_version(),
  retries = get_retries(),
  verbose = get_ru_verbose()
)

Arguments

flatten

Whether to flatten the resulting list of lists (TRUE) or not (FALSE, default). Only applies to ODK Central version < 0.8.

odata

Whether to sanitise the field names to match the way they will be outputted for OData. While the original field names as given in the XForms definition may be used as-is for CSV output, OData has some restrictions related to the domain-qualified identifier syntax it uses. Only applies to ODK Central version < 0.8. Default: FALSE.

parse

Whether to parse the form schema into a tibble of form field type and name. This uses form_schema_parse internally. If used together with flatten=TRUE, form_schema will raise a warning and return the unparsed, flattened form schema. Only applies to ODK Central version < 0.8. Default: TRUE.

draft

Whether the form is published (FALSE) or a draft (TRUE). Default: TRUE.

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

Details

ODK Central has introduced a new API endpoint in version 0.8 which returns a parsed and flattened list of fields. This replaces the nested form schema which is challenging to parse.

While users of newer ODK Central versions (> 0.8) can ignore the legacy support for ODK Central's earlier form schema API, users of ODK Central version < 0.8 can set an environment variable ODKC_VERSION to their ODKC's version in format <major>.<minor> e.g. 0.7. This variable caters for future breaking changes.

Either way, form_schema will always return a tibble with columns name, type, path and ruodk_name.

Value

A tibble or nested list (v0.7) containing the form definition. At the lowest nesting level, each form field consists of a list of two nodes, name (the underlying field name) and type (the XForms field type, as in "string", "select1", "geopoint", "binary" and so on). These fields are nested in lists of tuples name (the XForms screen name), children (the fields as described above), type ("structure" for non- repeating screens, "repeat" for repeating screens). A list with name "meta" may precede the structure, if several metadata fields are captured (e.g. "instanceId", form start datetimes etc.). In all cases for ODK Central 0.8, and with default parameters (parse=TRUE) for ODK Central 0.7, form_schema returns a tibble with the columns:

  • name The field name as given in the form schema.

  • type The field type, e.g. "string", "select1", etc.

  • path The XForms path of the field,

  • selectMultiple Whether a field of type "select" is a select multiple (TRUE). Any other types are NA.

  • ruodk_name The predicted field name as generated by odata_submission_get, prefixed by the path, additionally cleaned with make_clean_names to match the cleaned column names from odata_submission_rectangle.

See Also

https://docs.getodk.org/central-api-form-management/#getting-form-schema-fields

Other form-management: form_detail(), form_list(), form_schema_ext(), form_xml()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

# With explicit pid and fid
fs_defaults <- form_schema(pid = 1, fid = "build_xformsId")

# With current ODK Central (v0.8)
fs <- form_schema()

# With defaults, ODK Central v0.7
fs_nested <- form_schema(
  flatten = FALSE,
  odata = FALSE,
  parse = FALSE,
  odkc_version = 0.7
)
listviewer::jsonedit(fs_nested)

fs_flattened <- form_schema(
  flatten = TRUE,
  odata = FALSE,
  parse = FALSE,
  odkc_version = 0.7
)
listviewer::jsonedit(fs_flattened)

# form_schema returns a nested list. There's nothing to change about that.
class(fs_nested)
# > "list"

class(fs_flattened)
# > "list"

# This assumes knowledge of that exact form being tested.
# First node: type "structure" (a field group) named "meta".
fs_nested[[1]]$type
# > "structure"

fs_nested[[1]]$name
# > "meta"

# The first node contains children, which means it's an XForms field group.
names(fs_nested[[1]])
# > "name" "children" "type"

# Next node: a "meta" field of type "string" capturing the  "instanceId".
# First child node of "meta": type "string", name "instanceId".
fs_nested[[1]]$children[[1]]$type
# > "string"
fs_nested[[1]]$children[[1]]$name
# > "instanceID"

# In the flattened version, the field's and it's ancestors' names are the
# components of "path".
fs_flattened[[1]]$path
# > "meta". "instanceId"

fs_flattened[[1]]$type
# > "string"

# Last node: a "meta" field capturing the datetime of form completion
fs_flattened[[length(fs_flattened)]]$type
# > "dateTime"
fs_nested[[length(fs_nested)]]$type
# > "dateTime"

# Parsed into a tibble of form field type/name:
# Useful to inform further parsing of submission data (attachments, dates)
fs <- form_schema(parse = TRUE, odkc_version = 0.7)
fs <- form_schema(odkc_version = 0.8)

# Attachments: used by handle_ru_attachments
fs %>% dplyr::filter(type == "binary")

# dateTime: used by handle_ru_datetimes
fs %>% dplyr::filter(type == "dateTime")

# Point location: used by handle_ru_geopoints
fs %>% dplyr::filter(type == "geopoint")

## End(Not run)

Show the extended schema of one form.

Description

[Experimental]

Usage

form_schema_ext(
  flatten = FALSE,
  odata = FALSE,
  parse = TRUE,
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  odkc_version = get_default_odkc_version(),
  retries = get_retries(),
  verbose = get_ru_verbose()
)

Arguments

flatten

Whether to flatten the resulting list of lists (TRUE) or not (FALSE, default). Only applies to ODK Central version < 0.8.

odata

Whether to sanitise the field names to match the way they will be outputted for OData. While the original field names as given in the XForms definition may be used as-is for CSV output, OData has some restrictions related to the domain-qualified identifier syntax it uses. Only applies to ODK Central version < 0.8. Default: FALSE.

parse

Whether to parse the form schema into a tibble of form field type and name. This uses form_schema_parse internally. If used together with flatten=TRUE, form_schema will raise a warning and return the unparsed, flattened form schema. Only applies to ODK Central version < 0.8. Default: TRUE.

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

Details

ODK Central has introduced a new API endpoint in version 0.8 which returns a parsed and flattened list of fields. This replaces the nested form schema which is challenging to parse. This list is returned by form_schema.

However this still misses important elements, in particular labels and choice_lists.

form_schema_ext returns the same object as form_schema adding labels and choice lists in all languages available. This is done by using the return object from form_xml.

It has the exact function signature as form_schema. In that sense, any call to form_schema can be replaced by form_schema_ext

This function, however, has been prepared with ODK Central version 0.8 or higher. If you use it with an earlier version, a warning will be given.

Value

A tibble containing the form definition. For ODK Central 0.8, and with default parameters (parse=TRUE) for ODK Central 0.7, form_schema returns a tibble with the columns:

  • name The field name as given in the form schema.

  • type The field type, e.g. "string", "select1", etc.

  • path The XForms path of the field,

  • ruodk_name The predicted field name as generated by odata_submission_get, prefixed by the path, additionally cleaned with make_clean_names to match the cleaned column names from odata_submission_rectangle.

  • label The field label as given in the form schema. If specific languages are available, this column will return the default language or it will be empty if this is not specified.

  • label_lang The field label in languange _lang as given in the form schema.

  • choices A list of lists containing at least values and, if available, labels of the choices as given in the form schema. If specific languages are available, this column will return the default language or it will be empty if this is not specified. Please notice that whenever choice filters are applied, this will return the unfiltered choice list.

  • choices_lang A list of lists containing at least values and, if available, labels of the choices in language _lang as given in the form schema. Please notice that whenever choice filters are applied, this will return the unfiltered choice list.

See Also

https://docs.getodk.org/central-api-form-management/#getting-form-schema-fields

https://docs.getodk.org/central-api-form-management/#retrieving-form-xml

Other form-management: form_detail(), form_list(), form_schema(), form_xml()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

# With current ODK Central (>0.7)
# get extended schema:
fsx <- form_schema_ext()

# print choice list in english:
fsx[fsx$name == "test_yn", "choices_english_(en)"][[1]]

# view the extended schema:
fsx

## End(Not run)

Parse a form_schema into a tibble of fields with name, type, and path.

Description

[Stable]

Usage

form_schema_parse(fs, path = "Submissions", verbose = get_ru_verbose())

Arguments

fs

The output of form_schema as nested list

path

The base path for form fields. Default: "Submissions". form_schema_parse recursively steps into deeper nesting levels, which are reflected as separate OData tables. The returned value in path reflects the XForms group name, which translates to separate screens in ODK Collect. Non-repeating form groups will be flattened out into the main Submissions table. Repeating groups are available as separate OData tables.

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

Details

This function is used by form_schema for older versions of ODK Central (pre 0.8). These return the form schema as XML, requiring the quite involved code of form_schema_parse, while newer ODK Central versions return JSON, which is parsed directly in form_schema.

The form_schema returned from ODK Central versions < 0.8 is a nested list of lists containing the form definition. The form definition consists of fields (with a type and name), and form groups, which are rendered as separate ODK Collect screens. Form groups in turn can also contain form fields.

form_schema_parse recursively unpacks the form and extracts the name and type of each field. This information then informs handle_ru_attachments, handle_ru_datetimes, handle_ru_geopoints, handle_ru_geotraces, and handle_ru_geoshapes.

See Also

Other utilities: attachment_get(), attachment_link(), attachment_url(), drop_null_coords(), get_one_attachment(), get_one_submission(), get_one_submission_att_list(), get_one_submission_audit(), handle_ru_attachments(), handle_ru_datetimes(), handle_ru_geopoints(), handle_ru_geoshapes(), handle_ru_geotraces(), isodt_to_local(), odata_submission_rectangle(), predict_ruodk_name(), prepend_uuid(), split_geopoint(), split_geoshape(), split_geotrace(), strip_uuid(), tidyeval, unnest_all()

Examples

## Not run: 
# Option 1: in two steps, ODKC Version 0.7
fs <- form_schema(flatten = FALSE, parse = FALSE, odkc_version = 0.7)
fsp <- form_schema_parse(fs)

# Option 2: in one go
fsp <- form_schema(parse = TRUE)

fsp

## End(Not run)

Show the XML representation of one form as list.

Description

[Stable]

Usage

form_xml(
  parse = TRUE,
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries()
)

Arguments

parse

Whether to parse the XML into a nested list, default: TRUE

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Value

The form XML as a nested list.

See Also

https://docs.getodk.org/central-api-form-management/#retrieving-form-xml

Other form-management: form_detail(), form_list(), form_schema(), form_schema_ext()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

# With explicit pid and fid
fxml_defaults <- form_xml(1, "build_xformsId")

# With defaults
fxml <- form_xml()
listviewer::jsonedit(fxml)

# form_xml returns a nested list
class(fxml)
# > "list"

## End(Not run)

A tibble of submission attachments.

Description

[Stable]

Usage

fq_attachments

Format

A tibble of submission attachments.

Source

The output of attachment_list run on submissions of the test form system.file("extdata", "FloraQuadrat04.xml", package = "ruODK").

See Also

Other included: fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


Parsed submission data for an ODK Central form.

Description

[Stable]

Usage

fq_data

Format

The output of odata_submission_get for a set of example data. A tidy tibble referencing the attachments included in the vignettes and documentation at a relative path ⁠attachments/media/<filename>.<ext>⁠.

Details

The parsed OData response for the submissions of an ODK Central form. This form represents a Flora Quadrat, which is a ca 50 by 50 m quadrat of a uniform plant community.

The XML and .odkbuild versions for this form are available as system.file("extdata", "FloraQuadrat04.xml", package = "ruODK") and system.file("extdata", "FloraQuadrat04.odkbuild", package = "ruODK"), respectively.

This data is kept up to date with the data used in vignettes and package tests. The data is comprised of test records with nonsensical data. The forms used to capture this data are development versions of real-world forms.

Source

See system.file("extdata", "FloraQuadrat04.xml", package = "ruODK") and odata_submission_get.

See Also

Other included: fq_attachments, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


Parsed submission data for a subgroup of an ODK Central form.

Description

[Stable]

Usage

fq_data_strata

Format

The output of odata_submission_get for a set of example data. A tidy tibble referencing the attachments included in the vignettes and documentation at a relative path ⁠attachments/media/<filename>.<ext>⁠.

Details

The parsed OData response for the subgroup of an ODK Central form.

This subgroup represents vegetation strata as per the NVIS classification. A vegetation stratum is a layer of plants with the same height, and dominated by one or few plant taxa. Plant communities can be made of up to five strata, with two to three being most common.

This data is kept up to date with the data used in vignettes and package tests. The data is comprised of test records with nonsensical data. The forms used to capture this data are development versions of real-world forms.

Source

See system.file("extdata", "FloraQuadrat04.xml", package = "ruODK") and odata_submission_get.

See Also

Other included: fq_attachments, fq_data, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


Parsed submission data for a subgroup of an ODK Central form.

Description

[Stable]

Usage

fq_data_taxa

Format

The output of odata_submission_get for a set of example data. A tidy tibble referencing the attachments included in the vignettes and documentation at a relative path ⁠attachments/media/<filename>.<ext>⁠.

Details

The parsed OData response for a subgroup of an ODK Central form.

This subgroup represents an individual plant taxon which is encountered by the enumerators. Typically, one voucher specimen is taken for each distinct encountered plant taxon. A field name is allocated by the enumerators, which can be the proper canonical name (if known) or any other moniker. The voucher specimens are later determined by taxonomic experts, who then provide the real, terminal taxonomic name for a given voucher specimen.

This data is kept up to date with the data used in vignettes and package tests. The data is comprised of test records with nonsensical data. The forms used to capture this data are development versions of real-world forms.

Source

See system.file("extdata", "FloraQuadrat04.xml", package = "ruODK") and odata_submission_get.

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


A tibble of form metadata.

Description

[Stable]

Usage

fq_form_detail

Format

A tibble of form metadata.

Source

The output of form_detail run on submissions of the test form system.file("extdata", "FloraQuadrat04.xml", package = "ruODK").

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


JSON form schema for an ODK Central form.

Description

[Stable]

Usage

fq_form_schema

Format

The output of ruODK::form_schema(), a tibble with columns "type", "name" and "path" and one row per form field.

Details

The parsed form schema of an ODK Central form.

This data is kept up to date with the data used in vignettes and package tests. The data is comprised of test records with nonsensical data. The forms used to capture this data are development versions of real-world forms.

This data is used to build vignettes offline and without the need for credentials to an ODK Central server. The test suite ensures that the "canned" data is identical to the "live" data.

Source

See system.file("extdata", "FloraQuadrat04.xml", package = "ruODK") and ruODK::form_schema().

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


A nested list of a form definition.

Description

[Stable]

Usage

fq_form_xml

Format

A nested list of a form definition.

Source

The output of form_xml run on the test form system.file("extdata", "FloraQuadrat04.xml", package = "ruODK").

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


OData metadata document for an ODK Central form.

Description

[Stable]

Usage

fq_meta

Format

A list of lists

Details

The OData response for the metadata of an ODK Central form.

This data is kept up to date with the data used in vignettes and package tests. The data is comprised of test records with nonsensical data. The forms used to capture this data are development versions of real-world forms.

Source

See system.file("extdata", "FloraQuadrat04.xml", package = "ruODK")

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


A tibble of project metadata.

Description

[Stable]

Usage

fq_project_detail

Format

A tibble of project metadata.

Source

The output of project_detail run on the project containing the test form system.file("extdata", "FloraQuadrat04.xml", package = "ruODK").

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


A tibble of project metadata.

Description

[Stable]

Usage

fq_project_list

Format

A tibble of project metadata.

Source

The output of project_list run on all projects on the configured ODK Central server.

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


OData submission data for an ODK Central form.

Description

[Stable]

Usage

fq_raw

Format

A list of lists

Details

The OData response for the submissions of an ODK Central form. This form represents a Flora Quadrat, which is a ca 50 by 50 m quadrat of a uniform plant community.

The XML and .odkbuild versions for this form are available as system.file("extdata", "FloraQuadrat04.xml", package = "ruODK") and system.file("extdata", "FloraQuadrat04.odkbuild", package = "ruODK"), respectively.

This data is kept up to date with the data used in vignettes and package tests. The data is comprised of test records with nonsensical data. The forms used to capture this data are development versions of real-world forms.

Source

See system.file("extdata", "FloraQuadrat04.xml", package = "ruODK")

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


OData submission data for a subgroup of an ODK Central form.

Description

[Stable]

Usage

fq_raw_strata

Format

A list of lists

Details

The OData response for the subgroup of an ODK Central form.

This subgroup represents vegetation strata as per the NVIS classification. A vegetation stratum is a layer of plants with the same height, and dominated by one or few plant taxa. Plant communities can be made of up to five strata, with two to three being most common.

This data is kept up to date with the data used in vignettes and package tests. The data is comprised of test records with nonsensical data. The forms used to capture this data are development versions of real-world forms.

Source

See system.file("extdata", "FloraQuadrat04.xml", package = "ruODK")

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


OData submission data for a subgroup of an ODK Central form.

Description

[Stable]

Usage

fq_raw_taxa

Format

A list of lists

Details

The OData response for a subgroup of an ODK Central form.

This subgroup represents an individual plant taxon which is encountered by the enumerators. Typically, one voucher specimen is taken for each distinct encountered plant taxon. A field name is allocated by the enumerators, which can be the proper canonical name (if known) or any other moniker. The voucher specimens are later determined by taxonomic experts, who then provide the real, terminal taxonomic name for a given voucher specimen.

This data is kept up to date with the data used in vignettes and package tests. The data is comprised of test records with nonsensical data. The forms used to capture this data are development versions of real-world forms.

Source

See system.file("extdata", "FloraQuadrat04.xml", package = "ruODK")

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


A tibble of submission metadata.

Description

[Stable]

Usage

fq_submission_list

Format

A tibble of submission metadata.

Source

The output of submission_list run on the test form system.file("extdata", "FloraQuadrat04.xml", package = "ruODK").

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


A nested list of submission data.

Description

[Stable]

Usage

fq_submissions

Format

A nested list of submission data.

Source

The output of submission_get run on the test form system.file("extdata", "FloraQuadrat04.xml", package = "ruODK") using submission instance IDs from submission_list.

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


OData service document for an ODK Central form.

Description

[Stable]

Usage

fq_svc

Format

A tibble with one row per submission data endpoint.

Details

The OData response for the metadata of an ODK Central form.

This data is kept up to date with the data used in vignettes and package tests. The data is comprised of test records with nonsensical data. The forms used to capture this data are development versions of real-world forms.

Source

OData service document for system.file("extdata", "FloraQuadrat04.xml", package = "ruODK")

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


A tibble of the main data table of records from a test form.

Description

[Stable]

Usage

fq_zip_data

Format

A tibble of main records from a test form.

Source

submission_export run on the test form system.file("extdata", "FloraQuadrat04.xml", package = "ruODK").

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


A tibble of a repeated sub-group of records from a test form.

Description

[Stable]

Usage

fq_zip_strata

Format

A tibble of repeated sub-group of records from a test form.

Source

submission_export run on the test form system.file("extdata", "FloraQuadrat04.xml", package = "ruODK").

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


A tibble of a repeated sub-group of records from a test form.

Description

[Stable]

Usage

fq_zip_taxa

Format

A tibble of repeated sub-group of records from a test form.

Source

submission_export run on the test form system.file("extdata", "FloraQuadrat04.xml", package = "ruODK").

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


The form_schema of a form containing geofields in GeoJSON.

Description

[Stable]

Usage

geo_fs

Format

An object of class tbl_df (inherits from tbl, data.frame) with 19 rows and 6 columns.

Source

form_schema run on the test form system.file("extdata", "Locations.xml", package = "ruODK").

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


The parsed submissions of a form containing geofields in GeoJSON.

Description

[Stable]

Usage

geo_gj

Format

An object of class tbl_df (inherits from tbl, data.frame) with 1 rows and 58 columns.

Source

odata_submission_get(wkt=FALSE, parse=TRUE) run on the test form system.file("extdata", "Locations.xml", package = "ruODK").

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


The unparsed submissions of a form containing geofields in GeoJSON.

Description

[Stable]

Usage

geo_gj_raw

Format

An object of class list of length 2.

Source

odata_submission_get(wkt=FALSE, parse=FALSE) run on the test form system.file("extdata", "Locations.xml", package = "ruODK").

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_wkt, geo_wkt88, geo_wkt_raw


The parsed submissions of a form containing geofields in GeoJSON with trailing empty coordinates present.

Description

[Stable]

Usage

geo_gj88

Format

An object of class tbl_df (inherits from tbl, data.frame) with 1 rows and 51 columns.

Details

This issue was fixed in #88. ODK Central versions 0.7 - 0.9 export geotraces and geoshapes with trailing empty coordinates. ruODK has a patch to drop trailing empty coordinates. This dataset is used to test the patch in ruODK.

Source

odata_submission_get(wkt=FALSE, parse=TRUE) run on the test form system.file("extdata", "Locations.xml", package = "ruODK").

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj_raw, geo_wkt, geo_wkt88, geo_wkt_raw


The parsed submissions of a form containing geofields in WKT.

Description

[Stable]

Usage

geo_wkt

Format

An object of class tbl_df (inherits from tbl, data.frame) with 1 rows and 55 columns.

Source

odata_submission_get(wkt=TRUE, parse=TRUE) run on the test form system.file("extdata", "Locations.xml", package = "ruODK").

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt88, geo_wkt_raw


The unparsed submissions of a form containing geofields in WKT.

Description

[Stable]

Usage

geo_wkt_raw

Format

An object of class list of length 2.

Source

odata_submission_get(wkt=TRUE, parse=FALSE) run on the test form system.file("extdata", "Locations.xml", package = "ruODK").

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt88


The parsed submissions of a form containing geofields in WKT with trailing empty coordinates present.

Description

[Stable]

Usage

geo_wkt88

Format

An object of class tbl_df (inherits from tbl, data.frame) with 1 rows and 48 columns.

Details

This issue was fixed in #88. ODK Central versions 0.7 - 0.9 export geotraces and geoshapes with trailing empty coordinates. ruODK has a patch to drop trailing empty coordinates. This dataset is used to test the patch in ruODK.

Source

odata_submission_get(wkt=TRUE, parse=TRUE) run on the test form system.file("extdata", "Locations.xml", package = "ruODK").

See Also

Other included: fq_attachments, fq_data, fq_data_strata, fq_data_taxa, fq_form_detail, fq_form_list, fq_form_schema, fq_form_xml, fq_meta, fq_project_detail, fq_project_list, fq_raw, fq_raw_strata, fq_raw_taxa, fq_submission_list, fq_submissions, fq_svc, fq_zip_data, fq_zip_strata, fq_zip_taxa, fs_v7, fs_v7_raw, geo_fs, geo_gj, geo_gj88, geo_gj_raw, geo_wkt, geo_wkt_raw


Download one media attachment.

Description

[Stable]

Usage

get_one_attachment(
  pth,
  fn,
  src,
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  verbose = get_ru_verbose()
)

Arguments

pth

A local file path to save the attachment to.

fn

The attachment filename, as per ODK form submission. If NA, no file will be downloaded, but NA will be returned. If the file does not exist in ODK Central, a warning will be emitted.

src

The attachment's download URL, generated by attachment_url. The src must contain the ⁠uuid:⁠ prefix. Note that the main Submissions table contains the submission id in the field id, whereas nested sub-tables contain the submission id in the field submissions_id.

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

Details

This is a helper function used by attachment_get. This function is not vectorised, but mapped by attachment_get to a tibble of input parameters.

Value

The relative local path to the downloaded attachment or NA.

See Also

Other utilities: attachment_get(), attachment_link(), attachment_url(), drop_null_coords(), form_schema_parse(), get_one_submission(), get_one_submission_att_list(), get_one_submission_audit(), handle_ru_attachments(), handle_ru_datetimes(), handle_ru_geopoints(), handle_ru_geoshapes(), handle_ru_geotraces(), isodt_to_local(), odata_submission_rectangle(), predict_ruodk_name(), prepend_uuid(), split_geopoint(), split_geoshape(), split_geotrace(), strip_uuid(), tidyeval, unnest_all()

Examples

## Not run: 
# Step 1: Setup ruODK with OData Service URL (has url, pid, fid)
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

# Step 2: Construct attachment_url
att_url <- ruODK:::attachment_url(
  "uuid:d3bcefea-32a8-4dbc-80ca-4ecb0678e2b0",
  "filename.jpg"
)

# Step 3: Get one attachment
local_fn <- get_one_attachment("media/filename.jpg", "filename.jpg", att_url)

# In real life: done in bulk behind the scenes during odata_submission_get()

## End(Not run)

Download one submission.

Description

This function is the workhorse for the vectorised function submission_get, which gets all submissions for a list of submission IDs.

Usage

get_one_submission(
  iid,
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries()
)

Arguments

iid

The instance_id, a UUID, as returned by submission_list.

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Details

Note this function returns a nested list containing any repeating subgroups. As the presence and length of repeating subgroups is non-deterministic and entirely depends on the completeness of the submission data, we cannot rectangle them any further here. Rectangling requires knowledge of the form schema and the completeness of submission data.

[Stable]

Value

A nested list of submission data.

See Also

https://docs.getodk.org/central-api-submission-management/#retrieving-submission-xml

Other utilities: attachment_get(), attachment_link(), attachment_url(), drop_null_coords(), form_schema_parse(), get_one_attachment(), get_one_submission_att_list(), get_one_submission_audit(), handle_ru_attachments(), handle_ru_datetimes(), handle_ru_geopoints(), handle_ru_geoshapes(), handle_ru_geotraces(), isodt_to_local(), odata_submission_rectangle(), predict_ruodk_name(), prepend_uuid(), split_geopoint(), split_geoshape(), split_geotrace(), strip_uuid(), tidyeval, unnest_all()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

# With explicit credentials, see tests
sl <- submission_list()

sub <- get_one_submission(sl$instance_id[[1]])
listviewer::jsonedit(sub)

# The details for one submission depend on the form fields
length(sub)
# > 11

# The items are the field names. Repeated groups have the same name.
names(sub)
# > "meta"                     "encounter_start_datetime" "reporter"
# > "device_id"                "location"                 "habitat"
# > "vegetation_structure"     "perimeter"                "taxon_encounter"
# > "taxon_encounter"          "encounter_end_datetime"

## End(Not run)

List all attachments of one submission.

Description

[Stable]

Usage

get_one_submission_att_list(
  iid,
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries()
)

Arguments

iid

The instance_id, a UUID, as returned by submission_list.

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Details

When a Submission is created, either over the OpenRosa or the REST interface, its XML data is analysed to determine which file attachments it references: these may be photos or video taken as part of the survey, or an audit/timing log, among other things. Each reference is an expected attachment, and these expectations are recorded permanently alongside the Submission. With this subresource, you can list the expected attachments, see whether the server actually has a copy or not, and download, upload, re-upload, or clear binary data for any particular attachment.

You can retrieve the list of expected Submission attachments at this route, along with a boolean flag indicating whether the server actually has a copy of the expected file or not. If the server has a file, you can then append its filename to the request URL to download only that file.

Value

A tibble containing some high-level details of the submission attachments. One row per submission attachment, columns are submission attributes:

    * name: The attachment filename, e.g. 12345.jpg
    * exists: Whether the attachment for that submission exists on the
      server.

See Also

https://docs.getodk.org/central-api-submission-management/#listing-expected-submission-attachments

https://docs.getodk.org/central-api-form-management/#listing-form-attachments

Other utilities: attachment_get(), attachment_link(), attachment_url(), drop_null_coords(), form_schema_parse(), get_one_attachment(), get_one_submission(), get_one_submission_audit(), handle_ru_attachments(), handle_ru_datetimes(), handle_ru_geopoints(), handle_ru_geoshapes(), handle_ru_geotraces(), isodt_to_local(), odata_submission_rectangle(), predict_ruodk_name(), prepend_uuid(), split_geopoint(), split_geoshape(), split_geotrace(), strip_uuid(), tidyeval, unnest_all()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

sl <- submission_list()

al <- get_one_submission_att_list(sl$instance_id[[1]])
al %>% knitr::kable(.)

# attachment_list returns a tibble
class(al)
# > c("tbl_df", "tbl", "data.frame")

# Submission attributes are the tibble's columns
names(al)
# > "name" "exists"

## End(Not run)

Download server audit logs for one submission.

Description

[Experimental]

Usage

get_one_submission_audit(
  iid,
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries()
)

Arguments

iid

The instance_id, a UUID, as returned by submission_list.

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Details

This function is the workhorse for the vectorised function submission_audit_get, which gets all server audit logs for a list of submission IDs.

Note this function returns a nested list containing any repeating subgroups. As the presence and length of repeating subgroups is non-deterministic and entirely depends on the completeness of the submission data, we cannot rectangle them any further here. Rectangling requires knowledge of the form schema and the completeness of submission data.

[Stable]

Value

A nested list of submission data.

See Also

https://docs.getodk.org/central-api-submission-management/#retrieving-audit-logs

Other utilities: attachment_get(), attachment_link(), attachment_url(), drop_null_coords(), form_schema_parse(), get_one_attachment(), get_one_submission(), get_one_submission_att_list(), handle_ru_attachments(), handle_ru_datetimes(), handle_ru_geopoints(), handle_ru_geoshapes(), handle_ru_geotraces(), isodt_to_local(), odata_submission_rectangle(), predict_ruodk_name(), prepend_uuid(), split_geopoint(), split_geoshape(), split_geotrace(), strip_uuid(), tidyeval, unnest_all()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

# With explicit credentials, see tests
sl <- submission_list()

sub <- get_one_submission_audit(sl$instance_id[[1]])
listviewer::jsonedit(sub)

# The details for one submission depend on the form fields
length(sub)
# > 11

# The items are the field names. Repeated groups have the same name.
names(sub)
# > "meta"                     "encounter_start_datetime" "reporter"
# > "device_id"                "location"                 "habitat"
# > "vegetation_structure"     "perimeter"                "taxon_encounter"
# > "taxon_encounter"          "encounter_end_datetime"

## End(Not run)

Download and link submission attachments according to a form schema.

Description

[Stable]

Usage

handle_ru_attachments(
  data,
  form_schema,
  local_dir = "media",
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  verbose = get_ru_verbose()
)

Arguments

data

Submissions rectangled into a tibble. E.g. the output of

ruODK::odata_submission_get(parse = FALSE) %>%
ruODK::odata_submission_rectangle()
form_schema

The form_schema for the submissions. E.g. the output of ruODK::form_schema().

local_dir

The local folder to save the downloaded files to, default: "media".

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

Details

For a given tibble of submissions, download and link attachments for all columns which are marked in the form schema as type "binary".

Value

The submissions tibble with all attachments downloaded and linked to a local_dir.

See Also

Other utilities: attachment_get(), attachment_link(), attachment_url(), drop_null_coords(), form_schema_parse(), get_one_attachment(), get_one_submission(), get_one_submission_att_list(), get_one_submission_audit(), handle_ru_datetimes(), handle_ru_geopoints(), handle_ru_geoshapes(), handle_ru_geotraces(), isodt_to_local(), odata_submission_rectangle(), predict_ruodk_name(), prepend_uuid(), split_geopoint(), split_geoshape(), split_geotrace(), strip_uuid(), tidyeval, unnest_all()

Examples

## Not run: 
library(magrittr)
data("fq_raw")
data("fq_form_schema")
t <- tempdir()
fs::dir_ls(t) %>% fs::file_delete()
fq_with_att <- fq_raw %>%
  ruODK::odata_submission_rectangle() %>%
  ruODK::handle_ru_attachments(
    form_schema = fq_form_schema,
    local_dir = t,
    pid = ruODK::get_test_pid(),
    fid = ruODK::get_test_fid(),
    url = ruODK::get_test_url(),
    un = ruODK::get_test_un(),
    pw = ruODK::get_test_pw(),
    verbose <- ruODK::get_ru_verbose()
  )
# There should be files in local_dir
testthat::expect_true(fs::dir_ls(t) %>% length() > 0)

## End(Not run)

Parse datetimes of submission data according to a form schema.

Description

[Stable]

Usage

handle_ru_datetimes(
  data,
  form_schema,
  orders = get_default_orders(),
  tz = get_default_tz(),
  verbose = get_ru_verbose()
)

Arguments

data

Submissions rectangled into a tibble. E.g. the output of

ruODK::odata_submission_get(parse = FALSE) %>%
ruODK::odata_submission_rectangle()
form_schema

The form_schema for the submissions. E.g. the output of ruODK::form_schema().

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

Details

For a given tibble of submissions, parse all columns which are marked in the form schema as type "date" or "dateTime" using a set of lubridate orders and a given timezone.

Value

The submissions tibble with all date/dateTime columns mutated as lubridate datetimes.

See Also

Other utilities: attachment_get(), attachment_link(), attachment_url(), drop_null_coords(), form_schema_parse(), get_one_attachment(), get_one_submission(), get_one_submission_att_list(), get_one_submission_audit(), handle_ru_attachments(), handle_ru_geopoints(), handle_ru_geoshapes(), handle_ru_geotraces(), isodt_to_local(), odata_submission_rectangle(), predict_ruodk_name(), prepend_uuid(), split_geopoint(), split_geoshape(), split_geotrace(), strip_uuid(), tidyeval, unnest_all()

Examples

## Not run: 
library(magrittr)
data("fq_raw")
data("fq_form_schema")

fq_with_dates <- fq_raw %>%
  ruODK::odata_submission_rectangle() %>%
  ruODK::handle_ru_datetimes(form_schema = fq_form_schema)

dplyr::glimpse(fq_with_dates)

## End(Not run)

Split all geopoints of a submission tibble into their components.

Description

[Stable]

Usage

handle_ru_geopoints(data, form_schema, wkt = FALSE, verbose = get_ru_verbose())

Arguments

data

Submissions rectangled into a tibble. E.g. the output of

ruODK::odata_submission_get(parse = FALSE) %>%
ruODK::odata_submission_rectangle()
form_schema

The form_schema for the submissions. E.g. the output of ruODK::form_schema().

wkt

Whether geofields are GeoJSON (if FALSE) or WKT strings (if TRUE), default: FALSE.

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

Details

For a given tibble of submissions, find all columns which are listed in the form schema as type geopoint, and extract their components. Extracted components are longitude (X), latitude (Y), altitude (Z, where given), and accuracy (M, where given).

The original column is retained to allow parsing into other spatially enabled formats.

Value

The submissions tibble with all geopoints retained in their original format, plus columns of their coordinate components as provided by split_geopoint.

See Also

Other utilities: attachment_get(), attachment_link(), attachment_url(), drop_null_coords(), form_schema_parse(), get_one_attachment(), get_one_submission(), get_one_submission_att_list(), get_one_submission_audit(), handle_ru_attachments(), handle_ru_datetimes(), handle_ru_geoshapes(), handle_ru_geotraces(), isodt_to_local(), odata_submission_rectangle(), predict_ruodk_name(), prepend_uuid(), split_geopoint(), split_geoshape(), split_geotrace(), strip_uuid(), tidyeval, unnest_all()

Examples

library(magrittr)
data("geo_fs")
data("geo_gj_raw")
data("geo_wkt_raw")

# GeoJSON
geo_gj_parsed <- geo_gj_raw %>%
  ruODK::odata_submission_rectangle(form_schema = geo_fs) %>%
  ruODK::handle_ru_geopoints(form_schema = geo_fs, wkt = FALSE)

dplyr::glimpse(geo_gj_parsed)

# WKT
geo_wkt_parsed <- geo_wkt_raw %>%
  ruODK::odata_submission_rectangle(form_schema = geo_fs) %>%
  ruODK::handle_ru_geopoints(form_schema = geo_fs, wkt = TRUE)

dplyr::glimpse(geo_wkt_parsed)

Split all geoshapes of a submission tibble into their components.

Description

[Stable]

Usage

handle_ru_geoshapes(
  data,
  form_schema,
  wkt = FALSE,
  odkc_version = get_default_odkc_version(),
  verbose = get_ru_verbose()
)

Arguments

data

Submissions rectangled into a tibble. E.g. the output of

ruODK::odata_submission_get(parse = FALSE) %>%
ruODK::odata_submission_rectangle(form_schema = ...)
form_schema

The form_schema for the submissions. E.g. the output of ruODK::form_schema().

wkt

Whether geofields are GeoJSON (if FALSE) or WKT strings (if TRUE), default: FALSE.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

Details

For a given tibble of submissions, find all columns which are listed in the form schema as type geoshape, and extract their components. Extracted components are longitude (X), latitude (Y), altitude (Z, where given), and accuracy (M, where given) of the first point of the geoshape.

The original column is retained to allow parsing into other spatially enabled formats.

Value

The submissions tibble with all geoshapes retained in their original format, plus columns of their first point's coordinate components as provided by split_geoshape.

See Also

Other utilities: attachment_get(), attachment_link(), attachment_url(), drop_null_coords(), form_schema_parse(), get_one_attachment(), get_one_submission(), get_one_submission_att_list(), get_one_submission_audit(), handle_ru_attachments(), handle_ru_datetimes(), handle_ru_geopoints(), handle_ru_geotraces(), isodt_to_local(), odata_submission_rectangle(), predict_ruodk_name(), prepend_uuid(), split_geopoint(), split_geoshape(), split_geotrace(), strip_uuid(), tidyeval, unnest_all()

Examples

## Not run: 
library(magrittr)
data("geo_fs")
data("geo_wkt_raw")
data("geo_gj_raw")

# GeoJSON
geo_gj_parsed <- geo_gj_raw %>%
  ruODK::odata_submission_rectangle(form_schema = geo_fs) %>%
  ruODK::handle_ru_geoshapes(form_schema = geo_fs, wkt = FALSE)

dplyr::glimpse(geo_gj_parsed)

# WKT
geo_wkt_parsed <- geo_wkt_raw %>%
  ruODK::odata_submission_rectangle(form_schema = geo_fs) %>%
  ruODK::handle_ru_geoshapes(form_schema = geo_fs, wkt = TRUE)

dplyr::glimpse(geo_wkt_parsed)

## End(Not run)

Split all geotraces of a submission tibble into their components.

Description

[Stable]

Usage

handle_ru_geotraces(
  data,
  form_schema,
  wkt = FALSE,
  odkc_version = get_default_odkc_version(),
  verbose = get_ru_verbose()
)

Arguments

data

Submissions rectangled into a tibble. E.g. the output of

ruODK::odata_submission_get(parse = FALSE) %>%
ruODK::odata_submission_rectangle(form_schema = ...)
form_schema

The form_schema for the submissions. E.g. the output of ruODK::form_schema().

wkt

Whether geofields are GeoJSON (if FALSE) or WKT strings (if TRUE), default: FALSE.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

Details

For a given tibble of submissions, find all columns which are listed in the form schema as type geotrace, and extract their components. Extracted components are longitude (X), latitude (Y), altitude (Z, where given), and accuracy (M, where given) of the first point of the geotrace.

The original column is retained to allow parsing into other spatially enabled formats.

Value

The submissions tibble with all geotraces retained in their original format, plus columns of their first point's coordinate components as provided by split_geotrace.

See Also

Other utilities: attachment_get(), attachment_link(), attachment_url(), drop_null_coords(), form_schema_parse(), get_one_attachment(), get_one_submission(), get_one_submission_att_list(), get_one_submission_audit(), handle_ru_attachments(), handle_ru_datetimes(), handle_ru_geopoints(), handle_ru_geoshapes(), isodt_to_local(), odata_submission_rectangle(), predict_ruodk_name(), prepend_uuid(), split_geopoint(), split_geoshape(), split_geotrace(), strip_uuid(), tidyeval, unnest_all()

Examples

## Not run: 
library(magrittr)
data("geo_fs")
data("geo_wkt_raw")
data("geo_gj_raw")

# GeoJSON
geo_gj_parsed <- geo_gj_raw %>%
  ruODK::odata_submission_rectangle(form_schema = geo_fs) %>%
  ruODK::handle_ru_geotraces(form_schema = geo_fs, wkt = FALSE)

dplyr::glimpse(geo_gj_parsed)

# WKT
geo_wkt_parsed <- geo_wkt_raw %>%
  ruODK::odata_submission_rectangle(form_schema = geo_fs) %>%
  ruODK::handle_ru_geotraces(form_schema = geo_fs, wkt = TRUE)

dplyr::glimpse(geo_wkt_parsed)

## End(Not run)

Get the Data Document from the OData Dataset Service.

Description

[Experimental]

Usage

odata_entitylist_data_get(
  pid = get_default_pid(),
  did = "",
  query = NULL,
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

did

(chr) The name of the Entity List, internally called Dataset. The function will error if this parameter is not given. Default: "".

query

An optional named list of query parameters, e.g.

list(
  "$filter" = "__system/createdAt le 2024-11-05",
  "$orderby" = "__system/creatorId ASC, __system/conflict DESC",
  "$top" = "100",
  "$skip" = "3",
  "$count" = "true"
)

No validation is conducted by ruODK on the query list prior to passing it to ODK Central. If omitted, no filter query is sent. Note that the behaviour of this parameter differs from the implementation of odata_submission_get() in that query here accepts a list of all possible OData query parameters and odata_submission_get() offers individual function parameters matching supported OData query parameters. Default: NULL

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Details

All the Entities in a Dataset.

The ⁠$top⁠ and ⁠$skip⁠ querystring parameters, specified by OData, apply limit and offset operations to the data, respectively.

The ⁠$count⁠ parameter, also an OData standard, will annotate the response data with the total row count, regardless of the scoping requested by ⁠$top⁠ and ⁠$skip⁠. If ⁠$top⁠ parameter is provided in the request then the response will include ⁠@odata.nextLink⁠ that you can use as is to fetch the next set of data. As of ODK Central v2023.4, ⁠@odata.nextLink⁠ contains a ⁠$skiptoken⁠ (an opaque cursor) to better paginate around deleted Entities.

The ⁠$filter⁠ querystring parameter can be used to filter certain data fields in the system-level schema, but not the Dataset properties. The operators lt, le, eq, ne, ge, gt, not, and, and or and the built-in functions now, year, month, day, hour, minute, second are supported.

The fields you can query against are as follows:

Entity Metadata: ⁠OData Field Name⁠ Entity Creator Actor ID: ⁠__system/creatorId⁠ Entity Timestamp: ⁠__system/createdAt⁠ Entity Update Timestamp: ⁠__system/updatedAt⁠ Entity Conflict: ⁠__system/conflict⁠

Note that createdAt and updatedAt are time components. This means that any comparisons you make need to account for the full time of the entity. It might seem like ⁠$filter=__system/createdAt le 2020-01-31⁠ would return all results on or before 31 Jan 2020, but in fact only entities made before midnight of that day would be accepted. To include all of the month of January, you need to filter by either ⁠$filter=__system/createdAt le 2020-01-31T23:59:59.999Z⁠ or ⁠$filter=__system/createdAt lt 2020-02-01⁠. Remember also that you can query by a specific timezone.

Please see the OData documentation on ⁠$filter⁠ operations and functions for more information.

The ⁠$select⁠ query parameter will return just the fields you specify and is supported on ⁠__id⁠, ⁠__system⁠, ⁠__system/creatorId⁠, ⁠__system/createdAt⁠ and ⁠__system/updatedAt⁠, as well as on user defined properties.

The ⁠$orderby⁠ query parameter will return Entities sorted by different fields, which come from the same list used by ⁠$filter⁠, as noted above. The order can be specified as ASC (ascending) or DESC (descending), which are case-insensitive. Multiple sort expressions can be used together, separated by commas, e.g. ⁠$orderby=__system/creatorId ASC, __system/conflict DESC⁠.

As the vast majority of clients only support the JSON OData format, that is the only format ODK Central offers.

Value

An S3 class odata_entitylist_data_get with two list items:

  • context The URL for the OData metadata document

  • value A tibble of EntitySets available in this EntityList, with names cleaned by janitor::clean_names() and unnested list columns (⁠__system⁠).

See Also

https://docs.getodk.org/central-api-odata-endpoints/#id3

http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#_Toc31358948

Other entity-management: entity_audits(), entity_changes(), entity_create(), entity_delete(), entity_detail(), entity_list(), entity_update(), entity_versions(), entitylist_detail(), entitylist_download(), entitylist_list(), entitylist_update(), odata_entitylist_metadata_get(), odata_entitylist_service_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

ds <- entitylist_list(pid = get_default_pid())

ds1 <- odata_entitylist_data_get(pid = get_default_pid(), did = ds$name[1])

ds1
ds1$context
ds1$value

qry <- list(
  "$filter" = "__system/createdAt le 2024-11-05",
  "$orderby" = "__system/creatorId ASC, __system/conflict DESC",
  "$top" = "100",
  "$skip" = "3",
  "$count" = "true"
)
ds2 <- odata_entitylist_data_get(
  pid = get_default_pid(),
  did = ds$name[1],
  query = qry
)

ds2

## End(Not run)

Get the Metadata Document from the OData Dataset Service.

Description

[Experimental]

Usage

odata_entitylist_metadata_get(
  pid = get_default_pid(),
  did = "",
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

did

(chr) The name of the Entity List, internally called Dataset. The function will error if this parameter is not given. Default: "".

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Details

The Metadata Document describes, in EDMX CSDL, the schema of all the data you can retrieve from the OData Dataset Service in question. Essentially, these are the Dataset properties, or the schema of each Entity, translated into the OData format.

Value

An S3 class odata_entitylist_metadata_get and list containing the Metadata document following the DDMX CSDL standard

  • version The EDMX version, e.g. "4.0"

  • complex_types

  • entity_types

  • containers

See Also

https://docs.getodk.org/central-api-odata-endpoints/#id2

https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.html

Other entity-management: entity_audits(), entity_changes(), entity_create(), entity_delete(), entity_detail(), entity_list(), entity_update(), entity_versions(), entitylist_detail(), entitylist_download(), entitylist_list(), entitylist_update(), odata_entitylist_data_get(), odata_entitylist_service_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

ds <- entitylist_list(pid = get_default_pid())

dm1 <- odata_entitylist_metadata_get(pid = get_default_pid(), did = ds$name[1])

# Overview
print(dm1)

# Get all property names for an entity type
names(dm1$entity_types$Entities$properties)

# Check what properties are non-filterable
dm1$containers$trees$entity_sets$Entities$capabilities

# Get complex type definitions
dm1$complex_types$metadata$properties

## End(Not run)

Get the Service Document from the OData Dataset Service.

Description

[Experimental]

Usage

odata_entitylist_service_get(
  pid = get_default_pid(),
  did = "",
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

did

(chr) The name of the Entity List, internally called Dataset. The function will error if this parameter is not given. Default: "".

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Details

ODK Central presents one OData service for every Dataset (Entity List) as a way to get an OData feed of Entities. To access the OData service, add .svc to the resource URL for the given Dataset (Entity List).

The Service Document provides a link to the main source of information in this OData service: the list of Entities in this Dataset, as well as the Metadata Document describing the schema of this information.

This document is available only in JSON format.

Value

An S3 class odata_entitylist_service_get with two list items:

  • context The URL for the OData metadata document

  • value A tibble of EntitySets available in this EntityList

See Also

https://docs.getodk.org/central-api-odata-endpoints/#odata-dataset-service

Other entity-management: entity_audits(), entity_changes(), entity_create(), entity_delete(), entity_detail(), entity_list(), entity_update(), entity_versions(), entitylist_detail(), entitylist_download(), entitylist_list(), entitylist_update(), odata_entitylist_data_get(), odata_entitylist_metadata_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

ds <- entitylist_list(pid = get_default_pid())

ds1 <- odata_entitylist_service_get(pid = get_default_pid(), did = ds$name[1])

ds1
ds1$context
ds1$value

## End(Not run)

Retrieve metadata from an OData URL ending in .svc as list of lists.

Description

[Stable]

Usage

odata_metadata_get(
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Value

A nested list containing Edmx (dataset schema definition) and .attrs (Version).

See Also

https://docs.getodk.org/central-api-odata-endpoints/#metadata-document

Other odata-api: odata_service_get(), odata_submission_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

meta <- odata_metadata_get()
listviewer::jsonedit(meta)

## End(Not run)

Retrieve service metadata from an OData URL ending in .svc as tibble.

Description

[Stable]

Usage

odata_service_get(
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Value

A tibble with one row per submission data endpoint. Columns: name, kind, url.

See Also

https://docs.getodk.org/central-api-odata-endpoints/#service-document

Other odata-api: odata_metadata_get(), odata_submission_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

svc <- odata_service_get()
svc

## End(Not run)

Retrieve and rectangle form submissions, parse dates, geopoints, download and link attachments.

Description

[Stable]

Usage

odata_submission_get(
  table = "Submissions",
  skip = NULL,
  top = NULL,
  count = FALSE,
  wkt = FALSE,
  expand = FALSE,
  filter = NULL,
  parse = TRUE,
  download = TRUE,
  orders = get_default_orders(),
  local_dir = "media",
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  odkc_version = get_default_odkc_version(),
  tz = get_default_tz(),
  retries = get_retries(),
  verbose = get_ru_verbose()
)

Arguments

table

The submission EntityType, or in plain words, the table name. Default: Submissions (the main table). Change to Submissions.GROUP_NAME for repeating form groups. The group name can be found through odata_service_get.

skip

The number of rows to be omitted from the results. Example: 10, default: NA (none skipped).

top

The number of rows to return. Example: 100, default: NA (all returned).

count

If TRUE, an @odata.count property will be returned in the response from ODK Central. Default: FALSE.

wkt

If TRUE, geospatial data will be returned as WKT (Well Known Text) strings. Default: FALSE, returns GeoJSON structures. Note that accuracy is only returned through GeoJSON.

expand

If TRUE, all subtables will be expanded and included with column names containing the number of the repeat, the group name, and the field name. This parameter is supported from ODK Central v1.2 onwards and will be ignored on earlier versions of ODK Central. The version is inferred from the parameter odkc_version. Default: FALSE.

filter

If provided, will filter responses to those matching the query. For an odkc_version below 1.1, this parameter will be discarded. As of ODK Central v1.5, the fields system/submitterId, system/submissionDate, ⁠__system/updatedAt⁠ and ⁠__system/reviewState⁠ are available to reference. The operators lt, lte, eq, neq, gte, gt, not, and, and or are supported, and the built-in functions now, year, month, day, hour, minute, second. ruODK does not validate the query string given to filter. It is highly recommended to refer to the ODK Central API documentation as well as the OData spec on filters. for filter options and capabilities.

parse

Whether to parse submission data based on form schema. Dates and datetimes will be parsed into local time. Attachments will be downloaded, and the field updated to the local file path. Point locations will be split into components; GeoJSON (wkt=FALSE) will be split into latitude, longitude, altitude and accuracy (with anonymous field names), while WKT will be split into longitude, latitude,and altitude (missing accuracy) prefixed by the original field name. See details for the handling of geotraces and geoshapes. Default: TRUE.

download

Whether to download attachments to local_dir or not. If in the future ODK Central supports hot-linking attachments, this parameter will replace attachment file names with their fully qualified attachment URL. Default: TRUE.

orders

(vector of character) Orders of datetime elements for lubridate. Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

local_dir

The local folder to save the downloaded files to, default: "media".

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

Details

odata_submission_get downloads submissions from (default) the main form group (submission table) including any non-repeating form groups, or from any other table as specified by parameter table.

With parameter parse=TRUE (default), submission data is parsed into a tibble. Any fields of type dateTime or date are parsed into dates, with an optional parameter tz to specify the local timezone.

A parameter local_dir (default: media) specifies a local directory for downloaded attachment files. Already existing, previously downloaded attachments will be retained.

With parameter wkt=TRUE, spatial fields will be returned as WKT, rather than GeoJSON. In addition, fields of type geopoint will be split into latitude, longitude, and altitude, prefixed with the original field name. E.g. a field start_location of type geopoint will be split into start_location_latitude, start_location_longitude, and start_location_altitude. The field name prefix will allow multiple fields of type geopoint to be split into their components without naming conflicts.

Geotraces (lines) and gepshapes (polygons) will be retained in their original format, plus columns of their first point's coordinate components as provided by split_geotrace and split_geoshape, respectively.

Entirely unpopulated form fields, as well as notes and form groups, will be excluded from the resulting tibble. Submitting at least one complete form instance will prevent the accidental exclusion of an otherwise mostly empty form field.

The only remaining manual step is to optionally join any sub-tables to the master table.

The parameter verbose enables diagnostic messages along the download and parsing process.

With parameter parse=FALSE, submission data is presented as nested list, which is the R equivalent of the JSON structure returned from the API. From there, odata_submission_rectangle can rectangle the data into a tibble, and subsequent lines of handle_ru_datetimes, handle_ru_attachments, handle_ru_geopoints, handle_ru_geotraces, and handle_ru_geoshapes parse dates, download and link file attachments, and extract coordinates from geofields. ruODK offers this manual and explicit pathway as an option to investigate and narrow down unexpected or unwanted behaviour.

Value

A list of lists.

  • value contains the submissions as list of lists.

  • @odata.context is the URL of the metadata.

  • @odata.count is the total number of rows in the table.

See Also

https://docs.getodk.org/central-api-odata-endpoints/#odata-form-service

https://docs.getodk.org/central-api-odata-endpoints/#data-document

Other odata-api: odata_metadata_get(), odata_service_get()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

form_tables <- ruODK::odata_service_get()
data <- odata_submission_get() # default: main data table
data <- odata_submission_get(table = form_tables$url[1]) # same, explicitly
data_sub1 <- odata_submission_get(table = form_tables$url[2]) # sub-table 1
data_sub2 <- odata_submission_get(table = form_tables$url[3]) # sub-table 2

# Skip one row, return the next 1 rows (top), include total row count
data <- odata_submission_get(
  table = form_tables$url[1],
  skip = 1,
  top = 1,
  count = TRUE
)

# Filter submissions
data <- odata_submission_get(
  table = form_tables$url[1],
  filter = "year(__system/submissionDate) lt year(now())"
)
data <- odata_submission_get(
  table = form_tables$url[1],
  filter = "year(__system/submissionDate) lt 2020"
)

# To include all of the month of January, you need to filter by either
# filter = "__system/submissionDate le 2020-01-31T23:59:59.999Z"
# or
# filter = "__system/submissionDate lt 2020-02-01".
# Instead of timezone UTC ("Z"), you can also filter by any other timezone.

## End(Not run)

Rectangle the output of odata_submission_get(parse=FALSE) into a tidy tibble and unnest all levels.

Description

[Stable]

Usage

odata_submission_rectangle(
  data,
  names_repair = "universal",
  names_sep = "_",
  form_schema = NULL,
  verbose = get_ru_verbose()
)

Arguments

data

A nested list of lists as given by odata_submission_get.

names_repair

The argument names_repair for tidyr::unnest_wider, default: "universal".

names_sep

The argument names_sep for tidyr::unnest_wider, default: "_". Un-nested variables inside a list column will be prefixed by the list column name, separated by names_sep. This avoids unsightly repaired names such as latitude...1.

form_schema

An optional form_schema, like the output of form_schema. If a form schema is supplied, location fields will not be unnested. While WKT location fields contain plain text and will never be unnested, GeoJSON location fields would cause errors during unnesting.

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

Details

This function cleans names with janitor::clean_names() and drops the prefix value_.

Value

The submissions as un-nested tibble

See Also

Other utilities: attachment_get(), attachment_link(), attachment_url(), drop_null_coords(), form_schema_parse(), get_one_attachment(), get_one_submission(), get_one_submission_att_list(), get_one_submission_audit(), handle_ru_attachments(), handle_ru_datetimes(), handle_ru_geopoints(), handle_ru_geoshapes(), handle_ru_geotraces(), isodt_to_local(), predict_ruodk_name(), prepend_uuid(), split_geopoint(), split_geoshape(), split_geotrace(), strip_uuid(), tidyeval, unnest_all()

Examples

## Not run: 
# Using canned data
data_parsed <- odata_submission_rectangle(fq_raw, verbose = TRUE)
# Field "device_id" is known part of fq_raw
testthat::expect_equal(
  data_parsed$device_id[[1]],
  fq_raw$value[[1]]$device_id
)

# fq_raw has two submissions
testthat::expect_equal(length(fq_raw$value), nrow(data_parsed))

## End(Not run)

Retrieve URL, project ID, and form ID from an ODK Central OData service URL.

Description

[Stable]

Usage

odata_svc_parse(svc)

Arguments

svc

(character) The OData service URL of a form as provided by the ODK Central form submissions tab. Example: "https://URL/v1/projects/PID/forms/FID.svc"

Value

A named list with three components (all of type character):

  • url The ODK Central base URL.

  • pid The project ID.

  • fid The form ID.

See Also

Other ru_settings: parse_odkc_version(), ru_settings(), ru_setup(), semver_gt(), semver_lt(), yell_if_error(), yell_if_missing()


Parse a given ODK Central version string or number into a semver.

Description

[Stable]

Usage

parse_odkc_version(v, env_var = "ODKC_VERSION")

Arguments

v

A string (e.g. "ODKC_VERSION=") or number (e.g. 0.8, 1.5) of a complete or partial semver, or a semver of class "svlist".

env_var

A string indicating which environment variable was targeted. This is used in the warning to advise which environment variable to update. If set to an empty string, the warning message is suppressed. Default: "ODKC_VERSION".

Details

Past versions of ruODK advised to set ODKC_VERSION to a floating point number indicating major and minor versions, e.g. ODKC_VERSION=0.7 or ODKC_VERSION=1.5.

ODK Central has since switched to semantic versioning, e.g. ⁠ODKC_VERSION=ODKC_VERSION=⁠.

To preserve backwards compatibility, ruODK handles both formats gracefully, but emits a helpful warning to update the version string if the older format is detected, or the version string is missing the minor or patch version.

Value

semver::svlist The version as semver of major, minor, and patch.

See Also

Other ru_settings: odata_svc_parse(), ru_settings(), ru_setup(), semver_gt(), semver_lt(), yell_if_error(), yell_if_missing()

Examples

parse_odkc_version("1.2.3")

# Warn: too short
parse_odkc_version("1")
parse_odkc_version("1.2")

# Warn: too long
parse_odkc_version("1.2.3.4")

# Warn: otherwise invalid
parse_odkc_version("1.2.")
parse_odkc_version(".2.3")

Create a new project.

Description

[Experimental]

Usage

project_create(
  name,
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw()
)

Arguments

name

The desired name of the project. Can contain whitespace.

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

Value

A tibble with one row per project and all project metadata as columns as per ODK Central API docs.

See Also

https://docs.getodk.org/central-api-project-management/#creating-a-project

Other project-management: project_detail(), project_list()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

p <- project_create("Test Project")
knitr::kable(p)

# project_create returns a tibble
class(p)
# > "tbl_df" "tbl" "data.frame"

# columns are project metadata
names(p)
# > "id" "name" "archived"

## End(Not run)

List all details of one project.

Description

While the API endpoint will return all details for one project, project_detail will fail with incorrect or missing authentication.

Usage

project_detail(
  pid = get_default_pid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Details

[Stable]

Value

A tibble with exactly one row for the project and all project metadata as columns as per ODK Central API docs. Column names are renamed from ODK's camelCase to snake_case. Values differ to values returned by ODK Central API:

  • archived: FALSE (if NULL) else TRUE

  • dates: NA if NULL

See Also

https://docs.getodk.org/central-api-project-management/#getting-project-details

Other project-management: project_create(), project_list()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

pd <- project_detail()

pd %>%
  dplyr::select(-"verbs") %>%
  knitr::kable(.)

## End(Not run)

List all projects.

Description

While the API endpoint will return all projects, project_list will fail with incorrect or missing authentication.

Usage

project_list(
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Details

[Stable]

Value

A tibble with one row per project and all project metadata as columns as per ODK Central API docs.

See Also

https://docs.getodk.org/central-api-project-management/#listing-projects

Other project-management: project_create(), project_detail()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

pl <- project_list()
knitr::kable(pl)

# project_list returns a tibble
class(pl)
# > "tbl_df" "tbl" "data.frame"

# columns are project metadata
names(pl)
# > "id" "name" "forms" "app_users" "created_at" "updated_at"
# > "last_submission" "archived"

## End(Not run)

rlang::abort() with a red error message with a cross symbol.

Description

[Stable]

Usage

ru_msg_abort(message)

Arguments

message

(chr) A message to print

See Also

Other messaging: ru_msg_info(), ru_msg_noop(), ru_msg_success(), ru_msg_warn()

Examples

## Not run: 
ru_msg_abort("This is an error, abort.")

## End(Not run)

Print a blue info message with an info symbol.

Description

[Stable]

Usage

ru_msg_info(message, verbose = get_ru_verbose())

Arguments

message

(chr) A message to print

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

See Also

Other messaging: ru_msg_abort(), ru_msg_noop(), ru_msg_success(), ru_msg_warn()

Examples

ru_msg_info("This is an info message.")

Print a green noop message with a filled circle symbol.

Description

[Stable]

Usage

ru_msg_noop(message, verbose = get_ru_verbose())

Arguments

message

(chr) A message to print

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

See Also

Other messaging: ru_msg_abort(), ru_msg_info(), ru_msg_success(), ru_msg_warn()

Examples

ru_msg_noop("This is a noop message.")

Print a green success message with a tick symbol.

Description

[Stable]

Usage

ru_msg_success(message, verbose = get_ru_verbose())

Arguments

message

(chr) A message to print

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

See Also

Other messaging: ru_msg_abort(), ru_msg_info(), ru_msg_noop(), ru_msg_warn()

Examples

ru_msg_success("This is a success message.")

rlang::warn() with a yellow warning message with a warning symbol.

Description

[Stable]

Usage

ru_msg_warn(message, verbose = get_ru_verbose())

Arguments

message

(chr) A message to print

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

See Also

Other messaging: ru_msg_abort(), ru_msg_info(), ru_msg_noop(), ru_msg_success()

Examples

## Not run: 
ru_msg_warn("This is a warning.")

## End(Not run)

Get or set ruODK settings.

Description

[Stable]

Usage

ru_settings()

get_default_pid()

get_default_fid()

get_default_url()

get_default_un()

get_default_pw()

get_default_pp()

get_default_tz()

get_default_orders()

get_test_url()

get_test_un()

get_test_pw()

get_test_pid()

get_test_fid()

get_test_fid_zip()

get_test_fid_att()

get_test_fid_gap()

get_test_fid_wkt()

get_test_pp()

get_ru_verbose()

get_default_odkc_version()

get_test_odkc_version()

get_retries()

Value

ru_settings prints your default ODK Central project ID, form ID, url, username, and password, corresponding optional test server as well as verbosity and HTTP request settings. ru_setup sets your production and test settings, while get_(default/test)_* get each of those respective settings.

See Also

ru_setup, get_default_pid, get_default_fid, get_default_url, get_default_un, get_default_pw, get_default_pp, get_default_tz, get_default_odkc_version, get_retries, get_test_pid, get_test_fid, get_test_fid_zip, get_test_fid_att, get_test_fid_gap, get_test_fid_wkt, get_test_url, get_test_un, get_test_pw, get_test_pp, get_test_odkc_version, get_ru_verbose.

Other ru_settings: odata_svc_parse(), parse_odkc_version(), ru_setup(), semver_gt(), semver_lt(), yell_if_error(), yell_if_missing()

Examples

ru_settings()

Configure default ruODK settings.

Description

Settings are returned invisibly and additionally printed depending on get_ru_verbose.

Usage

ru_setup(
  svc = NULL,
  pid = NULL,
  fid = NULL,
  url = NULL,
  un = NULL,
  pw = NULL,
  pp = NULL,
  tz = NULL,
  odkc_version = NULL,
  retries = NULL,
  verbose = NULL,
  test_svc = NULL,
  test_pid = NULL,
  test_fid = NULL,
  test_fid_zip = NULL,
  test_fid_att = NULL,
  test_fid_gap = NULL,
  test_fid_wkt = NULL,
  test_url = NULL,
  test_un = NULL,
  test_pw = NULL,
  test_pp = NULL,
  test_odkc_version = NULL
)

Arguments

svc

(optional, character) The OData service URL of a form. This parameter will set pid, fid, and url. It is sufficient to supply svc, un, and pw.

pid

(optional, character) The ID of an existing project on url. This will override the project ID from svc. A numeric value for pid will be converted to character.

fid

(optional, character) The alphanumeric ID of an existing form in pid. This will override the form ID from svc.

url

An ODK Central URL, e.g. "https://sandbox.central.getodk.org". This will override the ODK Central base URL from svc.

un

An ODK Central username which is the email of a "web user" in the specified ODK Central instance url (optional, character).

pw

The password for user un (optional, character).

pp

The passphrase (optional, character) for an encrypted form.

tz

Global default time zone. ruODK's time zone is determined in order of precedence:

  • Function parameter: e.g. odata_submission_get(tz = "Australia/Perth")

  • ruODK setting: ru_setup(tz = "Australia/Perth")

  • Environment variable RU_TIMEZONE (e.g. set in .Renviron)

  • UTC (GMT+00)

odkc_version

The ODK Central version as major/minor version, e.g. 1.1.

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

verbose

Global default for ruODK verbosity. ruODK verbosity is determined in order of precedence:

  • Function parameter: e.g. odata_submission_get(verbose = TRUE)

  • ruODK setting: ru_setup(verbose = TRUE)

  • Environment variable RU_VERBOSE (e.g. set in .Renviron)

  • FALSE.

test_svc

(optional, character) The OData service URL of a test form. This parameter will set test_pid, test_fid, and test_url. It is sufficient to supply test_svc, test_un, and test_pw to configure testing.

test_pid

(optional, character) The numeric ID of an existing project on test_url. This will override the project ID from test_svc. A numeric value for test_pid will be converted to character.

test_fid

(optional, character) The alphanumeric ID of an existing form in test_pid. This will override the form ID from test_svc. This form is used as default form in all tests, examples, vignettes, data, and Rmd templates.

test_fid_zip

(optional, character) The alphanumeric ID of an existing form in test_pid. This will override the form ID from test_svc. Provide the form ID of a form with few submissions and without attachments. This form is used to test the repeated download of all form submissions.

test_fid_att

(optional, character) The alphanumeric ID of an existing form in test_pid. This will override the form ID from test_svc. Provide the form ID of a form with few submissions and few attachments. This form is used to test downloading and linking attachments.

test_fid_gap

(optional, character) The alphanumeric ID of an existing form in test_pid. This will override the form ID from test_svc. Provide the form ID of a form with gaps in the first submission. This form is used to test parsing incomplete submissions.

test_fid_wkt

(optional, character) The alphanumeric ID of an existing form in test_pid. This will override the form ID from test_svc. Provide the form ID of a form with geopoints, geotraces, and geoshapes.

test_url

(optional, character) A valid ODK Central URL for testing. This will override the ODK Central base URL from svc.

test_un

(optional, character) A valid ODK Central username (email) privileged to view the test project(s) at test_url.

test_pw

(optional, character) The valid ODK Central password for test_un.

test_pp

(optional, character) The valid passphrase to decrypt the data of encrypted project test_pid for download, only used for tests.

test_odkc_version

The ODK Central test server's version as major/minor version, e.g. 1.1.

Details

[Stable]

ru_setup sets ODK Central connection details. ruODK's functions default to use the default project ID, form ID, URL, username, and password unless specified explicitly.

Any parameters not specified will remain unchanged. It is therefore possible to set up username and password initially with ru_setup(un="XXX", pw="XXX"), and switch between forms with ru_setup(svc="XXX"), supplying the form's OData service URL. ODK Central conveniently provides the OData service URL in the form submission tab, which in turn contains base URL, project ID, and form ID.

ruODK's automated tests require a valid ODK Central URL, and a privileged username and password of a "web user" on that ODK Central instance, as well as an existing project and form.

See Also

Other ru_settings: odata_svc_parse(), parse_odkc_version(), ru_settings(), semver_gt(), semver_lt(), yell_if_error(), yell_if_missing()

Examples

# `ruODK` users only need default settings to their ODK Central:
ru_setup(url = "https://my-odkc.com", un = "[email protected]", pw = "...")

# `ruODK` contributors and maintainers need specific ODK Central
# instances to run tests and build vignettes, see contributing guide:
ru_setup(
  url = "https://odkcentral.dbca.wa.gov.au",
  un = "[email protected]",
  pw = "...",
  pp = "...",
  test_url = "https://sandbox.central.getodk.org",
  test_un = "[email protected]",
  test_pw = "...",
  test_pp = "...",
  test_pid = 14,
  test_fid = "build_Flora-Quadrat-0-2_1558575936",
  test_fid_zip = "build_Spotlighting-0-6_1558333698",
  test_fid_att = "build_Flora-Quadrat-0-1_1558330379",
  test_fid_gap = "build_Turtle-Track-or-Nest-1-0_1569907666",
  test_fid_wkt = "build_Locations_1589344221",
  retries = 3,
  verbose = TRUE
)

Show whether a given semver is greater than a baseline version.

Description

Show whether a given semver is greater than a baseline version.

Usage

semver_gt(sv = get_default_odkc_version(), to = "1.5.0")

Arguments

sv

The semver to compare as character ("2023.5.1", "1.5.0", "1.5"), or numeric (1.5). The value is always parsed with semver::parse_semver(). Default: get_default_odkc_version().

to

The semver to compare to as string. Although semver can parse complete version strings, to is still parsed by parse_odkc_version() to ensure it is complete with major, minor, and patch version components.

Value

A boolean indicating whether the given semver sv is greater than the baseline semver to.

See Also

Other ru_settings: odata_svc_parse(), parse_odkc_version(), ru_settings(), ru_setup(), semver_lt(), yell_if_error(), yell_if_missing()

Examples

get_default_odkc_version() |> semver_gt("0.8.0")
"2024.1.1" |> semver_gt("2024.1.0")
"2024.1.1" |> semver_gt("2024.1.1")
"2024.1.1" |> semver_gt("2024.1.2")

Show whether a given semver is lesser than a baseline version.

Description

Show whether a given semver is lesser than a baseline version.

Usage

semver_lt(sv = get_default_odkc_version(), to = "1.5.0")

Arguments

sv

The semver to compare as character ("2023.5.1", "1.5.0", "1.5"), or numeric (1.5). The value is always parsed with semver::parse_semver(). Default: get_default_odkc_version().

to

The semver to compare to as string. Although semver can parse complete version strings, to is still parsed by parse_odkc_version() to ensure it is complete with major, minor, and patch version components.

Value

A boolean indicating whether the given semver sv is greater than the baseline semver to.

See Also

Other ru_settings: odata_svc_parse(), parse_odkc_version(), ru_settings(), ru_setup(), semver_gt(), yell_if_error(), yell_if_missing()

Examples

get_default_odkc_version() |> semver_lt("0.8.0")
"2024.1.1" |> semver_lt("2024.1.0")
"2024.1.1" |> semver_lt("2024.1.1")
"2024.1.1" |> semver_lt("2024.1.2")

Annotate a dataframe containing a geopoint column with lon, lat, alt.

Description

[Stable]

Usage

split_geopoint(data, colname, wkt = FALSE)

Arguments

data

(dataframe) A dataframe with a geopoint column.

colname

(chr) The name of the geopoint column. This column will be retained.

wkt

Whether geofields are GeoJSON (if FALSE) or WKT strings (if TRUE), default: FALSE.

Details

This function is used by handle_ru_geopoints on all geopoint fields as per form_schema.

Value

The given dataframe with the WKT POINT column colname, plus three new columns, colname_longitude, colname_latitude, colname_altitude. The three new columns are prefixed with the original colname to avoid naming conflicts with any other geopoint columns.

See Also

Other utilities: attachment_get(), attachment_link(), attachment_url(), drop_null_coords(), form_schema_parse(), get_one_attachment(), get_one_submission(), get_one_submission_att_list(), get_one_submission_audit(), handle_ru_attachments(), handle_ru_datetimes(), handle_ru_geopoints(), handle_ru_geoshapes(), handle_ru_geotraces(), isodt_to_local(), odata_submission_rectangle(), predict_ruodk_name(), prepend_uuid(), split_geoshape(), split_geotrace(), strip_uuid(), tidyeval, unnest_all()

Examples

## Not run: 
df_wkt <- tibble::tibble(
  stuff = c("asd", "sdf", "sdf"),
  loc = c(
    "POINT (115.99 -32.12 20.01)",
    "POINT (116.12 -33.34 15.23)",
    "POINT (114.01 -31.56 23.56)"
  )
)
df_wkt_split <- df |> split_geopoint("loc", wkt = TRUE)
testthat::expect_equal(
  names(df_wkt_split),
  c("stuff", "loc", "loc_longitude", "loc_latitude", "loc_altitude")
)

# With package data
data("geo_fs")
data("geo_wkt_raw")
data("geo_gj_raw")

# Find variable names of geopoints
geo_fields <- geo_fs |>
  dplyr::filter(type == "geopoint") |>
  magrittr::extract2("ruodk_name")
geo_fields[1] # First geotrace in data: point_location_point_gps

# Rectangle but don't parse submission data (GeoJSON and WKT)
geo_gj_rt <- geo_gj_raw |>
  odata_submission_rectangle(form_schema = geo_fs)
geo_wkt_rt <- geo_wkt_raw |>
  odata_submission_rectangle(form_schema = geo_fs)

# Data with first geopoint split
gj_first_gt <- split_geopoint(geo_gj_rt, geo_fields[1], wkt = FALSE)
gj_first_gt$point_location_point_gps_longitude

wkt_first_gt <- split_geopoint(geo_wkt_rt, geo_fields[1], wkt = TRUE)
wkt_first_gt$point_location_point_gps_longitude

## End(Not run)

Annotate a dataframe containing a geoshape column with lon, lat, alt of the geotrace's first point.

Description

[Stable]

Usage

split_geoshape(
  data,
  colname,
  wkt = FALSE,
  odkc_version = get_default_odkc_version()
)

Arguments

data

(dataframe) A dataframe with a geoshape column.

colname

(chr) The name of the geoshape column. This column will be retained.

wkt

Whether geofields are GeoJSON (if FALSE) or WKT strings (if TRUE), default: FALSE.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

Details

This function is used by handle_ru_geopoints on all geopoint fields as per form_schema.

Value

The given dataframe with the geoshape column colname, plus three new columns, colname_longitude, colname_latitude, colname_altitude. The three new columns are prefixed with the original colname to avoid naming conflicts with any other geoshape columns.

See Also

Other utilities: attachment_get(), attachment_link(), attachment_url(), drop_null_coords(), form_schema_parse(), get_one_attachment(), get_one_submission(), get_one_submission_att_list(), get_one_submission_audit(), handle_ru_attachments(), handle_ru_datetimes(), handle_ru_geopoints(), handle_ru_geoshapes(), handle_ru_geotraces(), isodt_to_local(), odata_submission_rectangle(), predict_ruodk_name(), prepend_uuid(), split_geopoint(), split_geotrace(), strip_uuid(), tidyeval, unnest_all()

Examples

## Not run: 
library(magrittr)
data("geo_fs")
data("geo_wkt_raw")
data("geo_gj_raw")

# Find variable names of geoshapes
geo_fields <- geo_fs %>%
  dplyr::filter(type == "geoshape") %>%
  magrittr::extract2("ruodk_name")
geo_fields[1] # First geoshape in data: shape_location_shape_gps

# Rectangle but don't parse submission data (GeoJSON and WKT)
geo_gj_rt <- geo_gj_raw %>%
  odata_submission_rectangle(form_schema = geo_fs)
geo_wkt_rt <- geo_wkt_raw %>%
  odata_submission_rectangle(form_schema = geo_fs)

# Data with first geoshape split
gj_first_gt <- split_geoshape(geo_gj_rt, geo_fields[1], wkt = FALSE)
cn_gj <- names(gj_first_gt)
testthat::expect_true("shape_location_shape_gps_longitude" %in% cn_gj)
testthat::expect_true("shape_location_shape_gps_latitude" %in% cn_gj)
testthat::expect_true("shape_location_shape_gps_altitude" %in% cn_gj)
testthat::expect_true(
  is.numeric(gj_first_gt$shape_location_shape_gps_longitude)
)
testthat::expect_true(
  is.numeric(gj_first_gt$shape_location_shape_gps_latitude)
)
testthat::expect_true(
  is.numeric(gj_first_gt$shape_location_shape_gps_altitude)
)

wkt_first_gt <- split_geoshape(geo_wkt_rt, geo_fields[1], wkt = TRUE)
cn_wkt <- names(wkt_first_gt)
testthat::expect_true("shape_location_shape_gps_longitude" %in% cn_wkt)
testthat::expect_true("shape_location_shape_gps_latitude" %in% cn_wkt)
testthat::expect_true("shape_location_shape_gps_altitude" %in% cn_wkt)
testthat::expect_true(
  is.numeric(wkt_first_gt$shape_location_shape_gps_longitude)
)
testthat::expect_true(
  is.numeric(wkt_first_gt$shape_location_shape_gps_latitude)
)
testthat::expect_true(
  is.numeric(wkt_first_gt$shape_location_shape_gps_altitude)
)

## End(Not run)

Annotate a dataframe containing a geotrace column with lon, lat, alt of the geotrace's first point.

Description

[Stable]

Usage

split_geotrace(
  data,
  colname,
  wkt = FALSE,
  odkc_version = get_default_odkc_version()
)

Arguments

data

(dataframe) A dataframe with a geotrace column.

colname

(chr) The name of the geotrace column. This column will be retained.

wkt

Whether geofields are GeoJSON (if FALSE) or WKT strings (if TRUE), default: FALSE.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

Details

This function is used by handle_ru_geopoints on all geopoint fields as per form_schema.

The format of the geotrace (GeoJSON, WKT, ODK Linestring) is determined via parameters wkt and odkc_version, rather than inferred from the class of the column. ODK Linestrings are character vectors without a leading "LINESTRING (", WKT are character vectors with a leading "LINESTRING (", and GeoJSON are list columns.

Value

The given dataframe with the geotrace column colname, plus three new columns, colname_longitude, colname_latitude, colname_altitude. The three new columns are prefixed with the original colname to avoid naming conflicts with any other geotrace columns.

See Also

Other utilities: attachment_get(), attachment_link(), attachment_url(), drop_null_coords(), form_schema_parse(), get_one_attachment(), get_one_submission(), get_one_submission_att_list(), get_one_submission_audit(), handle_ru_attachments(), handle_ru_datetimes(), handle_ru_geopoints(), handle_ru_geoshapes(), handle_ru_geotraces(), isodt_to_local(), odata_submission_rectangle(), predict_ruodk_name(), prepend_uuid(), split_geopoint(), split_geoshape(), strip_uuid(), tidyeval, unnest_all()

Examples

## Not run: 
library(magrittr)
data("geo_fs")
data("geo_wkt_raw")
data("geo_gj_raw")

# Find variable names of geotraces
geo_fields <- geo_fs %>%
  dplyr::filter(type == "geotrace") %>%
  magrittr::extract2("ruodk_name")
geo_fields[1] # First geotrace in data: path_location_path_gps

# Rectangle but don't parse submission data (GeoJSON and WKT)
geo_gj_rt <- geo_gj_raw %>%
  odata_submission_rectangle(form_schema = geo_fs)
geo_wkt_rt <- geo_wkt_raw %>%
  odata_submission_rectangle(form_schema = geo_fs)

# Data with first geotrace split
gj_first_gt <- split_geotrace(geo_gj_rt, geo_fields[1], wkt = FALSE)
testthat::expect_true(
  "path_location_path_gps_longitude" %in% names(gj_first_gt)
)
testthat::expect_true(
  "path_location_path_gps_latitude" %in% names(gj_first_gt)
)
testthat::expect_true(
  "path_location_path_gps_altitude" %in% names(gj_first_gt)
)
testthat::expect_true(
  is.numeric(gj_first_gt$path_location_path_gps_longitude)
)
testthat::expect_true(
  is.numeric(gj_first_gt$path_location_path_gps_latitude)
)
testthat::expect_true(
  is.numeric(gj_first_gt$path_location_path_gps_altitude)
)

wkt_first_gt <- split_geotrace(geo_wkt_rt, geo_fields[1], wkt = TRUE)
testthat::expect_true(
  "path_location_path_gps_longitude" %in% names(wkt_first_gt)
)
testthat::expect_true(
  "path_location_path_gps_latitude" %in% names(wkt_first_gt)
)
testthat::expect_true(
  "path_location_path_gps_altitude" %in% names(wkt_first_gt)
)
testthat::expect_true(
  is.numeric(wkt_first_gt$path_location_path_gps_longitude)
)
testthat::expect_true(
  is.numeric(wkt_first_gt$path_location_path_gps_latitude)
)
testthat::expect_true(
  is.numeric(wkt_first_gt$path_location_path_gps_altitude)
)

## End(Not run)

Get submission audits for a list of submission instance IDs.

Description

[Experimental]

Usage

submission_audit_get(
  iid,
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries()
)

Arguments

iid

A list of submission instance IDs, e.g. from submission_list$instance_id.

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Details

Uses get_one_submission_audit on a list of submission instance IDs (iid) as returned from submission_list$instance_id. By giving the list of iid to download explicitly, that list can be modified using information not accessible to ruODK, e.g. iid can be restricted to "only not already downloaded submissions".

To get the combined submission audit logs for one form as one single, concatenated audit.csv file, use submission_export.

Value

A nested list of submission audit logs.

See Also

https://docs.getodk.org/central-api-submission-management/#retrieving-submission-xml

Other submission-management: attachment_list(), encryption_key_list(), submission_detail(), submission_export(), submission_get(), submission_list()

Examples

## Not run: 
# Step 1: Setup ruODK with OData Service URL (has url, pid, fid)
ruODK::ru_setup(svc = "...")

# Step 2: List all submissions of form
sl <- submission_list()

# Step 3: Get submission audit logs
sa <- submission_audit_get(sl$instance_id)

## End(Not run)

Show metadata for one submission.

Description

[Stable]

Usage

submission_detail(
  iid,
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries()
)

Arguments

iid

The instance_id, a UUID, as returned by submission_list.

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Value

A nested list of submission metadata.

See Also

https://docs.getodk.org/central-api-submission-management/#getting-submission-metadata

Other submission-management: attachment_list(), encryption_key_list(), submission_audit_get(), submission_export(), submission_get(), submission_list()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

sl <- submission_list()

sub <- submission_detail(sl$instance_id[[1]])

# The details for one submission return exactly one row
nrow(sub)
# > 1

# The columns are metadata about the submission and the submitter
names(sub)
# > "instance_id" "submitter_id" "submitter_type" "submitter_display_name"
# > "submitter_created_at" "device_id" "created_at"

## End(Not run)

Export all form submissions including repeats and attachments to CSV.

Description

[Maturing]

Usage

submission_export(
  local_dir = here::here(),
  overwrite = TRUE,
  media = TRUE,
  repeats = TRUE,
  deleted_fields = FALSE,
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  pp = get_default_pp(),
  retries = get_retries(),
  odkc_version = get_default_odkc_version(),
  verbose = get_ru_verbose()
)

Arguments

local_dir

The local folder to save the downloaded files to, default: here::here.

overwrite

Whether to overwrite previously downloaded zip files, default: FALSE

media

Whether to include media attachments, default: TRUE. This feature only has effect on ODK Central v1.1 and higher. Setting this feature to FALSE with an odkc_version < 1.1 and will display a verbose noop message, but still return all media attachments.

repeats

Whether to include repeat data (if TRUE), or whether to return the root table only (FALSE). Default: TRUE. Requesting repeats=FALSE will also omit any media, and override the parameter media. Setting this feature to FALSE with an odkc_version < 1.1 and will display a verbose noop message, but still include all repeat data.

deleted_fields

Whether to restore all fields previously deleted from this form for this export (TRUE). All known fields and data for those fields will be merged and exported. default: FALSE

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

pp

The passphrase for an encrypted form.

Default: NULL.

Passphrases can be stored e.g. as environment variables.

See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

odkc_version

The ODK Central version as a semantic version string (year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's version page ⁠/version.txt⁠. Discard the "v". ruODK uses this parameter to adjust for breaking changes in ODK Central.

Default: get_default_odkc_version or "2023.5.1" if unset.

Set default get_default_odkc_version through ru_setup(odkc_version="2023.5.1").

See vignette("Setup", package = "ruODK").

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

Details

This function exports all the Submission data associated with a Form as one zip file containing one or more CSV files, as well as all multimedia attachments associated with the included Submissions.

For an incremental download of a subset of submissions, use submission_list or odata_submission_get with filter queries.

Contents

The inclusion of subtables (from repeating form groups) can be toggled through repeats, whereas the inclusion of media attachments can be toggled through media.

Download location

The file will be downloaded to the project root unless specified otherwise (via local_dir). Subsequently, the zip file can be extracted. Attachment filenames (e.g. "12345.jpg") should be prepended with media (resulting in e.g. ⁠media/12345.jpg⁠) in order to represent the relative path to the actual attachment file (as extracted from the zip file).

Encryption

ODK Central supports two modes of encryption - learn about them here. ruODK supports project managed encryption, however the support is limited to exactly one encryption key. The supplied passphrase will be used against the first returned encryption key. Remaining encryption keys are ignored by ruODK.

If an incorrect passphrase is given, the request is terminated immediately. It has been reported that multiple requests with incorrect passphrases can crash ODK Central.

Value

The absolute path to the exported ZIP file named after the form ID. The exported ZIP file will have the extension .zip unless only the root table was requested (with repeats=FALSE), in which case the exported file will have the extension .csv. In contrast to ODK Central, which exports to submissions.csv(.zip), the exported ZIP file is named after the form to avoid accidentally overwriting the ZIP export from another form.

See Also

https://docs.getodk.org/central-api-submission-management/#exporting-form-submissions-to-csv

Other submission-management: attachment_list(), encryption_key_list(), submission_audit_get(), submission_detail(), submission_get(), submission_list()

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

se <- submission_export()

# Unzip and inspect the loot
t <- tempdir()
f <- unzip(se, exdir = t)
fs::dir_ls(t)
fid <- get_test_fid()
sub <- fs::path(t, glue::glue("{fid}.csv")) %>% readr::read_csv()
sub %>% knitr::kable(.)

## End(Not run)

Get submissions for a list of submission instance IDs.

Description

Uses get_one_submission on a list of submission instance IDs (iid) as returned from submission_list$instance_id. By giving the list of iid to download explicitly, that list can be modified using information not accessible to ruODK, e.g. iid can be restricted to "only not already downloaded submissions".

Usage

submission_get(
  iid,
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries()
)

Arguments

iid

A list of submission instance IDs, e.g. from submission_list$instance_id.

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Details

Forms with submission audit enabled will also receive the submission audit as audit.csv. This will overwrite all previous audit.csv files. To get the combined submission audit logs as one single, concatenated audit.csv file, use submission_export. Note that the submission audit is different from the server audit. The submission audit logs the actions of the enumerator in ODK Collect, whereas the form audit logs the actions of the project manager in ODK Central.

Value

A nested list of submission data.

See Also

https://docs.getodk.org/central-api-submission-management/#retrieving-submission-xml

Other submission-management: attachment_list(), encryption_key_list(), submission_audit_get(), submission_detail(), submission_export(), submission_list()

Examples

## Not run: 
# Step 1: Setup ruODK with OData Service URL (has url, pid, fid)
ruODK::ru_setup(svc = "...")

# Step 2: List all submissions of form
sl <- submission_list()

# Step 3: Get submissions
subs <- submission_get(sl$instance_id)

## End(Not run)

List all submissions of one form.

Description

[Stable]

Usage

submission_list(
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  orders = get_default_orders(),
  tz = get_default_tz()
)

Arguments

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

Value

A tibble containing some high-level details of the form submissions. One row per submission, columns are submission attributes:

    * instance_id: uuid, string. The unique ID for each submission.
    * submitter_id: user ID, integer.
    * created_at: time of submission upload, dttm
    * updated_at: time of submission update on server, dttm or NA

See Also

https://docs.getodk.org/central-api-submission-management/#listing-all-submissions-on-a-form

Other submission-management: attachment_list(), encryption_key_list(), submission_audit_get(), submission_detail(), submission_export(), submission_get()

Examples

## Not run: 
# Set default credentials, see vignette("setup")
ruODK::ru_setup(
  svc = ...,
  un = "[email protected]",
  pw = "..."
)

sl <- submission_list()
sl %>% knitr::kable(.)

fl <- form_list()

# submission_list returns a tibble
class(sl)
# > c("tbl_df", "tbl", "data.frame")

# Submission attributes are the tibble's columns
names(sl)
# > "instance_id" "submitter_id" "device_id" "created_at" "updated_at"

# Number of submissions (rows) is same as advertised in form_list
form_list_nsub <- fl %>%
  filter(fid == get_test_fid()) %>%
  magrittr::extract2("submissions") %>%
  as.numeric()
nrow(sl) == form_list_nsub
# > TRUE

## End(Not run)

List all users.

Description

[Maturing]

Usage

user_list(
  qry = NULL,
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries(),
  orders = get_default_orders(),
  tz = get_default_tz(),
  verbose = get_ru_verbose()
)

Arguments

qry

A query string to filter users by. The query string is not case sensitive and can contain special characters, such as @.

The query string must be at least 5 alphabetic characters long to return good enough matches. E.g. janet will match a user with display name ⁠Janette Doe⁠. E.g., ⁠@dbca.wa⁠ will match users with an email from dbca.wa.gov.au, whereas ⁠@dbca.w⁠ or ⁠@dbca⁠ will return no matches.

Default: NULL.

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

orders

(vector of character) Orders of datetime elements for lubridate.

Default: c("YmdHMS", "YmdHMSz", "Ymd HMS", "Ymd HMSz", "Ymd", "ymd").

tz

A timezone to convert dates and times to.

Read vignette("setup", package = "ruODK") to learn how ruODK's timezone can be set globally or per function.

verbose

Whether to display debug messages or not.

Read vignette("setup", package = "ruODK") to learn how ruODK's verbosity can be set globally or per function.

Details

Currently, there are no paging or filtering options, so listing Users will get you every User in the system, every time. Optionally, a q query string parameter may be provided to filter the returned users by any given string. The search is performed via a trigram similarity index over both the Email and Display Name fields, and results are ordered by match score, best matches first. If a q parameter is given, and it exactly matches an email address that exists in the system, that user's details will always be returned, even for actors who cannot user.list. The request must still authenticate as a valid Actor. This allows non-Administrators to choose a user for an action (e.g. grant rights) without allowing full search.

Actors who cannot user.list will always receive [] with a 200 OK response. ruODK does not (yet) warn if this is the case, and you (the requesting Actor) have no permission to user.list.

Value

A tibble with user details as per the ODK Central API docs.

See Also

https://docs.getodk.org/central-api-accounts-and-users/#listing-all-users

https://www.postgresql.org/docs/9.6/pgtrgm.html

Examples

## Not run: 
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...")

# All users
ul <- user_list()

# Search users
# Given a user with display name "Janette Doe" and email "@org.com.au"
user_list(qry = "jan") # no results, query string too short
user_list(qry = "jane") # no results, query string too short
user_list(qry = "janet") # returns Janette
user_list(qry = "@org") # no results, query string too short
user_list(qry = "@org.c") # no results, query string too short
user_list(qry = "@org.co") # returns all users matching "@org.co"

# Actor not allowed to user.list
user_list() # If this is empty, you might not have permissions to list users

## End(Not run)