Learn R Programming

datapack (version 1.0.0)

serializeToBagIt: Serialize A DataPackage into a BagIt Archive File

Description

The BagIt packaging format https://tools.ietf.org/html/draft-kunze-bagit-08 is used to prepare an archive file that contains the contents of a DataPackage.

Usage

serializeToBagIt(x, ...)
"serializeToBagIt"(x, mapId = as.character(NA), syntaxName = as.character(NA), namespaces = data.frame(), mimeType = as.character(NA), syntaxURI = as.character(NA), resolveURI = as.character(NA), ...)

Arguments

x
A DataPackage object
...
Additional arguments
mapId
A unique identifier for the package resource map. If not specified, one will be automatically generated.
syntaxName
The name of the syntax to use for the resource map serialization, defaults to "rdfxml"
namespaces
An optional data frame containing one or more namespaces and their associated prefix for the resource map serialization.
mimeType
The mimetype for the resource map serialization, defaults to "application/rdf+xml".
syntaxURI
An optional string specifying the URI for the resource map serialization.
resolveURI
A character string containing a URI to prepend to datapackage identifiersa for the resource map.

Value

The file name that contains the BagIt zip archive.

Details

A BagIt Archive File is created by copying each member of a DataPackge, and preparing files that describe the files in the archive, including information about the size of the files and a checksum for each file. An OAI-ORE resource map is automatically created and added to the archive. These metadata files and the data files are then packaged into a single zip file.

See Also

DataPackage-class

For more information and examples regarding the parameters specifying the creation of the resource map, see serializePackage.

Examples

Run this code
# Create the first data object
dp <- new("DataPackage")
data <- charToRaw("1,2,3\n4,5,6")
do <- new("DataObject", id="do1", dataobj=data, format="text/csv", user="jsmith")
dp <- addData(dp, do)
# Create a second data object
data2 <- charToRaw("7,8,9\n4,10,11")
do2 <- new("DataObject", id="do2", dataobj=data2, format="text/csv", user="jsmith")
dp <- addData(dp, do2)
# Create a relationship between the two data objects
recordDerivation(dp, "do2", "do2")
# Write out the data package to a BagIt file
bagitFile <- serializeToBagIt(dp, syntaxName="json", mimeType="application/json")

Run the code above in your browser using DataLab