These functions are primarily intended to assist with testing
features of redcapAPI
. Purging and restoring project data permits
us to perform tests on different project structures without having to
manage multiple projects or API tokens.
When purging project data, many of these actions may only be performed with a project in development status, as they are potentially destructive and may result in data loss. It is a good practice to back up your data and project structure before purging a project.
preserveProject(object, ...)# S3 method for redcapApiConnection
preserveProject(
object,
...,
error_handling = getOption("redcap_error_handling"),
config = list()
)
purgeProject(object, ...)
# S3 method for redcapApiConnection
purgeProject(
object,
arms = FALSE,
events = FALSE,
users = FALSE,
user_roles = FALSE,
dags = FALSE,
records = FALSE,
purge_all = FALSE,
flush = TRUE,
...,
error_handling = getOption("redcap_error_handling"),
config = list()
)
restoreProject(object, ...)
# S3 method for redcapApiConnection
restoreProject(
object,
project_information = NULL,
arms = NULL,
events = NULL,
meta_data = NULL,
mappings = NULL,
repeating_instruments = NULL,
users = NULL,
user_roles = NULL,
user_role_assignments = NULL,
dags = NULL,
dag_assignments = NULL,
records = NULL,
flush = TRUE,
...,
error_handling = getOption("redcap_error_handling"),
config = list()
)
# S3 method for list
restoreProject(
object,
rcon,
...,
error_handling = getOption("redcap_error_handling"),
config = list()
)
A redcapConnection
object. Except in
restoreProject.list
, where object
is a list of data frames
to use in restoring the project.
Arguments to pass to other methods.
An option for how to handle errors returned by the API.
see redcap_error
list
Additional configuration parameters to pass to
POST
. These are appended to any parameters in
rcon$config
.
Either logical(1)
indicating if arms data should be
purged from the project; or a data.frame
for restoring arms
data via importArms
.
Either logical(1)
indicating if events data should be
purged from the project; or a data.frame
for restoring events
data via importEvents
Either logical(1)
indicating if users data should be
purged from the project; or a data.frame
for restoring users
data via importUsers
. NOT YET IMPLEMENTED
Either logical(1)
indicating if user roles data should be
purged from the project; or a data.frame
for restoring user roles
data via importUserRoles
. NOT YET IMPLEMENTED
Either logical(1)
indicating if DAG data should be
purged from the project; or a data.frame
for restoring DAGs
data via importDags
. NOT YET IMPLEMENTED
Either logical(1)
indicating if user roles data should be
purged from the project; or a data.frame
for restoring user roles
data via importRecords
logical(1)
. A shortcut option to purge all
data elements from a project.
logical(1)
. If TRUE
, the all caches in the connection
object will be flushed after completing the operation. This is highly
recommended.
data.frame
for restoring data. Provides the
project settings to load via importProjectInformation
.
A data.frame
for restoring metadata
data via importMetaData
. The API doesn't support deleting
metadata, but an import replaces the existing metadata.
A data.frame
for restoring instrument-event mappings
via importMappings
. The API doesn't support deleting
mappings, but an import replaces the existing mappings.
A data.frame
for restoring repeating instruments
configuration via importRepeatingInstrumentsEvents
. The API doesn't support deleting
repeating instruments, but an import replaces the existing instruments.
NOT YET IMPLEMENTED
A data.frame
for restoring user role
assignments via importUserRoleAssignments
. The API doesn't support deleting
assignments, but an import replaces the existing assignments. NOT YET IMPLEMENTED.
A data.frame
for restoring DAG
assignments via importDagAssignments
. The API doesn't support deleting
assignments, but an import replaces the existing assignments. NOT YET IMPLEMENTED.
When restoring a project, all arguments are optional. Any argument
that is NULL
will result in no import being made. The order of
reconstructing the project is (purging data occurs in the reverse order):
1. Update project information
2. Import Arms Data
3. Import Events Data
4. Import Meta Data
5. Import Mappings
6. Import Repeating Instruments
7. Import Users
8. Import User Roles
9. Import User Role Assignments
10. Import Data Access Groups
11. Import Data Access Group Assignments
12. Import Records