├── .github ├── .gitignore └── workflows │ ├── R-CMD-check.yaml │ └── rhub.yaml ├── tests ├── testthat.R └── testthat │ ├── test.ResourceMap.R │ └── test_DataObject.R ├── vignettes ├── package-diagram.png └── package-diagram-with-prov.png ├── .Rbuildignore ├── .gitignore ├── inst ├── extdata │ ├── pkg-example │ │ ├── binary.csv.zip │ │ ├── gre-predicted.png │ │ ├── logit-regression-example.R │ │ └── binary.csv │ ├── filter-species.R │ ├── sample-data-filtered.csv │ ├── sample-eml.xml │ ├── resourceMap-sample.xml │ └── sample-data.csv ├── CITATION ├── COPYRIGHTS ├── testfiles │ ├── sysmeta-v2-repfalse-zero-reps.xml │ ├── sysmeta.xml │ ├── sysmeta-updated.xml │ ├── sysmeta-v2.xml │ └── sysmeta-v2-repfalse.xml └── WORDLIST ├── datapack.Rproj ├── man ├── dmsg.Rd ├── freeResourceMap.Rd ├── datapack-deprecated.Rd ├── plotRelationships.Rd ├── ResourceMap-initialize.Rd ├── getFormatId.Rd ├── getIdentifier.Rd ├── getSize.Rd ├── calculateChecksum.Rd ├── getIdentifiers.Rd ├── DataPackage-initialize.Rd ├── getMember.Rd ├── validate.Rd ├── containsId.Rd ├── updateRelationships.Rd ├── SystemMetadata.Rd ├── parseSystemMetadata.Rd ├── getRelationships.Rd ├── getData.Rd ├── removeMember.Rd ├── getTriples.Rd ├── getValue.Rd ├── serializeSystemMetadata.Rd ├── parseRDF.Rd ├── canRead.Rd ├── updateXML.Rd ├── recordDerivation.Rd ├── serializeRDF.Rd ├── setPublicAccess.Rd ├── addData.Rd ├── ResourceMap-class.Rd ├── addMember.Rd ├── updateMetadata.Rd ├── clearAccessPolicy.Rd ├── selectMember.Rd ├── setValue.Rd ├── createFromTriples.Rd ├── removeRelationships.Rd ├── replaceMember.Rd ├── serializePackage.Rd ├── datapack.Rd ├── serializeToBagIt.Rd ├── DataObject-initialize.Rd ├── addAccessRule.Rd ├── insertRelationship.Rd ├── hasAccessRule.Rd ├── describeWorkflow.Rd ├── DataObject-class.Rd ├── SystemMetadata-initialize.Rd ├── SystemMetadata-class.Rd ├── DataPackage-class.Rd └── removeAccessRule.Rd ├── R ├── zzz.R ├── dmsg.R ├── datapack-package.r └── Constants.R ├── cran-comments.md ├── DESCRIPTION ├── NAMESPACE ├── NEWS.md └── README.md /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(datapack) 3 | 4 | test_check("datapack") 5 | -------------------------------------------------------------------------------- /vignettes/package-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci/datapack/HEAD/vignettes/package-diagram.png -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^\.travis\.yml$ 2 | ^.*\.Rproj$ 3 | ^\.Rproj\.user$ 4 | cran-comments.md 5 | .gitignore 6 | ^\.github$ 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .DS_Store 5 | inst/.DS_Store 6 | inst/extdata/.DS_Store 7 | datapackage.Rproj 8 | -------------------------------------------------------------------------------- /inst/extdata/pkg-example/binary.csv.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci/datapack/HEAD/inst/extdata/pkg-example/binary.csv.zip -------------------------------------------------------------------------------- /vignettes/package-diagram-with-prov.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci/datapack/HEAD/vignettes/package-diagram-with-prov.png -------------------------------------------------------------------------------- /inst/extdata/pkg-example/gre-predicted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropensci/datapack/HEAD/inst/extdata/pkg-example/gre-predicted.png -------------------------------------------------------------------------------- /inst/extdata/filter-species.R: -------------------------------------------------------------------------------- 1 | # Simple program that reads in a dataset, modifies it and writes it out. 2 | specInfo <- read.csv("sample-data.csv") 3 | specFiltered <- subset(data, nutr >= "5") 4 | outFile <- tempfile(fileext=".csv") 5 | write.csv(specFiltered, file=outFile, row.names=FALSE) 6 | 7 | -------------------------------------------------------------------------------- /datapack.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 4 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Package 16 | PackageUseDevtools: Yes 17 | PackageInstallArgs: --no-multiarch --with-keep.source 18 | PackageRoxygenize: rd,collate,namespace,vignette 19 | -------------------------------------------------------------------------------- /man/dmsg.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/dmsg.R 3 | \name{dmsg} 4 | \alias{dmsg} 5 | \title{Print a debugging message to stderr} 6 | \usage{ 7 | dmsg(msg) 8 | } 9 | \arguments{ 10 | \item{msg}{the message to be printed} 11 | } 12 | \description{ 13 | Print a debugging message to stderr 14 | } 15 | \details{ 16 | Only print the message if the option "datapack.debugging_mode" is TRUE. 17 | } 18 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | #' @title Deprecated Methods 2 | #' @description The following items are deprecated in this release of datapack and will be 3 | #' marked as Defunct and removed in a future version. 4 | #' @name datapack-deprecated 5 | #' @keywords internal 6 | #' 7 | #' @section These methods are deprecated: 8 | #' \describe{ 9 | #' \item{\code{\link{recordDerivation}}}{: Record derivation relationships between objects in a DataPackage.} 10 | #' \item{\code{\link{addData}}}{: Add a DataObject to the DataPackage.} 11 | #' } 12 | #' 13 | NULL -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | year <- sub("-.*", "", meta$Date) 2 | note <- sprintf("R package version %s", meta$Version) 3 | title <- meta$Title 4 | authors <- c( 5 | person("Matthew B.", "Jones", email="jones@nceas.ucsb.edu", role=c("aut", "cre")), 6 | person("Peter", "Slaughter", role = "aut", email = "slaughter@nceas.ucsb.edu")) 7 | bibentry(bibtype = "Manual", 8 | title = paste0("{datapack}: ", title), 9 | author = authors, 10 | year = year, 11 | note = note, 12 | url = "https://github.com/ropensci/datapack", 13 | doi = "10.5063/F1QV3JGM") 14 | -------------------------------------------------------------------------------- /man/freeResourceMap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ResourceMap.R 3 | \name{freeResourceMap} 4 | \alias{freeResourceMap} 5 | \alias{freeResourceMap,ResourceMap-method} 6 | \title{Free memory used by a ResouceMap} 7 | \usage{ 8 | freeResourceMap(x) 9 | 10 | \S4method{freeResourceMap}{ResourceMap}(x) 11 | } 12 | \arguments{ 13 | \item{x}{a ResourceMap} 14 | } 15 | \description{ 16 | The resources allocated by the redland RDF package are freed. The ResourceMap 17 | object should be deleted immediately following this call. 18 | } 19 | \seealso{ 20 | \code{\link{ResourceMap-class}} 21 | } 22 | -------------------------------------------------------------------------------- /man/datapack-deprecated.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/zzz.R 3 | \name{datapack-deprecated} 4 | \alias{datapack-deprecated} 5 | \title{Deprecated Methods} 6 | \description{ 7 | The following items are deprecated in this release of datapack and will be 8 | marked as Defunct and removed in a future version. 9 | } 10 | \section{These methods are deprecated}{ 11 | 12 | \describe{ 13 | \item{\code{\link{recordDerivation}}}{: Record derivation relationships between objects in a DataPackage.} 14 | \item{\code{\link{addData}}}{: Add a DataObject to the DataPackage.} 15 | } 16 | } 17 | 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /inst/COPYRIGHTS: -------------------------------------------------------------------------------- 1 | The datapack R package is copyright; 2 | Copyright (C) 2014-2016 Regents of the University of California 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 | except in compliance with the License. You may obtain a copy of the License at: 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed under 10 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 11 | either express or implied. See the License for the specific language governing permissions 12 | and limitations under the License. 13 | -------------------------------------------------------------------------------- /man/plotRelationships.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{plotRelationships} 4 | \alias{plotRelationships} 5 | \alias{plotRelationships,DataPackage-method} 6 | \title{Plot derivation relationships obtained from getRelationships} 7 | \usage{ 8 | plotRelationships(x, ...) 9 | 10 | \S4method{plotRelationships}{DataPackage}(x, col = NULL, ...) 11 | } 12 | \arguments{ 13 | \item{x}{a DataPackage object} 14 | 15 | \item{...}{other options passed to the igraph plot function} 16 | 17 | \item{col}{vector of colors used for plotting} 18 | } 19 | \description{ 20 | Creates graph of dataPackage object generated from getRelationships 21 | } 22 | \seealso{ 23 | \code{\link{DataPackage-class}} 24 | } 25 | -------------------------------------------------------------------------------- /man/ResourceMap-initialize.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ResourceMap.R 3 | \name{initialize,ResourceMap-method} 4 | \alias{initialize,ResourceMap-method} 5 | \alias{ResourceMap-initialize} 6 | \title{Initialize a ResourceMap object} 7 | \usage{ 8 | \S4method{initialize}{ResourceMap}(.Object, id = NA_character_) 9 | } 10 | \arguments{ 11 | \item{.Object}{a ResourceMap object} 12 | 13 | \item{id}{a unique identifier to identify this ResourceMap. This id will be used internally in the ResourceMap.} 14 | } 15 | \value{ 16 | the ResourceMap object 17 | } 18 | \description{ 19 | Create a ResourceMap object that contains relationships (RDF triples) of objects in the DataPackage. 20 | } 21 | \seealso{ 22 | \code{\link{ResourceMap-class}} 23 | } 24 | -------------------------------------------------------------------------------- /man/getFormatId.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataObject.R 3 | \name{getFormatId} 4 | \alias{getFormatId} 5 | \alias{getFormatId,DataObject-method} 6 | \title{Get the FormatId of the DataObject} 7 | \usage{ 8 | getFormatId(x, ...) 9 | 10 | \S4method{getFormatId}{DataObject}(x) 11 | } 12 | \arguments{ 13 | \item{x}{DataObject} 14 | 15 | \item{...}{(not yet used)} 16 | } 17 | \value{ 18 | the formatId 19 | } 20 | \description{ 21 | Get the FormatId of the DataObject 22 | } 23 | \examples{ 24 | data <- charToRaw("1,2,3\n4,5,6\n") 25 | do <- new("DataObject", "id1", dataobj=data, "text/csv", 26 | "uid=jones,DC=example,DC=com", "urn:node:KNB") 27 | fmtId <- getFormatId(do) 28 | } 29 | \seealso{ 30 | \code{\link{DataObject-class}} 31 | } 32 | -------------------------------------------------------------------------------- /man/getIdentifier.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataObject.R 3 | \name{getIdentifier} 4 | \alias{getIdentifier} 5 | \alias{getIdentifier,DataObject-method} 6 | \title{Get the Identifier of the DataObject} 7 | \usage{ 8 | getIdentifier(x, ...) 9 | 10 | \S4method{getIdentifier}{DataObject}(x) 11 | } 12 | \arguments{ 13 | \item{x}{DataObject} 14 | 15 | \item{...}{(not yet used)} 16 | } 17 | \value{ 18 | the identifier 19 | } 20 | \description{ 21 | Get the Identifier of the DataObject 22 | } 23 | \examples{ 24 | data <- charToRaw("1,2,3\n4,5,6\n") 25 | do <- new("DataObject", "id1", dataobj=data, "text/csv", 26 | "uid=jones,DC=example,DC=com", "urn:node:KNB") 27 | id <- getIdentifier(do) 28 | } 29 | \seealso{ 30 | \code{\link{DataObject-class}} 31 | } 32 | -------------------------------------------------------------------------------- /man/getSize.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{getSize} 4 | \alias{getSize} 5 | \alias{getSize,DataPackage-method} 6 | \title{Get the Count of Objects in the Package} 7 | \usage{ 8 | getSize(x, ...) 9 | 10 | \S4method{getSize}{DataPackage}(x) 11 | } 12 | \arguments{ 13 | \item{x}{A DataPackage instance} 14 | 15 | \item{...}{(not yet used)} 16 | } 17 | \value{ 18 | The number of object in the Package 19 | } 20 | \description{ 21 | Get the Count of Objects in the Package 22 | } 23 | \examples{ 24 | dp <- new("DataPackage") 25 | data <- charToRaw("1,2,3\n4,5,6") 26 | do <- new("DataObject", dataobj=data, format="text/csv", user="jsmith") 27 | dp <- addMember(dp, do) 28 | getSize(dp) 29 | } 30 | \seealso{ 31 | \code{\link{DataPackage-class}} 32 | } 33 | -------------------------------------------------------------------------------- /man/calculateChecksum.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataObject.R 3 | \name{calculateChecksum} 4 | \alias{calculateChecksum} 5 | \alias{calculateChecksum,DataObject-method} 6 | \title{Calculate a checksum for the DataObject using the specified checksum algorithm} 7 | \usage{ 8 | calculateChecksum(x, ...) 9 | 10 | \S4method{calculateChecksum}{DataObject}(x, checksumAlgorithm = "SHA256", ...) 11 | } 12 | \arguments{ 13 | \item{x}{A DataObject instance} 14 | 15 | \item{...}{Additional parameters (not yet used)} 16 | 17 | \item{checksumAlgorithm}{a \code{character} value specifying the checksum algorithm to use (i.e "MD5" or "SHA1" or "SHA256")} 18 | } 19 | \value{ 20 | The calculated checksum 21 | } 22 | \description{ 23 | calculates a checksum 24 | } 25 | \note{ 26 | this method is intended for internal package use only. 27 | } 28 | -------------------------------------------------------------------------------- /man/getIdentifiers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{getIdentifiers} 4 | \alias{getIdentifiers} 5 | \alias{getIdentifiers,DataPackage-method} 6 | \title{Get the Identifiers of Package Members} 7 | \usage{ 8 | getIdentifiers(x, ...) 9 | 10 | \S4method{getIdentifiers}{DataPackage}(x) 11 | } 12 | \arguments{ 13 | \item{x}{A DataPackage instance} 14 | 15 | \item{...}{(not yet used)} 16 | } 17 | \value{ 18 | A list of identifiers 19 | } 20 | \description{ 21 | The identifiers of the objects in the package are retrieved and returned as a list. 22 | } 23 | \examples{ 24 | dp <- new("DataPackage") 25 | data <- charToRaw("1,2,3\n4,5,6") 26 | do <- new("DataObject", dataobj=data, format="text/csv", user="jsmith") 27 | dp <- addMember(dp, do) 28 | getIdentifiers(dp) 29 | } 30 | \seealso{ 31 | \code{\link{DataPackage-class}} 32 | } 33 | -------------------------------------------------------------------------------- /man/DataPackage-initialize.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{initialize,DataPackage-method} 4 | \alias{initialize,DataPackage-method} 5 | \alias{DataPackage-initialize} 6 | \title{Initialize a DataPackage object} 7 | \usage{ 8 | \S4method{initialize}{DataPackage}(.Object, packageId) 9 | } 10 | \arguments{ 11 | \item{.Object}{The object being initialized} 12 | 13 | \item{packageId}{The package id to assign to the package} 14 | } 15 | \description{ 16 | Initialize a DataPackage object 17 | } 18 | \examples{ 19 | # Create a DataPackage with undefined package id (to be set manually later) 20 | pkg <- new("DataPackage") 21 | # Alternatively, manually assign the package id when the DataPackage object is created 22 | pkg <- new("DataPackage", "urn:uuid:4f953288-f593-49a1-adc2-5881f815e946") 23 | } 24 | \seealso{ 25 | \code{\link{DataPackage-class}} 26 | } 27 | -------------------------------------------------------------------------------- /man/getMember.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{getMember} 4 | \alias{getMember} 5 | \alias{getMember,DataPackage-method} 6 | \title{Return the Package Member by Identifier} 7 | \usage{ 8 | getMember(x, ...) 9 | 10 | \S4method{getMember}{DataPackage}(x, identifier) 11 | } 12 | \arguments{ 13 | \item{x}{A DataPackage instance} 14 | 15 | \item{...}{(Not yet used)} 16 | 17 | \item{identifier}{A DataObject identifier} 18 | } 19 | \value{ 20 | A DataObject if the member is found, or NULL if not 21 | } 22 | \description{ 23 | Given the identifier of a member of the data package, return the DataObject 24 | representation of the member. 25 | } 26 | \examples{ 27 | dp <- new("DataPackage") 28 | data <- charToRaw("1,2,3\n4,5,6") 29 | do <- new("DataObject", id="myNewId", dataobj=data, format="text/csv", user="jsmith") 30 | dp <- addMember(dp, do) 31 | do2 <- getMember(dp, "myNewId") 32 | } 33 | \seealso{ 34 | \code{\link{DataPackage-class}} 35 | } 36 | -------------------------------------------------------------------------------- /man/validate.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/SystemMetadata.R 3 | \name{validate} 4 | \alias{validate} 5 | \alias{validate,SystemMetadata-method} 6 | \title{Validate a SystemMetadata object} 7 | \usage{ 8 | validate(x, ...) 9 | 10 | \S4method{validate}{SystemMetadata}(x, ...) 11 | } 12 | \arguments{ 13 | \item{x}{the instance to be validated} 14 | 15 | \item{...}{(Additional parameters)} 16 | } 17 | \value{ 18 | logical, \code{TRUE} if the SystemMetadata object is valid, else a list of strings detailing errors 19 | } 20 | \description{ 21 | Validate a system metadata object, ensuring that required fields are present and of the right type. 22 | } 23 | \examples{ 24 | library(XML) 25 | doc <- xmlParseDoc(system.file("testfiles/sysmeta.xml", package="datapack"), asText=FALSE) 26 | sysmeta <- new("SystemMetadata") 27 | sysmeta <- parseSystemMetadata(sysmeta, xmlRoot(doc)) 28 | valid <- validate(sysmeta) 29 | } 30 | \seealso{ 31 | \code{\link{SystemMetadata-class}} 32 | } 33 | -------------------------------------------------------------------------------- /man/containsId.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{containsId} 4 | \alias{containsId} 5 | \alias{containsId,DataPackage-method} 6 | \title{Returns true if the specified object is a member of the package} 7 | \usage{ 8 | containsId(x, ...) 9 | 10 | \S4method{containsId}{DataPackage}(x, identifier) 11 | } 12 | \arguments{ 13 | \item{x}{A DataPackage object} 14 | 15 | \item{...}{(Not yet used)} 16 | 17 | \item{identifier}{The DataObject identifier to check for inclusion in the DataPackage} 18 | } 19 | \value{ 20 | A logical - a value of TRUE indicates that the DataObject is in the DataPackage 21 | } 22 | \description{ 23 | Returns true if the specified object is a member of the package 24 | } 25 | \examples{ 26 | dp <- new("DataPackage") 27 | data <- charToRaw("1,2,3\n4,5,6") 28 | id <- "myNewId" 29 | do <- new("DataObject", id=id, dataobj=data, format="text/csv", user="jsmith") 30 | dp <- addMember(dp, do) 31 | isInPackage <- containsId(dp, identifier="myNewId") 32 | } 33 | \seealso{ 34 | \code{\link{DataPackage-class}} 35 | } 36 | -------------------------------------------------------------------------------- /man/updateRelationships.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{updateRelationships} 4 | \alias{updateRelationships} 5 | \alias{updateRelationships,DataPackage-method} 6 | \title{Update package relationships by replacing an old identifier with a new one} 7 | \usage{ 8 | updateRelationships(x, ...) 9 | 10 | \S4method{updateRelationships}{DataPackage}(x, id, newId, ...) 11 | } 12 | \arguments{ 13 | \item{x}{A DataPackage object} 14 | 15 | \item{...}{(Not yet used)} 16 | 17 | \item{id}{A character value containing the identifier to be replaced.} 18 | 19 | \item{newId}{A character value containing the identifier that will replace the old identifier.} 20 | } 21 | \description{ 22 | When package members are updated, they receive a new identifier (replaceMember). It is therefor 23 | necessary to update the package relationships to update occurrences of the old identifier 24 | with the new one when the old identifier appears in the "subject" or "object" of a 25 | relationship. 26 | } 27 | \seealso{ 28 | \code{\link{DataPackage-class}} 29 | } 30 | -------------------------------------------------------------------------------- /man/SystemMetadata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/SystemMetadata.R 3 | \name{SystemMetadata} 4 | \alias{SystemMetadata} 5 | \alias{SystemMetadata,XMLInternalElementNode-method} 6 | \title{Create DataONE SystemMetadata object} 7 | \usage{ 8 | SystemMetadata(...) 9 | 10 | \S4method{SystemMetadata}{XMLInternalElementNode}(x, ...) 11 | } 12 | \arguments{ 13 | \item{...}{Additional arguments} 14 | 15 | \item{x}{A value of type \code{"XMLInternalElementNode"}, containing the parsed XML element with SystemMetadata fields.} 16 | } 17 | \description{ 18 | A class representing DataONE SystemMetadata, which is core information about objects stored in a repository 19 | and needed to manage those objects across systems. SystemMetadata contains basic identification, ownership, 20 | access policy, replication policy, and related metadata. 21 | 22 | If the *sysmeta* parameter is specified, then construct a new SystemMetadata instance by using the fields from 23 | an XML representation of the SystemMetadata. 24 | } 25 | \seealso{ 26 | \code{\link{SystemMetadata-class}} 27 | } 28 | -------------------------------------------------------------------------------- /R/dmsg.R: -------------------------------------------------------------------------------- 1 | # 2 | # This work was created by participants in the DataONE project, and is 3 | # jointly copyrighted by participating institutions in DataONE. For 4 | # more information on DataONE, see our web site at http://dataone.org. 5 | # 6 | # Copyright 2011-2014 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | #' Print a debugging message to stderr 22 | #' @details Only print the message if the option "datapack.debugging_mode" is TRUE. 23 | #' @param msg the message to be printed 24 | dmsg <- function(msg) { 25 | dbg <- getOption("datapack.debugging_mode", default = FALSE) 26 | if (dbg) { 27 | message(msg) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /man/parseSystemMetadata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/SystemMetadata.R 3 | \name{parseSystemMetadata} 4 | \alias{parseSystemMetadata} 5 | \alias{parseSystemMetadata,SystemMetadata-method} 6 | \title{Parse an external XML document and populate a SystemMetadata object with the parsed data} 7 | \usage{ 8 | parseSystemMetadata(x, ...) 9 | 10 | \S4method{parseSystemMetadata}{SystemMetadata}(x, xml, ...) 11 | } 12 | \arguments{ 13 | \item{x}{The \code{SystemMetadata} object} 14 | 15 | \item{...}{Additional arguments passed to other functions or methods} 16 | 17 | \item{xml}{The XML representation of the capabilities, as an XMLInternalElementNode} 18 | } 19 | \value{ 20 | the SystemMetadata object representing an object 21 | } 22 | \description{ 23 | Parse an XML representation of system metadata, and set the object slots of a SystemMetadata object 24 | the with obtained values. 25 | } 26 | \examples{ 27 | library(XML) 28 | doc <- xmlParseDoc(system.file("testfiles/sysmeta.xml", package="datapack"), asText=FALSE) 29 | sysmeta <- new("SystemMetadata") 30 | sysmeta <- parseSystemMetadata(sysmeta, xmlRoot(doc)) 31 | } 32 | \seealso{ 33 | \code{\link{SystemMetadata-class}} 34 | } 35 | -------------------------------------------------------------------------------- /man/getRelationships.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{getRelationships} 4 | \alias{getRelationships} 5 | \alias{getRelationships,DataPackage-method} 6 | \title{Retrieve relationships of package objects} 7 | \usage{ 8 | getRelationships(x, ...) 9 | 10 | \S4method{getRelationships}{DataPackage}(x, condense = F, ...) 11 | } 12 | \arguments{ 13 | \item{x}{A DataPackage object} 14 | 15 | \item{...}{(Not yet used)} 16 | 17 | \item{condense}{A logical value, if TRUE then a more easily viewed version of relationships are returned.} 18 | } 19 | \description{ 20 | Relationships of objects in a package are defined using the \code{'insertRelationship'} call and retrieved 21 | using \code{getRetaionships}. These relationships are returned in a data frame with \code{'subject'}, \code{'predicate'}, \code{'objects'} 22 | as the columns, ordered by "subject" 23 | } 24 | \examples{ 25 | dp <- new("DataPackage") 26 | insertRelationship(dp, "/Users/smith/scripts/genFields.R", 27 | "http://www.w3.org/ns/prov#used", 28 | "https://knb.ecoinformatics.org/knb/d1/mn/v1/object/doi:1234/_030MXTI009R00_20030812.40.1") 29 | rels <- getRelationships(dp) 30 | } 31 | \seealso{ 32 | \code{\link{DataPackage-class}} 33 | } 34 | -------------------------------------------------------------------------------- /man/getData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataObject.R, R/DataPackage.R 3 | \name{getData} 4 | \alias{getData} 5 | \alias{getData,DataObject-method} 6 | \alias{getData,DataPackage-method} 7 | \title{Get the data content of a specified data object} 8 | \usage{ 9 | getData(x, ...) 10 | 11 | \S4method{getData}{DataObject}(x) 12 | 13 | \S4method{getData}{DataPackage}(x, id) 14 | } 15 | \arguments{ 16 | \item{x}{DataObject or DataPackage: the data structure from where to get the data} 17 | 18 | \item{...}{Additional arguments} 19 | 20 | \item{id}{Missing or character: if \code{'x'} is DataPackage, the identifier of the 21 | package member to get data from} 22 | } 23 | \value{ 24 | raw representation of the data 25 | } 26 | \description{ 27 | Get the data content of a specified data object 28 | } 29 | \examples{ 30 | data <- charToRaw("1,2,3\n4,5,6\n") 31 | do <- new("DataObject", "id1", dataobj=data, "text/csv", 32 | "uid=jones,DC=example,DC=com", "urn:node:KNB") 33 | bytes <- getData(do) 34 | dp <- new("DataPackage") 35 | data <- charToRaw("1,2,3\n4,5,6") 36 | do1 <- new("DataObject", id="id1", data, format="text/csv", user="smith", mnNodeId="urn:node:KNB") 37 | dp <- addMember(dp, do1) 38 | bytes <- getData(dp, "id1") 39 | } 40 | \seealso{ 41 | \code{\link{DataObject-class}} 42 | } 43 | -------------------------------------------------------------------------------- /man/removeMember.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{removeMember} 4 | \alias{removeMember} 5 | \alias{removeMember,DataPackage-method} 6 | \title{Remove the Specified Member from the Package} 7 | \usage{ 8 | removeMember(x, ...) 9 | 10 | \S4method{removeMember}{DataPackage}(x, do, removeRelationships = FALSE) 11 | } 12 | \arguments{ 13 | \item{x}{a DataPackage object} 14 | 15 | \item{...}{(Not yet used)} 16 | 17 | \item{do}{The package member to remove, either as a \code{"DataObject"} or \code{"character"} (for the object identifier)} 18 | 19 | \item{removeRelationships}{A \code{logical} value. If TRUE, package relationships for this package member are removed. Default is FALSE.} 20 | } 21 | \description{ 22 | Given the identifier of a DataObject in a DataPackage, delete the DataObject 23 | from the DataPackage. 24 | } 25 | \details{ 26 | The \code{removeMember} method removes the specified DataObject from the DataPackage. In 27 | addition, any package relationships that included the DataObject are removed. 28 | } 29 | \examples{ 30 | dp <- new("DataPackage") 31 | data <- charToRaw("1,2,3\n4,5,6") 32 | do <- new("DataObject", id="myNewId", dataobj=data, format="text/csv", user="jsmith") 33 | dp <- addMember(dp, do) 34 | # Remove the package member and any provenance relationships that reference it. 35 | removeMember(dp, "myNewId", removeRelationships=TRUE) 36 | } 37 | \seealso{ 38 | \code{\link{DataPackage-class}} 39 | } 40 | -------------------------------------------------------------------------------- /man/getTriples.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ResourceMap.R 3 | \name{getTriples} 4 | \alias{getTriples} 5 | \alias{getTriples,ResourceMap-method} 6 | \title{Get the RDF relationships stored in the ResourceMap} 7 | \usage{ 8 | getTriples(x, ...) 9 | 10 | \S4method{getTriples}{ResourceMap}(x, filter = TRUE, identifiers = list(), ...) 11 | } 12 | \arguments{ 13 | \item{x}{ResourceMap} 14 | 15 | \item{...}{Additional parameters (not yet implemented).} 16 | 17 | \item{filter}{A \code{logical} value. If TRUE, then DataONE packaging relationships are omitted.} 18 | 19 | \item{identifiers}{A list of \code{character} values of the identifiers of DataPackage members.} 20 | } 21 | \value{ 22 | x A data.frame containing the relationships from the ResourceMap 23 | } 24 | \description{ 25 | The \code{getTriples} method extracts the RDF relationships from a ResourceMap. 26 | } 27 | \details{ 28 | The \code{filter} argument causes DataONE packaging relationships to be removed. 29 | A description of these can be viewed at https://purl.dataone.org/architecture/design/DataPackage.html. 30 | The \code{identifiers} parameter can contain a list of DataPackage members for which the 31 | identifiers will be 'demoted', that is any relationship that has these identifiers as a 32 | URL as the subject or object will be changed to the 'bare' identifier. The intent of these two parameter is to 33 | transform the DataPackage to a 'local' state, so that it can be more easily updated locally. 34 | } 35 | -------------------------------------------------------------------------------- /man/getValue.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{getValue} 4 | \alias{getValue} 5 | \alias{getValue,DataPackage-method} 6 | \title{Get values for selected DataPackage members} 7 | \usage{ 8 | getValue(x, ...) 9 | 10 | \S4method{getValue}{DataPackage}(x, name, identifiers = NA_character_) 11 | } 12 | \arguments{ 13 | \item{x}{A DataPackage instance} 14 | 15 | \item{...}{(Not yet used)} 16 | 17 | \item{name}{A name of a DataObject slot.} 18 | 19 | \item{identifiers}{A list of DataPackage member identifiers} 20 | } 21 | \value{ 22 | A list of values for matching slot names and included identifiers. 23 | } 24 | \description{ 25 | Given a slot name and set of package member identifiers, return slot values. 26 | } 27 | \details{ 28 | If the parameter \code{identifiers} is provided, then only the DataPackage 29 | members that have identifiers in the provided list will have there values fetched. 30 | If this parameter is not provided, then the values for all DataPackage members are returned. 31 | } 32 | \examples{ 33 | dp <- new("DataPackage") 34 | data <- charToRaw("1,2,3\n4,5,6") 35 | do <- new("DataObject", id="myNewId", dataobj=data, format="text/csv", user="jsmith") 36 | dp <- addMember(dp, do) 37 | data <- charToRaw("7,8.9\n4,10,11") 38 | do <- new("DataObject", id="myNewId2", dataobj=data, format="text/csv", user="jsmith") 39 | dp <- addMember(dp, do) 40 | formats <- getValue(dp, name="sysmeta@formatId") 41 | } 42 | \seealso{ 43 | \code{\link{DataPackage-class}} 44 | } 45 | -------------------------------------------------------------------------------- /man/serializeSystemMetadata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/SystemMetadata.R 3 | \name{serializeSystemMetadata} 4 | \alias{serializeSystemMetadata} 5 | \alias{serializeSystemMetadata,SystemMetadata-method} 6 | \title{Serialize a SystemMetadata object to an XML representation} 7 | \usage{ 8 | serializeSystemMetadata(x, ...) 9 | 10 | \S4method{serializeSystemMetadata}{SystemMetadata}(x, version = "v1", ...) 11 | } 12 | \arguments{ 13 | \item{x}{The SystemMetadata instance to be serialized.} 14 | 15 | \item{...}{(Not currently used)} 16 | 17 | \item{version}{A character string representing the DataONE API version that this system will be used with (e.g. "v1", "v2").} 18 | } 19 | \value{ 20 | A character value of the filename that the XML representation of the SystemMetadata object was written to. 21 | 22 | the character string representing a SystemMetadata object 23 | } 24 | \description{ 25 | The SystemMetadata object is converted to XML and 26 | written to a file. 27 | } 28 | \details{ 29 | If the \code{'version'} parameter is specified as *v2* then the SystemMetadata 30 | object is serialized according to the DataONE version 2.0 system metadata format. 31 | } 32 | \examples{ 33 | library(XML) 34 | doc <- xmlParseDoc(system.file("testfiles/sysmeta.xml", package="datapack"), asText=FALSE) 35 | sysmeta <- new("SystemMetadata") 36 | sysmeta <- parseSystemMetadata(sysmeta, xmlRoot(doc)) 37 | sysmetaXML <- serializeSystemMetadata(sysmeta, version="v2") 38 | } 39 | \seealso{ 40 | \code{\link{SystemMetadata-class}} 41 | } 42 | -------------------------------------------------------------------------------- /inst/testfiles/sysmeta-v2-repfalse-zero-reps.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1 4 | arctic-data.9794.1 5 | text/csv 6 | 2944 7 | 1328389b7b5cf33727a9bb0aaadc76b7 8 | http://orcid.org/0000-0001-9790-3510 9 | http://orcid.org/0000-0001-9790-3510 10 | 11 | 12 | CN=arctic-data-admins,DC=dataone,DC=org 13 | read 14 | write 15 | changePermission 16 | 17 | 18 | http://orcid.org/0000-0001-9790-3510 19 | read 20 | write 21 | changePermission 22 | 23 | 24 | public 25 | read 26 | 27 | 28 | 29 | false 30 | 2016-11-17T00:00:00.000+00:00 31 | 2016-11-16T22:07:24.685+00:00 32 | urn:node:ARCTIC 33 | urn:node:ARCTIC 34 | 35 | -------------------------------------------------------------------------------- /man/parseRDF.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ResourceMap.R 3 | \name{parseRDF} 4 | \alias{parseRDF} 5 | \alias{parseRDF,ResourceMap-method} 6 | \title{Parse an RDF/XML resource map from a file} 7 | \usage{ 8 | parseRDF(x, rdf, ...) 9 | 10 | \S4method{parseRDF}{ResourceMap}( 11 | x, 12 | rdf, 13 | asText = FALSE, 14 | name = "rdfxml", 15 | mimeType = "application/rdf+xml", 16 | ... 17 | ) 18 | } 19 | \arguments{ 20 | \item{x}{ResourceMap} 21 | 22 | \item{rdf}{A file or character value containing a resource map that will be parsed into the ResourceMap object} 23 | 24 | \item{...}{Additional parameters (not yet used).} 25 | 26 | \item{asText}{A logical value. If TRUE, then the 'rdf' parameter is a character vector, if FALSE then it is the name of a file to read.} 27 | 28 | \item{name}{The name of the RDF xml parser, the default is "rdfxml".} 29 | 30 | \item{mimeType}{A character value containing the RDF format type. The default is "application/rdf+xml".} 31 | } 32 | \value{ 33 | x the ResourceMap containing the parsed RDF/XML content 34 | } 35 | \description{ 36 | parseRDF reads a file containing an RDF model in RDF/XML format and initializes 37 | a ResourceMap based on this content. 38 | } 39 | \details{ 40 | This method resets the slot ResourceMap@world so any previously stored triples are discarded, allowing 41 | for a clean model object in which to parse the new RDF content into. It is assumed that the content is a 42 | valid ORE resource map therefor no validation checks specific to the OAI-ORE content model are performed. 43 | } 44 | -------------------------------------------------------------------------------- /inst/testfiles/sysmeta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1 4 | doi:10.xxyy/AA/tesdoc123456789 5 | eml://ecoinformatics.org/eml-2.1.0 6 | 36281 7 | 24426711d5385a9ffa583a13d07af2502884932f 8 | CN=Matt Jones A729,O=Google,C=US,DC=cilogon,DC=org 9 | CN=Matt Jones A729,O=Google,C=US,DC=cilogon,DC=org 10 | 11 | 12 | public 13 | read 14 | 15 | 16 | CN=Matt Jones A729,O=Google,C=US,DC=cilogon,DC=org 17 | CN=Subject2,O=Google,C=US,DC=cilogon,DC=org 18 | write 19 | changePermission 20 | 21 | 22 | 23 | urn:node:KNB 24 | urn:node:mnUNM1 25 | urn:node:BADNODE 26 | 27 | true 28 | 2011-08-31T15:59:50.071163 29 | 2011-08-31T15:59:50.072921 30 | urn:node:KNB 31 | urn:node:KNB 32 | 33 | -------------------------------------------------------------------------------- /man/canRead.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataObject.R 3 | \name{canRead} 4 | \alias{canRead} 5 | \alias{canRead,DataObject-method} 6 | \title{Test whether the provided subject can read an object} 7 | \usage{ 8 | canRead(x, ...) 9 | 10 | \S4method{canRead}{DataObject}(x, subject) 11 | } 12 | \arguments{ 13 | \item{x}{DataObject} 14 | 15 | \item{...}{Additional arguments} 16 | 17 | \item{subject}{: the subject name of the person/system to check for read permissions} 18 | } 19 | \value{ 20 | boolean TRUE if the subject has read permission, or FALSE otherwise 21 | } 22 | \description{ 23 | Using the AccessPolicy, tests whether the subject has read permission 24 | for the object. This method is meant work prior to submission to a repository, 25 | and will show the permissions that would be enforced by the repository on submission. 26 | Currently it only uses the AccessPolicy to determine who can read (and not the rightsHolder field, 27 | which always can read an object). If an object has been granted read access by the 28 | special "public" subject, then all subjects have read access. 29 | } 30 | \details{ 31 | The subject name used in both the AccessPolicy and in the \code{'subject'} 32 | argument to this method is a string value, but is generally formatted as an X.509 33 | name formatted according to RFC 2253. 34 | } 35 | \examples{ 36 | data <- charToRaw("1,2,3\n4,5,6\n") 37 | obj <- new("DataObject", id="1234", dataobj=data, format="text/csv") 38 | obj <- addAccessRule(obj, "smith", "read") 39 | access <- canRead(obj, "smith") 40 | } 41 | \seealso{ 42 | \code{\link{DataObject-class}} 43 | } 44 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Test environments 2 | 3 | * Windows Server 2022 x64 (build 20348): x86_64-w64-mingw32 R Under development (unstable) (2025-10-03 r88899 ucrt) 4 | * macOS Sequoia 15.6.1: aarch64-apple-darwin20 R 4.5.1 5 | * macOS Ventura 13.7.6: aarch64-apple-darwin20 R 4.4.1 6 | * macOS Ventura 13.7.6: aarch64-apple-darwin20 R 4.5.1 7 | * Windows Server 2022 x64 (build 26100): x86_64-w64-mingw32 R version 4.5.1 (2025-06-13 ucrt) 8 | * Ubuntu 24.04.3 LTS: x86_64-pc-linux-gnu R version 4.5.1 (2025-06-13) 9 | * Ubuntu 24.04.3 LTS: x86_64-pc-linux-gnu R version 4.4.3 (2025-02-28) 10 | * Ubuntu 24.04.3 LTS: x86_64-pc-linux-gnu R Under development (unstable) (2025-10-02 r88897) 11 | 12 | * rhub::rhub_check() 13 | * Fedora Linux 38 (Container Image) 14 | * using R Under development (unstable) (2025-10-02 r88897) 15 | * using platform: x86_64-pc-linux-gnu 16 | * Ubuntu 24.04.3 LTS 17 | * using R Under development (unstable) (2025-10-02 r88897) 18 | * using platform: x86_64-pc-linux-gnu 19 | * macOS Sequoia 15.6.1 20 | * using R Under development (unstable) (2025-10-03 r88898) 21 | * using platform: aarch64-apple-darwin20 22 | * Windows Server 2022 x64 (build 26100) 23 | * using R Under development (unstable) (2025-10-02 r88897 ucrt) 24 | * using platform: x86_64-w64-mingw32 25 | 26 | * There were no ERRORs or WARNINGs or NOTES. 27 | 28 | ## Downstream dependencies 29 | 30 | * revdepcheck:revdep_check() found no problems with the only downstream dependency: `dataone`. 31 | 32 | ## Comments 33 | 34 | Earlier I missed some broken URLs in the checks, which are now fixed. 35 | -------------------------------------------------------------------------------- /inst/WORDLIST: -------------------------------------------------------------------------------- 1 | ABI 2 | accessPolicy 3 | AccessPolicy 4 | Acknowledgements 5 | Allard 6 | ArchitectureDocs 7 | bagit 8 | BagIt 9 | Budden 10 | changePermission 11 | cito 12 | CITO 13 | cn 14 | createFromTriples 15 | csv 16 | DATANET 17 | dataobj 18 | DataObject 19 | DataObjects 20 | dataone 21 | DataONE 22 | datapackage 23 | dataPackage 24 | Datapackage 25 | DataPackage 26 | DataPackages 27 | derivedId 28 | deserialize 29 | DIBBS 30 | doi 31 | DOIs 32 | ecoinformatics 33 | eml 34 | EML 35 | filesystem 36 | formatId 37 | FormatId 38 | geospatial 39 | getData 40 | getRelationships 41 | Github 42 | graphviz 43 | grepl 44 | Gries 45 | Habermann 46 | http 47 | https 48 | IANA 49 | Identifers 50 | ietf 51 | igraph 52 | IRI 53 | JGM 54 | json 55 | JSON 56 | kunze 57 | Michener 58 | mimetype 59 | mimeType 60 | nceas 61 | NCEAS 62 | NetCDF 63 | ns 64 | ntriples 65 | OAI 66 | objectID 67 | objectIDs 68 | objectIDS 69 | objectType 70 | openarchives 71 | ORCID 72 | param 73 | parseRDF 74 | PIDs 75 | PLR 76 | ProvONE 77 | QV 78 | rasters 79 | rdf 80 | RDF 81 | rdfxml 82 | recordr 83 | redland 84 | Redland 85 | replaceMember 86 | resolveURI 87 | ResouceMap 88 | ResourceMap 89 | rightsHolder 90 | ropensci 91 | Schildhauer 92 | serializePackage 93 | seriesId 94 | sourceId 95 | stderr 96 | subjectID 97 | subjectType 98 | subtype 99 | syntaxName 100 | sysmeta 101 | SystemMetadata 102 | tempfile 103 | updateMetadata 104 | uploadDataPackage 105 | uri 106 | URI 107 | UUID 108 | Vieglais 109 | wasDerivedFrom 110 | wasGeneratedBy 111 | www 112 | XMLInternalElementNode 113 | XPath 114 | Yeboah 115 | zipfile 116 | -------------------------------------------------------------------------------- /man/updateXML.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataObject.R 3 | \name{updateXML} 4 | \alias{updateXML} 5 | \alias{updateXML,DataObject-method} 6 | \title{Update selected elements of the XML content of a DataObject} 7 | \usage{ 8 | updateXML(x, ...) 9 | 10 | \S4method{updateXML}{DataObject}(x, xpath = NA_character_, replacement = NA_character_, ...) 11 | } 12 | \arguments{ 13 | \item{x}{A DataObject instance} 14 | 15 | \item{...}{Additional parameters (not yet used)} 16 | 17 | \item{xpath}{A \code{character} value specifying the location in the XML to update.} 18 | 19 | \item{replacement}{A \code{character} value that will replace the elements found with the \code{xpath}.} 20 | } 21 | \value{ 22 | The modified DataObject 23 | } 24 | \description{ 25 | The data content of the DataObject is updated by using the \code{xpath} 26 | argument to locate the elements to update with the character value specified in the 27 | \code{replacement} argument. 28 | } 29 | \examples{ 30 | \dontrun{ 31 | library(datapack) 32 | dataObj <- new("DataObject", format="text/csv", file=sampleData) 33 | sampleEML <- system.file("extdata/sample-eml.xml", package="datapack") 34 | dataObj <- updateMetadata(dataObj, xpath="", replacement=) 35 | } 36 | library(datapack) 37 | # Create the metadata object with a sample EML file 38 | sampleMeta <- system.file("./extdata/sample-eml.xml", package="datapack") 39 | metaObj <- new("DataObject", format="eml://ecoinformatics.org/eml-2.1.1", file=sampleMeta) 40 | # In the metadata object, replace "sample-data.csv" with 'sample-data.csv.zip' 41 | xp <- sprintf("//dataTable/physical/objectName[text()=\"\%s\"]", "sample-data.csv") 42 | metaObj <- updateXML(metaObj, xpath=xp, replacement="sample-data.csv.zip") 43 | } 44 | \seealso{ 45 | \code{\link{DataObject-class}} 46 | } 47 | -------------------------------------------------------------------------------- /man/recordDerivation.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{recordDerivation} 4 | \alias{recordDerivation} 5 | \alias{recordDerivation,DataPackage-method} 6 | \title{Record derivation relationships between objects in a DataPackage} 7 | \usage{ 8 | recordDerivation(x, ...) 9 | 10 | \S4method{recordDerivation}{DataPackage}(x, sourceID, derivedIDs, ...) 11 | } 12 | \arguments{ 13 | \item{x}{a DataPackage object} 14 | 15 | \item{...}{Additional parameters} 16 | 17 | \item{sourceID}{the identifier of the source object in the relationship} 18 | 19 | \item{derivedIDs}{an identifier or list of identifiers of objects that were derived from the source} 20 | } 21 | \description{ 22 | Record a derivation relationship that expresses that a target object has been derived from a source object. 23 | For use with DataONE, a best practice is to specify the subject and predicate as DataONE persistent identifiers 24 | (https://mule1.dataone.org/ArchitectureDocs-current/design/PIDs.html). If the objects are not known to DataONE, then local identifiers can be 25 | used, and these local identifiers may be promoted to DataONE PIDs when the package is uploaded to a DataONE member node. 26 | } 27 | \details{ 28 | A derived relationship is created for each value in the list "objectIDs". For each derivedId, one statement will be 29 | added expressing that it was derived from the sourceId. The predicate is will be an RDF property (as a IRI) from the W3C PROV 30 | specification, namely, "http://www.w3.org/ns/prov#wasDerivedFrom" 31 | } 32 | \examples{ 33 | \dontrun{ 34 | dp <- new("DataPackage") 35 | recordDerivation(dp, "doi:1234/_030MXTI009R00_20030812.40.1", 36 | "doi:1234/_030MXTI009R00_20030812.45.1") 37 | } 38 | } 39 | \seealso{ 40 | \code{\link{DataPackage-class}} 41 | } 42 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/master/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, develop] 6 | pull_request: 7 | branches: [main, develop] 8 | 9 | name: R-CMD-check 10 | 11 | jobs: 12 | R-CMD-check: 13 | runs-on: ${{ matrix.config.os }} 14 | 15 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 16 | 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | config: 21 | - {os: macOS-latest, r: 'release'} 22 | - {os: windows-latest, r: 'release'} 23 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 24 | - {os: ubuntu-latest, r: 'release'} 25 | - {os: ubuntu-latest, r: 'oldrel-1'} 26 | 27 | env: 28 | GITHUB_PAT: ${{ secrets.TOKEN }} 29 | R_KEEP_PKG_SOURCE: yes 30 | 31 | steps: 32 | - uses: actions/checkout@v4 33 | 34 | - uses: r-lib/actions/setup-pandoc@v2 35 | 36 | - uses: r-lib/actions/setup-r@v2 37 | with: 38 | r-version: ${{ matrix.config.r }} 39 | http-user-agent: ${{ matrix.config.http-user-agent }} 40 | use-public-rspm: true 41 | 42 | - uses: r-lib/actions/setup-r-dependencies@v2 43 | with: 44 | extra-packages: rcmdcheck 45 | 46 | - uses: r-lib/actions/check-r-package@v2 47 | with: 48 | args: 'c("--no-manual", "--as-cran")' 49 | 50 | - name: Show testthat output 51 | if: always() 52 | run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true 53 | shell: bash 54 | 55 | - name: Upload check results 56 | if: failure() 57 | uses: actions/upload-artifact@v4 58 | with: 59 | name: ${{ runner.os }}-r${{ matrix.config.r }}-results 60 | path: check 61 | -------------------------------------------------------------------------------- /inst/testfiles/sysmeta-updated.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1 4 | doi:10.xxyy/AA/tesdoc123456789 5 | eml://ecoinformatics.org/eml-2.1.0 6 | 36281 7 | 24426711d5385a9ffa583a13d07af2502884932f 8 | CN=Matt Jones A729,O=Google,C=US,DC=cilogon,DC=org 9 | CN=Matt Jones A729,O=Google,C=US,DC=cilogon,DC=org 10 | 11 | 12 | public 13 | read 14 | 15 | 16 | CN=Matt Jones A729,O=Google,C=US,DC=cilogon,DC=org 17 | write 18 | changePermission 19 | 20 | 21 | CN=Subject2,O=Google,C=US,DC=cilogon,DC=org 22 | write 23 | changePermission 24 | 25 | 26 | bob 27 | read 28 | write 29 | 30 | 31 | alice 32 | read 33 | write 34 | 35 | 36 | 37 | urn:node:KNB 38 | urn:node:mnUNM1 39 | urn:node:BADNODE 40 | 41 | true 42 | 2011-08-31T15:59:50.071163 43 | 2011-08-31T15:59:50.072921 44 | urn:node:KNB 45 | urn:node:KNB 46 | 47 | -------------------------------------------------------------------------------- /man/serializeRDF.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ResourceMap.R 3 | \name{serializeRDF} 4 | \alias{serializeRDF} 5 | \alias{serializeRDF,ResourceMap-method} 6 | \title{Serialize a ResouceMap} 7 | \usage{ 8 | serializeRDF(x, ...) 9 | 10 | \S4method{serializeRDF}{ResourceMap}( 11 | x, 12 | file, 13 | syntaxName = "rdfxml", 14 | mimeType = "application/rdf+xml", 15 | namespaces = data.frame(namespace = character(), prefix = character(), stringsAsFactors 16 | = FALSE), 17 | syntaxURI = NA_character_ 18 | ) 19 | } 20 | \arguments{ 21 | \item{x}{a ResourceMap} 22 | 23 | \item{...}{Additional parameters} 24 | 25 | \item{file}{the file to which the ResourceMap will be serialized} 26 | 27 | \item{syntaxName}{name of the syntax to use for serialization - default is "rdfxml"} 28 | 29 | \item{mimeType}{the mimetype of the serialized output - the default is "application/rdf+xml"} 30 | 31 | \item{namespaces}{a data frame containing one or more namespaces and their associated prefix} 32 | 33 | \item{syntaxURI}{A URI of the serialized syntax} 34 | } 35 | \value{ 36 | status of the serialization (non) 37 | } 38 | \description{ 39 | The Redland RDF library is used to serialize the ResourceMap RDF model 40 | to a file as RDF/XML. 41 | } 42 | \examples{ 43 | dp <- new("DataPackage") 44 | data <- charToRaw("1,2,3\n4,5,6") 45 | do1 <- new("DataObject", id="id1", data, format="text/csv") 46 | do2 <- new("DataObject", id="id2", data, format="text/csv") 47 | dp <- addMember(dp, do1) 48 | dp <- addMember(dp, do2) 49 | dp <- insertRelationship(dp, subjectID="id1", objectIDs="id2", 50 | predicate="http://www.w3.org/ns/prov#wasDerivedFrom") 51 | relations <- getRelationships(dp) 52 | resmap <- new("ResourceMap") 53 | resmap <- createFromTriples(resmap, relations, id="myuniqueid") 54 | \dontrun{ 55 | tf <- tempfile(fileext=".xml") 56 | serializeRDF(resmap, tf) 57 | } 58 | } 59 | \seealso{ 60 | \code{\link{ResourceMap-class}} 61 | } 62 | -------------------------------------------------------------------------------- /man/setPublicAccess.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataObject.R, R/DataPackage.R 3 | \name{setPublicAccess} 4 | \alias{setPublicAccess} 5 | \alias{setPublicAccess,DataObject-method} 6 | \alias{setPublicAccess,DataPackage-method} 7 | \title{Add a Rule to the AccessPolicy to make the object publicly readable} 8 | \usage{ 9 | setPublicAccess(x, ...) 10 | 11 | \S4method{setPublicAccess}{DataObject}(x) 12 | 13 | \S4method{setPublicAccess}{DataPackage}(x, identifiers = list()) 14 | } 15 | \arguments{ 16 | \item{x}{DataObject} 17 | 18 | \item{...}{(not yet used)} 19 | 20 | \item{identifiers}{A list of \code{character} values containing package member identifiers that will be updated (default is all package members).} 21 | } 22 | \value{ 23 | A DataObject with modified access rules. 24 | 25 | A DataPackage with modified access rules. 26 | } 27 | \description{ 28 | To be called prior to creating the object in DataONE. When called before 29 | creating the object, adds a rule to the access policy that makes this object 30 | publicly readable. If called after creation, it will only change the system 31 | metadata locally, and will not have any effect on remotely uploaded copies of 32 | the DataObject. 33 | } 34 | \examples{ 35 | data <- charToRaw("1,2,3\n4,5,6\n") 36 | do <- new("DataObject", "id1", dataobj=data, "text/csv", 37 | "uid=jones,DC=example,DC=com", "urn:node:KNB") 38 | do <- setPublicAccess(do) 39 | # First create a sample package with two DataObjects 40 | dp <- new("DataPackage") 41 | data <- charToRaw("1,2,3\n4,5,6\n") 42 | obj <- new("DataObject", id="id1", dataobj=data, format="text/csv") 43 | dp <- addMember(dp, obj) 44 | data2 <- charToRaw("7,8,9\n4,10,11\n") 45 | obj2 <- new("DataObject", id="id2", dataobj=data2, format="text/csv") 46 | dp <- addMember(dp, obj2) 47 | # Now add public read to all package members ("id1", "id2") 48 | dp <- setPublicAccess(dp) 49 | } 50 | \seealso{ 51 | \code{\link{DataObject-class}} 52 | 53 | \code{\link{DataObject-class}} 54 | 55 | \code{\link{DataPackage-class}} 56 | } 57 | -------------------------------------------------------------------------------- /man/addData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{addData} 4 | \alias{addData} 5 | \alias{addData,DataPackage,DataObject-method} 6 | \title{Add a DataObject to the DataPackage} 7 | \usage{ 8 | addData(x, do, ...) 9 | 10 | \S4method{addData}{DataPackage,DataObject}(x, do, mo = NA_character_) 11 | } 12 | \arguments{ 13 | \item{x}{A DataPackage instance} 14 | 15 | \item{do}{A DataObject instance} 16 | 17 | \item{...}{(Additional parameters)} 18 | 19 | \item{mo}{A DataObject (containing metadata describing \code{"do"} ) to associate with the science object.} 20 | } 21 | \value{ 22 | the updated DataPackage object 23 | } 24 | \description{ 25 | The DataObject is added to the DataPackage. 26 | } 27 | \details{ 28 | The DataObject \code{"do"} is added to the DataPackage. If the optional \code{"mo"} parameter is specified, then it is 29 | assumed that the DataObject \code{"mo"} is a metadata 30 | object that describes the science object \code{"do"} that is being added. The \code{addData} function will add a relationship 31 | to the DataPackage resource map that indicates that the metadata object describes the science object using the 32 | Citation Typing Ontology (CITO). 33 | Note: this method updates the passed-in DataPackage object. 34 | \code{documents} and \code{isDocumentedBy} relationship. 35 | } 36 | \examples{ 37 | dpkg <- new("DataPackage") 38 | data <- charToRaw("1,2,3\n4,5,6") 39 | metadata <- charToRaw("EML or other metadata document text goes here\n") 40 | md <- new("DataObject", id="md1", dataobj=metadata, format="text/xml", user="smith", 41 | mnNodeId="urn:node:KNB") 42 | do <- new("DataObject", id="id1", dataobj=data, format="text/csv", user="smith", 43 | mnNodeId="urn:node:KNB") 44 | # Associate the metadata object with the science object. The 'mo' object will be added 45 | # to the package automatically, since it hasn't been added yet. 46 | # This method is now deprecated, so suppress warnings if desired. 47 | suppressWarnings(dpkg <- addData(dpkg, do, md)) 48 | } 49 | \seealso{ 50 | \code{\link{DataPackage-class}} 51 | } 52 | -------------------------------------------------------------------------------- /man/ResourceMap-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ResourceMap.R 3 | \docType{class} 4 | \name{ResourceMap-class} 5 | \alias{ResourceMap-class} 6 | \title{ResourceMap provides methods to create, serialize and deserialize an OAI ORE resource map} 7 | \description{ 8 | The Open Archives Initiative Object Reuse and Exchange (OAI-ORE) defines standards for the description 9 | and exchange of aggregations of web resources, such as a DataPackage. A Resource Map describes the objects 10 | in a DataPackage and the relationships between these objects. 11 | } 12 | \section{Slots}{ 13 | 14 | \describe{ 15 | \item{\code{relations}}{value of type \code{"data.frame"}, containing RDF triples representing the relationship between package objects} 16 | 17 | \item{\code{world}}{a Redland RDF World object} 18 | 19 | \item{\code{storage}}{a Redland RDF Storage object} 20 | 21 | \item{\code{model}}{a Redland RDF Model object} 22 | 23 | \item{\code{id}}{a unique identifier for a ResourceMap instance} 24 | }} 25 | 26 | \section{Methods}{ 27 | 28 | \describe{ 29 | \item{\code{\link[=ResourceMap-initialize]{initialize}}}{: Initialize a ResourceMap object.} 30 | \item{\code{\link{createFromTriples}}}{: Populate a ResourceMap with RDF relationships from data.frame.} 31 | \item{\code{\link{getTriples}}}{: Get the RDF relationships stored in the ResourceMap.} 32 | \item{\code{\link{parseRDF}}}{: Parse an RDF/XML resource map from a file.} 33 | \item{\code{\link{serializeRDF}}}{: Write the ResourceMap relationships to a file.} 34 | } 35 | } 36 | 37 | \examples{ 38 | dp <- new("DataPackage") 39 | dp <- insertRelationship(dp, "/Users/smith/scripts/genFields.R", 40 | "http://www.w3.org/ns/prov#used", 41 | "https://knb.ecoinformatics.org/knb/d1/mn/v1/object/doi:1234/_030MXTI009R00_20030812.40.1") 42 | relations <- getRelationships(dp) 43 | resMap <- new("ResourceMap") 44 | resMap <- createFromTriples(resMap, relations, getIdentifiers(dp)) 45 | \dontrun{ 46 | tf <- tempfile(fileext=".rdf") 47 | serializeRDF(resMap, file=tf) 48 | } 49 | } 50 | \seealso{ 51 | \code{\link{datapack}} 52 | } 53 | \keyword{resourceMap} 54 | -------------------------------------------------------------------------------- /man/addMember.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{addMember} 4 | \alias{addMember} 5 | \alias{addMember,DataPackage-method} 6 | \title{Add a DataObject to the DataPackage} 7 | \usage{ 8 | addMember(x, ...) 9 | 10 | \S4method{addMember}{DataPackage}(x, do, mo = NA_character_) 11 | } 12 | \arguments{ 13 | \item{x}{A DataPackage instance} 14 | 15 | \item{...}{(Additional parameters)} 16 | 17 | \item{do}{The DataObject to add.} 18 | 19 | \item{mo}{A DataObject (containing metadata describing \code{"do"} ) to associate with the science object. If this DataObject 20 | has already been added to the package, the argument can be a \code{"character"} containing the DataObject identifier.} 21 | } 22 | \value{ 23 | the updated DataPackage object 24 | } 25 | \description{ 26 | The DataObject is added to the DataPackage. 27 | } 28 | \details{ 29 | The DataObject \code{"do"} is added to the DataPackage. If the optional \code{"mo"} parameter is specified, then it is 30 | assumed that the DataObject \code{"mo"} is a metadata 31 | object that describes the science object \code{"do"} that is being added. The \code{addMember} function will add a relationship 32 | to the DataPackage resource map that indicates that the metadata object describes the science object using the 33 | Citation Typing Ontology (CITO). 34 | Note: this method updates the passed-in DataPackage object. 35 | \code{documents} and \code{isDocumentedBy} relationship. 36 | } 37 | \examples{ 38 | dpkg <- new("DataPackage") 39 | data <- charToRaw("1,2,3\n4,5,6") 40 | metadata <- charToRaw("EML or other metadata document text goes here\n") 41 | md <- new("DataObject", id="md1", dataobj=metadata, format="text/xml", user="smith", 42 | mnNodeId="urn:node:KNB") 43 | do <- new("DataObject", id="id1", dataobj=data, format="text/csv", user="smith", 44 | mnNodeId="urn:node:KNB") 45 | # Associate the metadata object with the science object. The 'mo' object will be added 46 | # to the package automatically, since it hasn't been added yet. 47 | dpkg <- addMember(dpkg, do, md) 48 | } 49 | \seealso{ 50 | \code{\link{DataPackage-class}} 51 | } 52 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: datapack 2 | Title: A Flexible Container to Transport and Manipulate Data and Associated 3 | Resources 4 | Version: 1.4.2 5 | Authors@R: c( 6 | person("Matthew B.", "Jones", role = c("aut","cre"), email = "jones@nceas.ucsb.edu", comment=c(ORCID = "0000-0003-0077-4738")), 7 | person("Peter", "Slaughter", role = "aut", email = "slaughter@nceas.ucsb.edu", comment=c(ORCID = "0000-0002-2192-403X")), 8 | person("Jeanette", "Clark", role = "ctb", email = "jclark@nceas.ucsb.edu", comment=c(ORCID = "0000-0003-4703-1974")), 9 | person("Regents of the University of California", role = c("cph"))) 10 | Description: Provides a flexible container to transport and manipulate complex 11 | sets of data. These data may consist of multiple data files and associated 12 | meta data and ancillary files. Individual data objects have associated system 13 | level meta data, and data files are linked together using the OAI-ORE standard 14 | resource map which describes the relationships between the files. The OAI- 15 | ORE standard is described at . Data packages 16 | can be serialized and transported as structured files that have been created 17 | following the BagIt specification. The BagIt specification is described at 18 | . 19 | Date: 2025-10-07 20 | Depends: 21 | R (>= 3.1.1) 22 | Imports: 23 | digest, 24 | fs, 25 | methods, 26 | redland, 27 | XML, 28 | utils, 29 | uuid, 30 | zip 31 | Suggests: 32 | testthat (>= 3.0.0), 33 | knitr, 34 | httr, 35 | igraph, 36 | rmarkdown 37 | License: Apache License (== 2.0) 38 | URL: https://docs.ropensci.org/datapack/, https://github.com/ropensci/datapack 39 | BugReports: https://github.com/ropensci/datapack/issues 40 | VignetteBuilder: knitr 41 | Encoding: UTF-8 42 | Language: en-US 43 | Collate: 44 | 'Constants.R' 45 | 'SystemMetadata.R' 46 | 'dmsg.R' 47 | 'DataObject.R' 48 | 'DataPackage.R' 49 | 'ResourceMap.R' 50 | 'datapack-package.r' 51 | 'zzz.R' 52 | RoxygenNote: 7.3.3 53 | Config/testthat/edition: 3 54 | -------------------------------------------------------------------------------- /inst/testfiles/sysmeta-v2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 3 4 | 5 | testresmap.rdf 6 | 7 7 | 0007f892-0d8f-4451-94e9-94d02ba5dd0d_0 8 | http://www.openarchives.org/ore/terms 9 | 2904 10 | c27e3570c2f845d05302e1560ddbd848d1c18179 11 | CN=Christopher Jones A2108,O=Google,C=US,DC=cilogon,DC=org 12 | CN=Christopher Jones A2108,O=Google,C=US,DC=cilogon,DC=org 13 | 14 | 15 | public 16 | read 17 | 18 | 19 | 20 | false 21 | 2015-08-24T22:19:33.523+00:00 22 | 2015-08-25T14:54:44.593+00:00 23 | urn:node:mnDevUNM1 24 | urn:node:mnDevUNM1 25 | 26 | urn:node:mnDevUNM1 27 | completed 28 | 2015-08-25T14:42:50.086+00:00 29 | 30 | 31 | urn:node:cnDev2 32 | completed 33 | 2015-08-25T14:42:50.199+00:00 34 | 35 | 36 | urn:node:mnDevUCSB2 37 | completed 38 | 2015-08-25T14:54:38.070+00:00 39 | 40 | 41 | urn:node:mnDevUNM2 42 | completed 43 | 2015-08-25T14:54:39.526+00:00 44 | 45 | 46 | -------------------------------------------------------------------------------- /inst/testfiles/sysmeta-v2-repfalse.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 3 4 | 5 | testresmap.rdf 6 | 7 7 | 0007f892-0d8f-4451-94e9-94d02ba5dd0d_0 8 | http://www.openarchives.org/ore/terms 9 | 2904 10 | c27e3570c2f845d05302e1560ddbd848d1c18179 11 | CN=Christopher Jones A2108,O=Google,C=US,DC=cilogon,DC=org 12 | CN=Christopher Jones A2108,O=Google,C=US,DC=cilogon,DC=org 13 | 14 | 15 | public 16 | read 17 | 18 | 19 | 20 | false 21 | 2015-08-24T22:19:33.523+00:00 22 | 2015-08-25T14:54:44.593+00:00 23 | urn:node:mnDevUNM1 24 | urn:node:mnDevUNM1 25 | 26 | urn:node:mnDevUNM1 27 | completed 28 | 2015-08-25T14:42:50.086+00:00 29 | 30 | 31 | urn:node:cnDev2 32 | completed 33 | 2015-08-25T14:42:50.199+00:00 34 | 35 | 36 | urn:node:mnDevUCSB2 37 | completed 38 | 2015-08-25T14:54:38.070+00:00 39 | 40 | 41 | urn:node:mnDevUNM2 42 | completed 43 | 2015-08-25T14:54:39.526+00:00 44 | 45 | 46 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(SystemMetadata) 4 | export(addAccessRule) 5 | export(addData) 6 | export(addMember) 7 | export(canRead) 8 | export(clearAccessPolicy) 9 | export(containsId) 10 | export(createFromTriples) 11 | export(freeResourceMap) 12 | export(getData) 13 | export(getFormatId) 14 | export(getIdentifier) 15 | export(getIdentifiers) 16 | export(getMember) 17 | export(getRelationships) 18 | export(getSize) 19 | export(getTriples) 20 | export(getValue) 21 | export(hasAccessRule) 22 | export(insertRelationship) 23 | export(parseRDF) 24 | export(parseSystemMetadata) 25 | export(plotRelationships) 26 | export(recordDerivation) 27 | export(removeAccessRule) 28 | export(removeMember) 29 | export(removeRelationships) 30 | export(replaceMember) 31 | export(selectMember) 32 | export(serializePackage) 33 | export(serializeRDF) 34 | export(serializeSystemMetadata) 35 | export(serializeToBagIt) 36 | export(setPublicAccess) 37 | export(setValue) 38 | export(updateMetadata) 39 | export(updateRelationships) 40 | export(updateXML) 41 | export(validate) 42 | exportClasses(DataObject) 43 | exportClasses(DataPackage) 44 | exportClasses(ResourceMap) 45 | exportClasses(SystemMetadata) 46 | exportMethods(SystemMetadata) 47 | exportMethods(addAccessRule) 48 | exportMethods(addData) 49 | exportMethods(addMember) 50 | exportMethods(canRead) 51 | exportMethods(clearAccessPolicy) 52 | exportMethods(containsId) 53 | exportMethods(createFromTriples) 54 | exportMethods(describeWorkflow) 55 | exportMethods(getData) 56 | exportMethods(getIdentifiers) 57 | exportMethods(getMember) 58 | exportMethods(getRelationships) 59 | exportMethods(getSize) 60 | exportMethods(getTriples) 61 | exportMethods(getValue) 62 | exportMethods(initialize) 63 | exportMethods(insertRelationship) 64 | exportMethods(plotRelationships) 65 | exportMethods(removeAccessRule) 66 | exportMethods(removeMember) 67 | exportMethods(removeRelationships) 68 | exportMethods(replaceMember) 69 | exportMethods(selectMember) 70 | exportMethods(serializePackage) 71 | exportMethods(setValue) 72 | exportMethods(updateMetadata) 73 | exportMethods(updateRelationships) 74 | exportMethods(updateXML) 75 | import(XML) 76 | import(digest) 77 | import(methods) 78 | import(redland) 79 | import(uuid) 80 | importFrom(graphics,legend) 81 | importFrom(graphics,plot) 82 | importFrom(zip,zip) 83 | -------------------------------------------------------------------------------- /inst/extdata/pkg-example/logit-regression-example.R: -------------------------------------------------------------------------------- 1 | # Logistic regression, also called a logit model, is used to model dichotomous outcome variables. 2 | # In the logit model the log odds of the outcome is modeled as a linear combination of the predictor variables. 3 | 4 | library(aod) 5 | library(ggplot2) 6 | library(Rcpp) 7 | 8 | # Example 1. Suppose that we are interested in the factors that influence whether a political candidate wins an election. The outcome (response) variable is binary (0/1); win or lose. The predictor variables of interest are the amount of money spent on the campaign, the amount of time spent campaigning negatively and whether or not the candidate is an incumbent. 9 | # Example 2. A researcher is interested in how variables, such as GRE (Graduate Record Exam scores), GPA (grade point average) and prestige of the undergraduate institution, 10 | # effect admission into graduate school. The response variable, admit/don't admit, is a binary variable. 11 | # Description of the data 12 | # For our data analysis below, we are going to expand on Example 2 about getting into graduate school. 13 | # We have generated hypothetical data, which can be obtained from our website from within R. 14 | # Note that R requires forward slashes (/) not back slashes (\) when specifying a file location even if the file is on your hard drive. 15 | 16 | mydata <- read.csv(system.file("./extdata/pkg-example/binary.csv", package="datapack")) 17 | 18 | mydata$rank <- factor(mydata$rank) 19 | mylogit <- glm(admit ~ gre + gpa + rank, data = mydata, family = "binomial") 20 | newdata1 <- with(mydata, data.frame(gre = mean(gre), gpa = mean(gpa), rank = factor(1:4))) 21 | newdata1$rankP <- predict(mylogit, newdata = newdata1, type = "response") 22 | newdata2 <- with(mydata, data.frame(gre = rep(seq(from = 200, to = 800, length.out = 100), 4), gpa = mean(gpa), rank = factor(rep(1:4, each = 100)))) 23 | newdata3 <- cbind(newdata2, predict(mylogit, newdata = newdata2, type="link", se=TRUE)) 24 | newdata3 <- within(newdata3, { 25 | PredictedProb <- plogis(fit) 26 | LL <- plogis(fit - (1.96 * se.fit)) 27 | UL <- plogis(fit + (1.96 * se.fit)) 28 | }) 29 | 30 | # Plot the predicted probability for gre 31 | ggplot(newdata3, aes(x = gre, y = PredictedProb)) + 32 | geom_ribbon(aes(ymin = LL, ymax = UL, fill = rank), alpha = .2) + 33 | geom_line(aes(colour = rank), size=1) 34 | 35 | # Write the plot out 36 | ggsave(sprintf("%s/gre-predicted.png", tempdir())) 37 | -------------------------------------------------------------------------------- /man/updateMetadata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{updateMetadata} 4 | \alias{updateMetadata} 5 | \alias{updateMetadata,DataPackage-method} 6 | \title{Update selected elements of the XML content of a DataObject in a DataPackage (aka package member)} 7 | \usage{ 8 | updateMetadata(x, do, ...) 9 | 10 | \S4method{updateMetadata}{DataPackage}(x, do, xpath, replacement, newId = NA_character_, ...) 11 | } 12 | \arguments{ 13 | \item{x}{a DataPackage instance} 14 | 15 | \item{do}{A DataObject instance object, or DataObject identifier} 16 | 17 | \item{...}{(Not yet used)} 18 | 19 | \item{xpath}{A \code{character} value specifying the location in the XML to update.} 20 | 21 | \item{replacement}{A \code{character} value that will replace the elements found with the \code{xpath}.} 22 | 23 | \item{newId}{A value of type \code{"character"} which will replace the identifier for this DataObject.} 24 | } 25 | \description{ 26 | A DataObject that contains an XML document can be edited by specifying a path 27 | to the elements to edit (an XPath expression) and a value to replace the text node. 28 | } 29 | \details{ 30 | This method requires some knowledge of the structure of the metadata document as well 31 | as facility with the XPath language. If the \code{newId} argument is used, the specified new 32 | identifier will be assigned to the object, and the previous identifier will be stored in the \code{oldId} slot, 33 | for possible use when updating the DataObject to a repository. If \code{newId} is not used, a new 34 | identifier will be generated for the DataObject only the first time that updateMetadata is called for 35 | a particular object in a DataPackage. 36 | } 37 | \examples{ 38 | # Create a DataObject and add it to the DataPackage 39 | dp <- new("DataPackage") 40 | sampleMeta <- system.file("./extdata/sample-eml.xml", package="datapack") 41 | id <- "1234" 42 | metaObj <- new("DataObject", id="1234", format="eml://ecoinformatics.org/eml-2.1.1", 43 | file=sampleMeta) 44 | dp <- addMember(dp, metaObj) 45 | 46 | # In the metadata object, insert the newly assigned data 47 | xp <- sprintf("//dataTable/physical/distribution[../objectName/text()=\"\%s\"]/online/url", 48 | "sample-data.csv") 49 | newURL <- sprintf("https://cn.dataone.org/cn/v2/resolve/\%s", "1234") 50 | dp <- updateMetadata(dp, id, xpath=xp, replacement=newURL) 51 | } 52 | \seealso{ 53 | \code{\link{DataPackage-class}} 54 | } 55 | -------------------------------------------------------------------------------- /man/clearAccessPolicy.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/SystemMetadata.R, R/DataObject.R, 3 | % R/DataPackage.R 4 | \name{clearAccessPolicy} 5 | \alias{clearAccessPolicy} 6 | \alias{clearAccessPolicy,SystemMetadata-method} 7 | \alias{clearAccessPolicy,DataObject-method} 8 | \alias{clearAccessPolicy,DataPackage-method} 9 | \title{Clear the accessPolicy from the specified object} 10 | \usage{ 11 | clearAccessPolicy(x, ...) 12 | 13 | \S4method{clearAccessPolicy}{SystemMetadata}(x, ...) 14 | 15 | \S4method{clearAccessPolicy}{DataObject}(x, ...) 16 | 17 | \S4method{clearAccessPolicy}{DataPackage}(x, identifiers = list(), ...) 18 | } 19 | \arguments{ 20 | \item{x}{the instance to clear access rules from.} 21 | 22 | \item{...}{(Additional parameters)} 23 | 24 | \item{identifiers}{A list of \code{character} values containing package member identifiers that the access rule will be applied to.} 25 | } 26 | \value{ 27 | The SystemMetadata object with the cleared access policy. 28 | 29 | The DataObject with the cleared access policy. 30 | 31 | The SystemMetadata object with the cleared access policy. 32 | } 33 | \description{ 34 | Clears the accessPolicy from the specified object by overwriting 35 | all existing access rules set on the object with an empty set. 36 | } 37 | \examples{ 38 | # Clear access policy for a SystemMetadata object. 39 | sysmeta <- new("SystemMetadata") 40 | sysmeta <- addAccessRule(sysmeta, "uid=smith,ou=Account,dc=example,dc=com", "write") 41 | sysmeta <- clearAccessPolicy(sysmeta) 42 | # Clear access policy for a DataObject 43 | do <- new("DataObject", format="text/csv", filename=system.file("extdata/sample-data.csv", 44 | package="datapack")) 45 | do <- addAccessRule(do, "uid=smith,ou=Account,dc=example,dc=com", "write") 46 | do <- clearAccessPolicy(do) 47 | # Clear access policy for a DataPackage 48 | dp <- new("DataPackage") 49 | data <- charToRaw("1,2,3\n4,5,6\n") 50 | obj <- new("DataObject", dataobj=data, format="text/csv") 51 | dp <- addMember(dp, obj) 52 | data2 <- charToRaw("7,8,9\n4,10,11\n") 53 | obj2 <- new("DataObject", dataobj=data2, format="text/csv") 54 | dp <- addMember(dp, obj2) 55 | 56 | # Add the access rule to all package members 57 | dp <- addAccessRule(dp, "uid=smith,ou=Account,dc=example,dc=com", 58 | permission="write") 59 | # Now clear the access policy for just the second object 60 | dp <- clearAccessPolicy(dp, getIdentifier(obj2)) 61 | 62 | } 63 | \seealso{ 64 | \code{\link{SystemMetadata-class}} 65 | 66 | \code{\link{DataObject-class}} 67 | 68 | \code{\link{DataPackage-class}} 69 | } 70 | -------------------------------------------------------------------------------- /man/selectMember.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{selectMember} 4 | \alias{selectMember} 5 | \alias{selectMember,DataPackage-method} 6 | \title{Return identifiers for objects that match search criteria} 7 | \usage{ 8 | selectMember(x, ...) 9 | 10 | \S4method{selectMember}{DataPackage}(x, name, value, as = "character") 11 | } 12 | \arguments{ 13 | \item{x}{A DataPackage instance} 14 | 15 | \item{...}{(Not yet used)} 16 | 17 | \item{name}{The name of the DataObject slot to inspect, for example "sysmeta@formatId".} 18 | 19 | \item{value}{A character or logical value to match. If specified as a character value, PERL style regular expressions can be used (see ?grepl).} 20 | 21 | \item{as}{A character value to specify the return type, either "DataObject" or "character" (the default)} 22 | } 23 | \value{ 24 | A list of matching DataObjects or DataObject identifiers. The default is to return a list of 25 | DataObject identifiers. 26 | } 27 | \description{ 28 | Return DataObjects or DataObject identifiers that match search terms. 29 | } 30 | \details{ 31 | The \code{"selectMember"} method inspects the DataObject slot \code{"name"} for a match with \code{"value"} 32 | for each DataObject in a DataPackage. Matching DataObjects are returned as a list containing either package member 33 | identifiers (character) or the DataObjects themselves, depending on the value of the \code{as} parameter. 34 | } 35 | \examples{ 36 | #' library(datapack) 37 | dp <- new("DataPackage") 38 | # Add the script to the DataPackage 39 | progFile <- system.file("./extdata/pkg-example/logit-regression-example.R", package="datapack") 40 | # An 'id' parameter is not specified, so one will be generated automatically. 41 | progObj <- new("DataObject", format="application/R", filename=progFile) 42 | dp <- addMember(dp, progObj) 43 | 44 | # Add a script input to the DataPackage 45 | inFile <- system.file("./extdata/pkg-example/binary.csv", package="datapack") 46 | inObj <- new("DataObject", format="text/csv", filename=inFile) 47 | dp <- addMember(dp, inObj) 48 | 49 | # Add a script output to the DataPackage 50 | outFile <- system.file("./extdata/pkg-example/gre-predicted.png", package="datapack") 51 | outObj <- new("DataObject", format="image/png", file=outFile) 52 | dp <- addMember(dp, outObj) 53 | 54 | # Now determine the package member identifier for the R script 55 | progIds <- selectMember(dp, name="sysmeta@formatId", value="application/R", as="character") 56 | inputId <- selectMember(dp, name="sysmeta@fileName", value="binary.csv") 57 | } 58 | \seealso{ 59 | \code{\link{DataPackage-class}} 60 | } 61 | -------------------------------------------------------------------------------- /man/setValue.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{setValue} 4 | \alias{setValue} 5 | \alias{setValue,DataPackage-method} 6 | \title{Set values for selected DataPackage members} 7 | \usage{ 8 | setValue(x, ...) 9 | 10 | \S4method{setValue}{DataPackage}(x, name, value, identifiers = NA_character_, ...) 11 | } 12 | \arguments{ 13 | \item{x}{A DataPackage instance} 14 | 15 | \item{...}{(Not yet used)} 16 | 17 | \item{name}{A DataObject slot name.} 18 | 19 | \item{value}{A new value to assign to the slot for selected DataPackage members.} 20 | 21 | \item{identifiers}{A list of identifiers of DataPackage members to update.} 22 | } 23 | \value{ 24 | A DataPackage with possibly updated DataObjects. 25 | } 26 | \description{ 27 | The \code{'setValue'} method is used to modify values stored in DataPackage members. 28 | Each member in a DataPackage is a DataObject which is an R S4 object that contains a set of values (slots). 29 | The available slots are described at \code{help("DataObject-class")}. 30 | } 31 | \details{ 32 | If the parameter \code{identifiers} is provided, then DataPackage members that 33 | have identifiers specified in the list will be updated. If this parameter is not provided 34 | then no members will be updated. To update all members in a package, specify the 35 | value of \code{identifiers=getIdentifiers(pkg)} where \code{pkg} is the variable name 36 | of the DataPackage to update. Note that this method can be used to update the 37 | \code{data} or \code{filenane} slots, but it is instead recommended to us the 38 | \code{replaceMember} method to achieve this, as the \code{replaceMember} method assists 39 | in properly setting the related SystemMetadata values. 40 | } 41 | \examples{ 42 | # First create a package that we can modify. 43 | dp <- new("DataPackage") 44 | data <- charToRaw("1,2,3\n4,5,6") 45 | # The next statment sets the format type incorrectly as an example, so we can correct it later 46 | do <- new("DataObject", id="myNewId", dataobj=data, format="image/jpg", user="jsmith") 47 | dp <- addMember(dp, do) 48 | data <- charToRaw("7,8.9\n4,10,11") 49 | # This next statement also sets the format type incorrectly 50 | do <- new("DataObject", id="myNewId2", dataobj=data, format="image/jpg", user="jsmith") 51 | dp <- addMember(dp, do) 52 | # Change format types to correct value for both package members 53 | # Careful! Specifying 'identifiers=getIdentifiers(dp) will update all package members! 54 | dp <- setValue(dp, name="sysmeta@formatId", value="text/csv", identifiers=getIdentifiers(dp)) 55 | } 56 | \seealso{ 57 | \code{\link{DataPackage-class}} 58 | } 59 | -------------------------------------------------------------------------------- /man/createFromTriples.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ResourceMap.R 3 | \name{createFromTriples} 4 | \alias{createFromTriples} 5 | \alias{createFromTriples,ResourceMap-method} 6 | \title{Populate a ResourceMap with RDF relationships from data.frame} 7 | \usage{ 8 | createFromTriples(x, ...) 9 | 10 | \S4method{createFromTriples}{ResourceMap}( 11 | x, 12 | relations, 13 | identifiers, 14 | resolveURI = NA_character_, 15 | externalIdentifiers = list(), 16 | creator = NA_character_, 17 | ... 18 | ) 19 | } 20 | \arguments{ 21 | \item{x}{a ResourceMap} 22 | 23 | \item{...}{(Additional parameters)} 24 | 25 | \item{relations}{A data.frame to read relationships from} 26 | 27 | \item{identifiers}{A list of the identifiers of data objects contained in the associated data package} 28 | 29 | \item{resolveURI}{A character string containing a URI to prepend to datapackage identifiers.} 30 | 31 | \item{externalIdentifiers}{A list of identifiers that are referenced from the package, but are not package members.} 32 | 33 | \item{creator}{A \code{character} string containing the creator of the package.} 34 | } 35 | \description{ 36 | RDF relationships are added to a ResourceMap object from a data.frame that 37 | contains RDF triples. For example, relationships can be exported from a DataPackage via 38 | \code{\link{getRelationships}}. The resulting data.frame is then read by \code{createFromTriples} 39 | to create the ResourceMap. 40 | } 41 | \details{ 42 | The \code{identifiers} parameter contains the identifiers of all data objects in the DataPackage. 43 | For each data objects, additional relationships will be added that are required by the OAI-ORE specification, 44 | for example a Dublin Core identifier statement is added. The resolveURI string value is prepended to 45 | DataPackage member identifiers in the resulting resource map. If no resolveURI value 46 | is specified, then 'https://cn.dataone.org/cn/v1/resolve' is used. 47 | } 48 | \examples{ 49 | library(datapack) 50 | dp <- new("DataPackage") 51 | data <- charToRaw("1,2,3\n4,5,6") 52 | do1 <- new("DataObject", id="id1", data, format="text/csv") 53 | do2 <- new("DataObject", id="id2", data, format="text/csv") 54 | dp <- addMember(dp, do1) 55 | dp <- addMember(dp, do2) 56 | dp <- insertRelationship(dp, subjectID="id1", objectIDs="id2", 57 | predicate="http://www.w3.org/ns/prov#wasDerivedFrom") 58 | relations <- getRelationships(dp) 59 | resMapId <- sprintf("\%s\%s", "resourceMap_", uuid::UUIDgenerate()) 60 | resMap <- new("ResourceMap", id=resMapId) 61 | resMap <- createFromTriples(resMap, relations, getIdentifiers(dp)) 62 | } 63 | \seealso{ 64 | \code{\link{ResourceMap-class}} 65 | } 66 | -------------------------------------------------------------------------------- /man/removeRelationships.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{removeRelationships} 4 | \alias{removeRelationships} 5 | \alias{removeRelationships,DataPackage-method} 6 | \title{Remove relationships of objects in a DataPackage} 7 | \usage{ 8 | removeRelationships(x, ...) 9 | 10 | \S4method{removeRelationships}{DataPackage}(x, subjectID = NA_character_, predicate = NA_character_) 11 | } 12 | \arguments{ 13 | \item{x}{A DataPackage object} 14 | 15 | \item{...}{(Additional parameters)} 16 | 17 | \item{subjectID}{The identifier of the subject of the relationships to be removed} 18 | 19 | \item{predicate}{The identifier of the predicate of the relationships to be removed} 20 | } 21 | \value{ 22 | the updated DataPackage object 23 | } 24 | \description{ 25 | Use this function to remove all or a subset of the relationships that have previously been added in a data package. 26 | } 27 | \details{ 28 | Remove a relationship of the form "subject -> predicate -> object", as defined by the Resource Description Framework (RDF), i.e. 29 | an RDF triple. If neither subjectID nor predicate are provided, then all relationships are removed. If one or both 30 | are provided, they are used to select matching triples to be removed. 31 | Note: This method updates the passed-in DataPackage object. 32 | } 33 | \examples{ 34 | dp <- new("DataPackage") 35 | # Create a relationship 36 | dp <- insertRelationship(dp, "/Users/smith/scripts/genFields.R", 37 | "https://knb.org/data_20030812.40.1", 38 | "http://www.w3.org/ns/prov#used") 39 | # Create a relationshp with the subject as a blank node with an automatically assigned blank 40 | # node id 41 | dp <- insertRelationship(dp, subjectID=NA_character_, objectIDs="thing6", 42 | predicate="http://myns.org/wasThing") 43 | # Create a relationshp with the subject as a blank node with a user assigned blank node id 44 | dp <- insertRelationship(dp, subjectID="urn:uuid:bc9e160e-ca21-47d5-871b-4a4820fe4451", 45 | objectIDs="thing7", predicate="http://myns.org/hadThing") 46 | # Create multiple relationships with the same subject, predicate, but different objects 47 | dp <- insertRelationship(dp, subjectID="https://myns.org/subject1", 48 | objectIDs=c("thing4", "thing5"), predicate="http://myns.org/hadThing") 49 | # Create multiple relationships with subject and object types specified 50 | dp <- insertRelationship(dp, subjectID="orcid.org/0000-0002-2192-403X", 51 | objectIDs="http://www.example.com/home", predicate="http://myns.org/hadHome", 52 | subjectType="uri", objectType="literal") 53 | nrow(getRelationships(dp)) 54 | dp <- removeRelationships(dp, predicate='http://myns.org/wasThing') 55 | nrow(getRelationships(dp)) 56 | dp <- removeRelationships(dp, subjectID='orcid.org/0000-0002-2192-403X') 57 | nrow(getRelationships(dp)) 58 | dp <- removeRelationships(dp, subjectID='https://myns.org/subject1', 59 | predicate='http://myns.org/hadThing') 60 | nrow(getRelationships(dp)) 61 | dp <- removeRelationships(dp) 62 | nrow(getRelationships(dp)) 63 | } 64 | \seealso{ 65 | \code{\link{DataPackage-class}} 66 | } 67 | -------------------------------------------------------------------------------- /man/replaceMember.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{replaceMember} 4 | \alias{replaceMember} 5 | \alias{replaceMember,DataPackage-method} 6 | \title{Replace the raw data or file associated with a DataObject} 7 | \usage{ 8 | replaceMember(x, do, ...) 9 | 10 | \S4method{replaceMember}{DataPackage}( 11 | x, 12 | do, 13 | replacement, 14 | formatId = NA_character_, 15 | mediaType = NA_character_, 16 | mediaTypeProperty = NA_character_, 17 | newId = NA_character_, 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{x}{A DataPackage instance} 23 | 24 | \item{do}{A DataObject instance} 25 | 26 | \item{...}{(Not yet used)} 27 | 28 | \item{replacement}{A \code{raw} object or \code{character} (for filename) that will replace the current value in the DataObject \code{do}.} 29 | 30 | \item{formatId}{A value of type \code{"character"}, the DataONE object format for the object.} 31 | 32 | \item{mediaType}{A value of type \code{"character"}, the IANA Media Type (aka MIME-Type) of the object, e.g. "text/csv".} 33 | 34 | \item{mediaTypeProperty}{A value of type \code{"list"} of \code{"character"}, IANA Media Type properties for the \code{"mediaType"} argument.} 35 | 36 | \item{newId}{A value of type \code{"character"} which will replace the identifier for this DataObject.} 37 | } 38 | \description{ 39 | A DataObject is a container for data that can be either an R raw object or 40 | a file on local disk. The \code{replaceMember} method can be used to update the 41 | date that a DataObject contains, for a DataObject that is a member of a DataPackage, 42 | substituting a new file or raw object in the specified DataObject. 43 | } 44 | \details{ 45 | The data that is replacing the existing DataObject data may be of a different 46 | format or type than the existing data. Because the data type and format may change, the 47 | system metadata that describes the data can be updated as well. The \code{replaceMember} 48 | method will update the SystemMetadata \code{size}, \code{checksum} values automatically, 49 | but does not update the \code{formatId}, \code{mediaType}, \code{mediaTypeProperty} 50 | unless requested, so these should be specified in the call to \code{replaceMember} if necessary. 51 | If the \code{newId} argument is used, the specified new identifier will be assigned to the 52 | object, otherwise one will be generated if necessary. This new identifier will be used 53 | if the DataPackage is uploaded to DataONE, and this object is updating an existing object in DataONE. 54 | } 55 | \examples{ 56 | # Create a DataObject and add it to the DataPackage 57 | dp <- new("DataPackage") 58 | doIn <- new("DataObject", format="text/csv", 59 | filename=system.file("./extdata/pkg-example/binary.csv", package="datapack")) 60 | dp <- addMember(dp, doIn) 61 | 62 | # Use the zipped version of the file instead by updating the DataObject 63 | dp <- replaceMember(dp, doIn, 64 | replacement=system.file("./extdata/pkg-example/binary.csv.zip", 65 | package="datapack"), 66 | formatId="application/zip") 67 | } 68 | \seealso{ 69 | \code{\link{DataPackage-class}} 70 | } 71 | -------------------------------------------------------------------------------- /R/datapack-package.r: -------------------------------------------------------------------------------- 1 | #' datapack, a container for packages of data and associated metadata 2 | #' 3 | #' @name datapack 4 | #' @author Matthew B. Jones (NCEAS), Peter Slaughter (NCEAS) 5 | #' @description The datapack R package provides an abstraction for collating 6 | #' heterogeneous collections of data objects and metadata into a bundle that can 7 | #' be transported and loaded into a single composite file. The methods in 8 | #' this package provide a convenient way 9 | #' to load data from common repositories such as DataONE into the R environment, 10 | #' and to document, serialize, and save data from R to data repositories worldwide. 11 | #' A data package is represented as an instance of the S4 class \code{\link[=DataPackage-class]{DataPackage}}, which 12 | #' consists of one or more instances of the S4 DataObject class, which in turn contains 13 | #' an instance of the S4 SystemMetadata class. The SystemMetadata 14 | #' class provides critical metadata about a data object that is needed to transport 15 | #' it to an external repository, including the identifier for the object, its 16 | #' format, its checksum and size, and information about which repositories the 17 | #' data is associated with. DataPackages can be loaded from and saved to the 18 | #' DataONE federated network of repositories using the dataone package, but they 19 | #' can also be used as standalone transport containers for other systems. 20 | #' 21 | #' A DataPackage includes a manifest based on the OAI-ORE 22 | #' specification for describing aggregations of files as a ResourceMap. 23 | #' Resource maps are RDF documents that conform to the Open Archives Initiative 24 | #' Object Reuse and Exchange (OAI-ORE) specification. Resource maps are generated 25 | #' by data providers to define data packages, and have a namespace of 26 | #' http://www.openarchives.org/ore/terms/. 27 | #' 28 | #' A DataPackage is serialized as a zip file following the BagIt RFC specification, 29 | #' which provides a consistent mechanism for a serialized representation of a 30 | #' group of opaque objects in a predictable structure. BagIt includes a 31 | #' specification for including metadata about each of the objects, the bag itself, 32 | #' and fixity attributes so that any BagIt implementation can validate the 33 | #' components contained within a package. When expanded, a BagIt zipfile will 34 | #' expand to a common directory structure with a predictable set of metadata that 35 | #' describes the structure and content of the bag. Conformance with the BagIt 36 | #' specification is handled by the DataPackage class. 37 | #' @aliases datapack 38 | #' @section Classes: 39 | #' \describe{ 40 | #' \item{\code{\link{DataPackage-class}}}{: A class representing a data package, which can contain data objects} 41 | #' \item{\code{\link{DataObject-class}}}{: DataObject wraps raw data with system-level metadata} 42 | #' \item{\code{\link{SystemMetadata-class}{SystemMetadata}}}{: A DataONE SystemMetadata object containing basic identification, ownership, access policy, replication policy, and related metadata.} 43 | #' \item{\code{\link{ResourceMap-class}{ResourceMap}}}{: ResourceMap provides methods to create, serialize and deserialize an OAI ORE resource map.} 44 | #' } 45 | #' @keywords internal 46 | "_PACKAGE" 47 | 48 | ## usethis namespace: start 49 | ## usethis namespace: end 50 | NULL 51 | -------------------------------------------------------------------------------- /.github/workflows/rhub.yaml: -------------------------------------------------------------------------------- 1 | # R-hub's generic GitHub Actions workflow file. It's canonical location is at 2 | # https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml 3 | # You can update this file to a newer version using the rhub2 package: 4 | # 5 | # rhub::rhub_setup() 6 | # 7 | # It is unlikely that you need to modify this file manually. 8 | 9 | name: R-hub 10 | run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}" 11 | 12 | on: 13 | workflow_dispatch: 14 | inputs: 15 | config: 16 | description: 'A comma separated list of R-hub platforms to use.' 17 | type: string 18 | default: 'linux,windows,macos' 19 | name: 20 | description: 'Run name. You can leave this empty now.' 21 | type: string 22 | id: 23 | description: 'Unique ID. You can leave this empty now.' 24 | type: string 25 | 26 | jobs: 27 | 28 | setup: 29 | runs-on: ubuntu-latest 30 | outputs: 31 | containers: ${{ steps.rhub-setup.outputs.containers }} 32 | platforms: ${{ steps.rhub-setup.outputs.platforms }} 33 | 34 | steps: 35 | # NO NEED TO CHECKOUT HERE 36 | - uses: r-hub/actions/setup@v1 37 | with: 38 | config: ${{ github.event.inputs.config }} 39 | id: rhub-setup 40 | 41 | linux-containers: 42 | needs: setup 43 | if: ${{ needs.setup.outputs.containers != '[]' }} 44 | runs-on: ubuntu-latest 45 | name: ${{ matrix.config.label }} 46 | strategy: 47 | fail-fast: false 48 | matrix: 49 | config: ${{ fromJson(needs.setup.outputs.containers) }} 50 | container: 51 | image: ${{ matrix.config.container }} 52 | 53 | steps: 54 | - uses: r-hub/actions/checkout@v1 55 | - uses: r-hub/actions/platform-info@v1 56 | with: 57 | token: ${{ secrets.RHUB_TOKEN }} 58 | job-config: ${{ matrix.config.job-config }} 59 | - uses: r-hub/actions/setup-deps@v1 60 | with: 61 | token: ${{ secrets.RHUB_TOKEN }} 62 | job-config: ${{ matrix.config.job-config }} 63 | - uses: r-hub/actions/run-check@v1 64 | with: 65 | token: ${{ secrets.RHUB_TOKEN }} 66 | job-config: ${{ matrix.config.job-config }} 67 | 68 | other-platforms: 69 | needs: setup 70 | if: ${{ needs.setup.outputs.platforms != '[]' }} 71 | runs-on: ${{ matrix.config.os }} 72 | name: ${{ matrix.config.label }} 73 | strategy: 74 | fail-fast: false 75 | matrix: 76 | config: ${{ fromJson(needs.setup.outputs.platforms) }} 77 | 78 | steps: 79 | - uses: r-hub/actions/checkout@v1 80 | - uses: r-hub/actions/setup-r@v1 81 | with: 82 | job-config: ${{ matrix.config.job-config }} 83 | token: ${{ secrets.RHUB_TOKEN }} 84 | - uses: r-hub/actions/platform-info@v1 85 | with: 86 | token: ${{ secrets.RHUB_TOKEN }} 87 | job-config: ${{ matrix.config.job-config }} 88 | - uses: r-hub/actions/setup-deps@v1 89 | with: 90 | job-config: ${{ matrix.config.job-config }} 91 | token: ${{ secrets.RHUB_TOKEN }} 92 | - uses: r-hub/actions/run-check@v1 93 | with: 94 | job-config: ${{ matrix.config.job-config }} 95 | token: ${{ secrets.RHUB_TOKEN }} 96 | -------------------------------------------------------------------------------- /man/serializePackage.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{serializePackage} 4 | \alias{serializePackage} 5 | \alias{serializePackage,DataPackage-method} 6 | \title{Create an OAI-ORE resource map from the package} 7 | \usage{ 8 | serializePackage(x, ...) 9 | 10 | \S4method{serializePackage}{DataPackage}( 11 | x, 12 | file, 13 | id = NA_character_, 14 | syntaxName = "rdfxml", 15 | mimeType = "application/rdf+xml", 16 | namespaces = data.frame(namespace = character(), prefix = character(), stringsAsFactors 17 | = FALSE), 18 | syntaxURI = NA_character_, 19 | resolveURI = NA_character_, 20 | creator = NA_character_ 21 | ) 22 | } 23 | \arguments{ 24 | \item{x}{A DataPackage object} 25 | 26 | \item{...}{Additional arguments} 27 | 28 | \item{file}{The file to which the ResourceMap will be serialized} 29 | 30 | \item{id}{A unique identifier for the serialization. The default value is the id assigned 31 | to the DataPackage when it was created.} 32 | 33 | \item{syntaxName}{The name of the syntax to use for serialization - default is "rdfxml"} 34 | 35 | \item{mimeType}{The mimetype of the serialized output - the default is "application/rdf+xml"} 36 | 37 | \item{namespaces}{A data frame containing one or more namespaces and their associated prefix} 38 | 39 | \item{syntaxURI}{URI of the serialization syntax} 40 | 41 | \item{resolveURI}{A character string containing a URI to prepend to datapackage identifiers} 42 | 43 | \item{creator}{A \code{character} string containing the creator of the package.} 44 | } 45 | \description{ 46 | The DataPackage is serialized as a OAI-ORE resource map to the specified file. 47 | } 48 | \details{ 49 | The resource map that is created is serialized by default as RDF/XML. Other serialization formats 50 | can be specified using the \code{syntaxName} and \code{mimeType} parameters. Other available formats 51 | include: 52 | \tabular{ll}{ 53 | \strong{syntaxName}\tab \strong{mimeType}\cr 54 | json\tab application/json\cr 55 | ntriples\tab application/n-triples\cr 56 | turtle\tab text/turtle\cr 57 | dot\tab text/x-graphviz\cr 58 | } 59 | Note that the \code{syntaxName} and \code{mimeType} arguments together specify o serialization format. 60 | 61 | Also, for packages that will be uploaded to the DataONE network, "rdfxml" is the only 62 | accepted format. 63 | 64 | The resolveURI string value is prepended to DataPackage member identifiers in the resulting resource map. 65 | If no resolveURI value is specified, then 'https://cn.dataone.org/cn/v1/resolve' is used. 66 | } 67 | \examples{ 68 | dp <- new("DataPackage") 69 | data <- charToRaw("1,2,3\n4,5,6") 70 | do <- new("DataObject", id="do1", dataobj=data, format="text/csv", user="jsmith") 71 | dp <- addMember(dp, do) 72 | data2 <- charToRaw("7,8,9\n10,11,12") 73 | do2 <- new("DataObject", id="do2", dataobj=data2, format="text/csv", user="jsmith") 74 | dp <- addMember(dp, do2) 75 | dp <- describeWorkflow(dp, sources=do, derivations=do2) 76 | \dontrun{ 77 | td <- tempdir() 78 | status <- serializePackage(dp, file=paste(td, "resmap.json", sep="/"), syntaxName="json", 79 | mimeType="application/json") 80 | status <- serializePackage(dp, file=paste(td, "resmap.xml", sep="/"), syntaxName="rdfxml", 81 | mimeType="application/rdf+xml") 82 | status <- serializePackage(dp, file=paste(td, "resmap.ttl", sep="/"), syntaxName="turtle", 83 | mimeType="text/turtle") 84 | } 85 | } 86 | \seealso{ 87 | \code{\link{DataPackage-class}} 88 | } 89 | -------------------------------------------------------------------------------- /man/datapack.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/datapack-package.r 3 | \docType{package} 4 | \name{datapack} 5 | \alias{datapack-package} 6 | \alias{datapack} 7 | \title{datapack, a container for packages of data and associated metadata} 8 | \description{ 9 | The datapack R package provides an abstraction for collating 10 | heterogeneous collections of data objects and metadata into a bundle that can 11 | be transported and loaded into a single composite file. The methods in 12 | this package provide a convenient way 13 | to load data from common repositories such as DataONE into the R environment, 14 | and to document, serialize, and save data from R to data repositories worldwide. 15 | A data package is represented as an instance of the S4 class \code{\link[=DataPackage-class]{DataPackage}}, which 16 | consists of one or more instances of the S4 DataObject class, which in turn contains 17 | an instance of the S4 SystemMetadata class. The SystemMetadata 18 | class provides critical metadata about a data object that is needed to transport 19 | it to an external repository, including the identifier for the object, its 20 | format, its checksum and size, and information about which repositories the 21 | data is associated with. DataPackages can be loaded from and saved to the 22 | DataONE federated network of repositories using the dataone package, but they 23 | can also be used as standalone transport containers for other systems. 24 | 25 | A DataPackage includes a manifest based on the OAI-ORE 26 | specification for describing aggregations of files as a ResourceMap. 27 | Resource maps are RDF documents that conform to the Open Archives Initiative 28 | Object Reuse and Exchange (OAI-ORE) specification. Resource maps are generated 29 | by data providers to define data packages, and have a namespace of 30 | http://www.openarchives.org/ore/terms/. 31 | 32 | A DataPackage is serialized as a zip file following the BagIt RFC specification, 33 | which provides a consistent mechanism for a serialized representation of a 34 | group of opaque objects in a predictable structure. BagIt includes a 35 | specification for including metadata about each of the objects, the bag itself, 36 | and fixity attributes so that any BagIt implementation can validate the 37 | components contained within a package. When expanded, a BagIt zipfile will 38 | expand to a common directory structure with a predictable set of metadata that 39 | describes the structure and content of the bag. Conformance with the BagIt 40 | specification is handled by the DataPackage class. 41 | } 42 | \section{Classes}{ 43 | 44 | \describe{ 45 | \item{\code{\link{DataPackage-class}}}{: A class representing a data package, which can contain data objects} 46 | \item{\code{\link{DataObject-class}}}{: DataObject wraps raw data with system-level metadata} 47 | \item{\code{\link{SystemMetadata-class}{SystemMetadata}}}{: A DataONE SystemMetadata object containing basic identification, ownership, access policy, replication policy, and related metadata.} 48 | \item{\code{\link{ResourceMap-class}{ResourceMap}}}{: ResourceMap provides methods to create, serialize and deserialize an OAI ORE resource map.} 49 | } 50 | } 51 | 52 | \seealso{ 53 | Useful links: 54 | \itemize{ 55 | \item \url{https://docs.ropensci.org/datapack/} 56 | \item \url{https://github.com/ropensci/datapack} 57 | \item Report bugs at \url{https://github.com/ropensci/datapack/issues} 58 | } 59 | 60 | } 61 | \author{ 62 | Matthew B. Jones (NCEAS), Peter Slaughter (NCEAS) 63 | } 64 | \keyword{internal} 65 | -------------------------------------------------------------------------------- /man/serializeToBagIt.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{serializeToBagIt} 4 | \alias{serializeToBagIt} 5 | \alias{serializeToBagIt,DataPackage-method} 6 | \title{Serialize A DataPackage into a BagIt Archive File} 7 | \usage{ 8 | serializeToBagIt(x, ...) 9 | 10 | \S4method{serializeToBagIt}{DataPackage}( 11 | x, 12 | mapId = NA_character_, 13 | syntaxName = NA_character_, 14 | namespaces = data.frame(), 15 | mimeType = NA_character_, 16 | syntaxURI = NA_character_, 17 | resolveURI = NA_character_, 18 | creator = NA_character_, 19 | ... 20 | ) 21 | } 22 | \arguments{ 23 | \item{x}{A DataPackage object} 24 | 25 | \item{...}{Additional arguments} 26 | 27 | \item{mapId}{A unique identifier for the package resource map. If not specified, one will be automatically generated.} 28 | 29 | \item{syntaxName}{The name of the syntax to use for the resource map serialization, defaults to "rdfxml"} 30 | 31 | \item{namespaces}{An optional data frame containing one or more namespaces and their associated prefix for the resource map serialization.} 32 | 33 | \item{mimeType}{The mimetype for the resource map serialization, defaults to "application/rdf+xml".} 34 | 35 | \item{syntaxURI}{An optional string specifying the URI for the resource map serialization.} 36 | 37 | \item{resolveURI}{A character string containing a URI to prepend to datapackage identifiers for the resource map.} 38 | 39 | \item{creator}{A \code{character} string containing the creator of the package.} 40 | } 41 | \value{ 42 | The file name that contains the BagIt zip archive. 43 | Recursively determines the name for a science metadata object. 44 | The base file name (eml, datacite, science-metadata, etc) should stay the same. 45 | Call the method with the base name and the number of existing files to start with. 46 | This is most likely 0. 47 | If there's a count defined, add it to the end of the file in () 48 | Then call the method again with count += 1 49 | Eventually a free file name will be found, and then the function returns that name 50 | } 51 | \description{ 52 | The BagIt packaging format \url{https://datatracker.ietf.org/doc/html/draft-kunze-bagit-08} 53 | is used to prepare an archive file that contains the contents of a DataPackage. 54 | } 55 | \details{ 56 | A BagIt Archive File is created by copying each member of a DataPackage, and preparing 57 | files that describe the files in the archive, including information about the size of the files 58 | and a checksum for each file. An OAI-ORE resource map is automatically created and added to the 59 | archive. These metadata files and the data files are then packaged into 60 | a single zip file. 61 | } 62 | \examples{ 63 | # Create the first data object 64 | dp <- new("DataPackage") 65 | data <- charToRaw("1,2,3,5,6") 66 | do <- new("DataObject", id="do1", dataobj=data, format="text/csv", user="jsmith") 67 | dp <- addMember(dp, do) 68 | # Create a second data object 69 | data2 <- charToRaw("7,8,9,4,10,11") 70 | do2 <- new("DataObject", id="do2", dataobj=data2, format="text/csv", user="jsmith") 71 | dp <- addMember(dp, do2) 72 | # Create a relationship between the two data objects 73 | dp <- describeWorkflow(dp, sources="do2", derivations="do2") 74 | # Write out the data package to a BagIt file 75 | \dontrun{ 76 | bagitFile <- serializeToBagIt(dp, syntaxName="json", mimeType="application/json") 77 | } 78 | } 79 | \seealso{ 80 | \code{\link{DataPackage-class}} 81 | 82 | For more information and examples regarding the parameters specifying the creation of the resource map, see \link{serializePackage}. 83 | } 84 | -------------------------------------------------------------------------------- /man/DataObject-initialize.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataObject.R 3 | \name{initialize,DataObject-method} 4 | \alias{initialize,DataObject-method} 5 | \alias{DataObject-initialize} 6 | \title{Initialize a DataObject} 7 | \usage{ 8 | \S4method{initialize}{DataObject}( 9 | .Object, 10 | id = NA_character_, 11 | dataobj = NA, 12 | format = NA_character_, 13 | user = NA_character_, 14 | mnNodeId = NA_character_, 15 | filename = NA_character_, 16 | seriesId = NA_character_, 17 | mediaType = NA_character_, 18 | mediaTypeProperty = list(), 19 | dataURL = NA_character_, 20 | targetPath = NA_character_, 21 | checksumAlgorithm = "SHA-256" 22 | ) 23 | } 24 | \arguments{ 25 | \item{.Object}{the DataObject instance to be initialized} 26 | 27 | \item{id}{the identifier for the DataObject, unique within its repository. Optionally this can be an existing SystemMetadata object} 28 | 29 | \item{dataobj}{the bytes of the data for this object in \code{'raw'} format, optional if \code{'filename'} is provided} 30 | 31 | \item{format}{the format identifier for the object, e.g."text/csv", "eml://ecoinformatics.org/eml-2.1.1"} 32 | 33 | \item{user}{the identity of the user owning the package, typically in X.509 format} 34 | 35 | \item{mnNodeId}{the node identifier for the repository to which this object belongs.} 36 | 37 | \item{filename}{the filename for the fully qualified path to the data on disk, optional if \code{'data'} is provided} 38 | 39 | \item{seriesId}{A unique string to identifier the latest of multiple revisions of the object.} 40 | 41 | \item{mediaType}{The When specified, indicates the IANA Media Type (aka MIME-Type) of the object. The value should include the media type and subtype (e.g. text/csv).} 42 | 43 | \item{mediaTypeProperty}{A list, indicates IANA Media Type properties to be associated with the parameter \code{"mediaType"}} 44 | 45 | \item{dataURL}{A character string containing a URL to remote data (a repository) that this DataObject represents.} 46 | 47 | \item{targetPath}{An optional string that denotes where the file should go in a downloaded package} 48 | 49 | \item{checksumAlgorithm}{A character string specifying the checksum algorithm to use} 50 | } 51 | \description{ 52 | When initializing a DataObject using passed in data, one can either pass 53 | in the \code{'id'} param as a \code{'SystemMetadata'} object, or as a \code{'character'} string 54 | representing the identifier for an object along with parameters for format, user,and associated member node. 55 | If \code{'data'} is not missing, the \code{'data'} param holds the \code{'raw'} data. Otherwise, the 56 | \code{'filename'} parameter must be provided, and points at a file containing the bytes of the data. 57 | } 58 | \details{ 59 | If filesystem storage is used for the data associated with a DataObject, care must be 60 | taken to not modify or remove that file in R or via other facilities while the DataObject exists in the R session. 61 | Changes to the object are not detected and will result in unexpected results. Also, if the \code{'dataobj'} parameter 62 | is used to specify the data source, then \code{'filename'} argument may also be specified, but in this case 63 | the value \code{'filename'} parameter is used to tell DataONE the filename to create when this file is 64 | downloaded from a repository. 65 | } 66 | \examples{ 67 | data <- charToRaw("1,2,3\n4,5,6\n") 68 | do <- new("DataObject", "id1", dataobj=data, "text/csv", 69 | "uid=jones,DC=example,DC=com", "urn:node:KNB", targetPath="data/rasters/data.tiff") 70 | } 71 | \seealso{ 72 | \code{\link{DataObject-class}} 73 | } 74 | -------------------------------------------------------------------------------- /man/addAccessRule.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/SystemMetadata.R, R/DataObject.R, 3 | % R/DataPackage.R 4 | \name{addAccessRule} 5 | \alias{addAccessRule} 6 | \alias{addAccessRule,SystemMetadata-method} 7 | \alias{addAccessRule,DataObject-method} 8 | \alias{addAccessRule,DataPackage-method} 9 | \title{Add access rules to the specified object} 10 | \usage{ 11 | addAccessRule(x, ...) 12 | 13 | \S4method{addAccessRule}{SystemMetadata}(x, y, ...) 14 | 15 | \S4method{addAccessRule}{DataObject}(x, y, ...) 16 | 17 | \S4method{addAccessRule}{DataPackage}(x, y, ...) 18 | } 19 | \arguments{ 20 | \item{x}{The object instance to which to add the rules} 21 | 22 | \item{...}{Additional arguments 23 | \itemize{ 24 | \item \code{permission}: The permission to be applied to subject if x is character (read, write, changePermission) 25 | }} 26 | 27 | \item{y}{The subject of the rule to be added, or a data frame of subject/permission tuples} 28 | } 29 | \value{ 30 | The SystemMetadata object with the updated access policy. 31 | 32 | The DataObject with the updated access policy 33 | 34 | The DataPackage with updated DataObject access policies 35 | } 36 | \description{ 37 | Add one or more access rules to the access policy of the specified object. 38 | } 39 | \details{ 40 | If the \code{y} argument is specified as a character string containing a \code{subject}, 41 | then an optional \code{permission} parameter must be specified, that contains a character list 42 | specifying the permissions to add for each \code{subject}. 43 | 44 | Note that when \code{addAccessRule} is called with a `DataPackage` argument, the 45 | additional parameter \code{identifiers} can be used: 46 | \itemize{ 47 | \item \code{identifiers}: A list of \code{character} values containing package member identifiers that the access rule will be applied to (all members is the default). 48 | } 49 | } 50 | \examples{ 51 | # Add an access rule to a SystemMetadata access policy. 52 | # Parameter "y" can be character string containing the subject of the access rule: 53 | sysmeta <- new("SystemMetadata") 54 | sysmeta <- addAccessRule(sysmeta, "uid=smith,ou=Account,dc=example,dc=com", "write") 55 | accessRules <- data.frame(subject=c("uid=smith,ou=Account,dc=example,dc=com", 56 | "uid=slaughter,o=unaffiliated,dc=example,dc=org"), permission=c("write", "changePermission")) 57 | sysmeta <- addAccessRule(sysmeta, accessRules) 58 | # Alternatively, parameter "y" can be a data.frame containing one or more access rules: 59 | sysmeta <- addAccessRule(sysmeta, "uid=smith,ou=Account,dc=example,dc=com", "write") 60 | accessRules <- data.frame(subject=c("uid=smith,ou=Account,dc=example,dc=com", 61 | "uid=slaughter,o=unaffiliated,dc=example,dc=org"), permission=c("write", "changePermission")) 62 | sysmeta <- addAccessRule(sysmeta, accessRules) 63 | # Add an access rule to a DataObject 64 | data <- charToRaw("1,2,3\n4,5,6\n") 65 | obj <- new("DataObject", id="1234", dataobj=data, format="text/csv") 66 | obj <- addAccessRule(obj, "uid=smith,ou=Account,dc=example,dc=com", "write") 67 | # Add an access rule to members of a DataPackage 68 | # First create a sample DataPackage 69 | dp <- new("DataPackage") 70 | data <- charToRaw("1,2,3\n4,5,6\n") 71 | obj <- new("DataObject", id="id1", dataobj=data, format="text/csv") 72 | dp <- addMember(dp, obj) 73 | data2 <- charToRaw("7,8,9\n4,10,11\n") 74 | obj2 <- new("DataObject", id="id2", dataobj=data2, format="text/csv") 75 | dp <- addMember(dp, obj2) 76 | # Add access rule to all package members 77 | dp <- addAccessRule(dp, "uid=smith,ou=Account,dc=example,dc=com", "write", getIdentifiers(dp)) 78 | } 79 | \seealso{ 80 | \code{\link{SystemMetadata-class}} 81 | 82 | \code{\link{DataObject-class}} 83 | 84 | \code{\link{DataPackage-class}} 85 | } 86 | -------------------------------------------------------------------------------- /man/insertRelationship.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{insertRelationship} 4 | \alias{insertRelationship} 5 | \alias{insertRelationship,DataPackage-method} 6 | \title{Record relationships of objects in a DataPackage} 7 | \usage{ 8 | insertRelationship(x, ...) 9 | 10 | \S4method{insertRelationship}{DataPackage}( 11 | x, 12 | subjectID, 13 | objectIDs, 14 | predicate = NA_character_, 15 | subjectType = NA_character_, 16 | objectTypes = NA_character_, 17 | dataTypeURIs = NA_character_ 18 | ) 19 | } 20 | \arguments{ 21 | \item{x}{A DataPackage object} 22 | 23 | \item{...}{(Additional parameters)} 24 | 25 | \item{subjectID}{The identifier of the subject of the relationship} 26 | 27 | \item{objectIDs}{A list of identifiers of the object of the relationships (a relationship is recorded for each objectID)} 28 | 29 | \item{predicate}{The IRI of the predicate of the relationship} 30 | 31 | \item{subjectType}{the type to assign the subject, values can be 'uri', 'blank'} 32 | 33 | \item{objectTypes}{the types to assign the objects (cal be single value or list), each value can be 'uri', 'blank', or 'literal'} 34 | 35 | \item{dataTypeURIs}{An RDF data type that specifies the type of the object} 36 | } 37 | \value{ 38 | the updated DataPackage object 39 | } 40 | \description{ 41 | Record a relationship of the form "subject -> predicate -> object", as defined by the Resource Description Framework (RDF), i.e. 42 | an RDF triple. 43 | } 44 | \details{ 45 | For use with DataONE, a best practice is to specify the subject and predicate as DataONE persistent identifiers 46 | (https://mule1.dataone.org/ArchitectureDocs-current/design/PIDs.html). If the objects are not known to DataONE, then local identifiers can be 47 | used, and these local identifiers may be promoted to DataONE PIDs when the package is uploaded to a DataONE member node. 48 | The predicate is typically an RDF property (as a IRI) from a schema supported by DataONE, i.e. "http://www.w3.org/ns/prov#wasGeneratedBy" 49 | If multiple values are specified for argument objectIDS, a relationship is created for each value in the list "objectIDs". IF a value 50 | is not specified for subjectType or objectType, then NA is assigned. Note that if these relationships are fetched via the getRelationships() 51 | function, and passed to the createFromTriples() function to initialize a ResourceMap object, the underlying redland package will assign 52 | appropriate values for subjects and objects. 53 | Note: This method updates the passed-in DataPackage object. 54 | } 55 | \examples{ 56 | dp <- new("DataPackage") 57 | # Create a relationship 58 | dp <- insertRelationship(dp, "/Users/smith/scripts/genFields.R", 59 | "https://knb.ecoinformatics.org/knb/d1/mn/v1/object/doi:1234/_030MXTI009R00_20030812.40.1", 60 | "http://www.w3.org/ns/prov#used") 61 | # Create a relationshp with the subject as a blank node with an automatically assigned blank 62 | # node id 63 | dp <- insertRelationship(dp, subjectID=NA_character_, objectIDs="thing6", 64 | predicate="http://www.myns.org/wasThing") 65 | # Create a relationshp with the subject as a blank node with a user assigned blank node id 66 | dp <- insertRelationship(dp, subjectID="urn:uuid:bc9e160e-ca21-47d5-871b-4a4820fe4451", 67 | objectIDs="thing7", predicate="http://www.myns.org/hadThing") 68 | # Create multiple relationships with the same subject, predicate, but different objects 69 | dp <- insertRelationship(dp, subjectID="urn:uuid:95055dc1-b2a0-4a00-bdc2-05c16d048ca2", 70 | objectIDs=c("thing4", "thing5"), predicate="http://www.myns.org/hadThing") 71 | # Create multiple relationships with subject and object types specified 72 | dp <- insertRelationship(dp, subjectID="orcid.org/0000-0002-2192-403X", 73 | objectIDs="http://www.example.com/home", predicate="http://www.example.com/hadHome", 74 | subjectType="uri", objectType="literal") 75 | } 76 | \seealso{ 77 | \code{\link{DataPackage-class}} 78 | } 79 | -------------------------------------------------------------------------------- /man/hasAccessRule.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/SystemMetadata.R, R/DataObject.R, 3 | % R/DataPackage.R 4 | \name{hasAccessRule} 5 | \alias{hasAccessRule} 6 | \alias{hasAccessRule,SystemMetadata-method} 7 | \alias{hasAccessRule,DataObject-method} 8 | \alias{hasAccessRule,DataPackage-method} 9 | \title{Determine if an access rules exists} 10 | \usage{ 11 | hasAccessRule(x, ...) 12 | 13 | \S4method{hasAccessRule}{SystemMetadata}(x, subject, permission) 14 | 15 | \S4method{hasAccessRule}{DataObject}(x, subject, permission) 16 | 17 | \S4method{hasAccessRule}{DataPackage}(x, subject, permission, identifiers = list(), ...) 18 | } 19 | \arguments{ 20 | \item{x}{the object to check for presence of the access rule.} 21 | 22 | \item{...}{Additional arguments} 23 | 24 | \item{subject}{of the rule to be checked} 25 | 26 | \item{permission}{the permission to be checked} 27 | 28 | \item{identifiers}{A list of \code{character} values containing package member identifiers for which the access rule will be checked.} 29 | } 30 | \value{ 31 | A logical value: if TRUE the access rule was found, if FALSE it was not found. 32 | 33 | When called for SystemMetadata, boolean TRUE if the access rule exists already, FALSE otherwise 34 | 35 | When called for a DataObject, boolean TRUE if the access rule exists already, FALSE otherwise 36 | 37 | When called for a DataPackage, boolean TRUE if the access rule exists in all specified package members already, FALSE otherwise 38 | } 39 | \description{ 40 | Each SystemMetadata document may contain a set of (subject, permission) tuples 41 | that represent the access rules for its associated object. This method determines 42 | whether a particular access rule already exists within the set. 43 | 44 | If called for a DataObject, then the SystemMetadata for the DataObject is checked. 45 | 46 | If called for a DataPackage, then the SystemMetadata for DataObjects in the DataPackage are checked. 47 | } 48 | \examples{ 49 | # 50 | # Check access rules for a SystemMetadata object. 51 | sysmeta <- new("SystemMetadata") 52 | sysmeta <- addAccessRule(sysmeta, "uid=smith,ou=Account,dc=example,dc=com", "write") 53 | accessRules <- data.frame(subject=c("uid=smith,ou=Account,dc=example,dc=com", 54 | "uid=slaughter,o=unaffiliated,dc=example,dc=org"), permission=c("write", "changePermission")) 55 | sysmeta <- addAccessRule(sysmeta, accessRules) 56 | ruleExists <- hasAccessRule(sysmeta, subject="uid=smith,ou=Account,dc=example,dc=com", 57 | permission="write") 58 | # 59 | # Check access rules for a DataObject 60 | data <- system.file("extdata/sample-data.csv", package="datapack") 61 | do <- new("DataObject", file=system.file("./extdata/sample-data.csv", package="datapack"), 62 | format="text/csv") 63 | do <- setPublicAccess(do) 64 | isPublic <- hasAccessRule(do, "public", "read") 65 | accessRules <- data.frame(subject=c("uid=smith,ou=Account,dc=example,dc=com", 66 | "uid=wiggens,o=unaffiliated,dc=example,dc=org"), 67 | permission=c("write", "changePermission"), 68 | stringsAsFactors=FALSE) 69 | do <- addAccessRule(do, accessRules) 70 | SmithHasWrite <- hasAccessRule(do, "uid=smith,ou=Account,dc=example,dc=com", "write") 71 | # 72 | # Check access rules for member DataObjects of a DataPackage. 73 | # First create an example DataPackage 74 | dp <- new("DataPackage") 75 | data <- charToRaw("1,2,3\n4,5,6\n") 76 | obj <- new("DataObject", id="id1", dataobj=data, format="text/csv") 77 | dp <- addMember(dp, obj) 78 | data2 <- charToRaw("7,8,9\n4,10,11\n") 79 | obj2 <- new("DataObject", id="id2", dataobj=data2, format="text/csv") 80 | dp <- addMember(dp, obj2) 81 | # Add access rules to all package members 82 | dp <- addAccessRule(dp, "uid=smith,ou=Account,dc=example,dc=com", "write") 83 | dp <- addAccessRule(dp, "uid=smith,ou=Account,dc=example,dc=com", "changePermission") 84 | hasWrite <- hasAccessRule(dp, "uid=smith,ou=Account,dc=example,dc=com", "write") 85 | hasChange <- hasAccessRule(dp, "uid=smith,ou=Account,dc=example,dc=com", "changePermission") 86 | } 87 | \seealso{ 88 | \code{\link{SystemMetadata-class}} 89 | 90 | \code{\link{DataObject-class}} 91 | 92 | \code{\link{DataPackage-class}} 93 | } 94 | -------------------------------------------------------------------------------- /man/describeWorkflow.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \name{describeWorkflow} 4 | \alias{describeWorkflow} 5 | \alias{describeWorkflow,DataPackage-method} 6 | \title{Add data derivation information to a DataPackage} 7 | \usage{ 8 | describeWorkflow(x, ...) 9 | 10 | \S4method{describeWorkflow}{DataPackage}( 11 | x, 12 | sources = list(), 13 | program = NA_character_, 14 | derivations = list(), 15 | insertDerivations = TRUE, 16 | ... 17 | ) 18 | } 19 | \arguments{ 20 | \item{x}{The \code{DataPackage} to add provenance relationships to.} 21 | 22 | \item{...}{Additional parameters} 23 | 24 | \item{sources}{A list of DataObjects for files that were read by the program. Alternatively, a list 25 | of DataObject identifiers can be specified as a list of character strings.} 26 | 27 | \item{program}{The DataObject created for the program such as an R script. Alternatively the DataObject identifier can 28 | be specified.} 29 | 30 | \item{derivations}{A list of DataObjects for files that were generated by the program. Alternatively, a list 31 | of DataObject identifiers can be specified as a list of character strings.} 32 | 33 | \item{insertDerivations}{A \code{logical} value. If TRUE then the provenance relationship 34 | \code{prov:wasDerivedFrom} will be used to connect every source and derivation. The default value 35 | is TRUE.} 36 | } 37 | \description{ 38 | Add information about the relationships among DataObject members 39 | in a DataPackage, retrospectively describing the way in which derived data were 40 | created from source data using a processing program such as an R script. These provenance 41 | relationships allow the derived data to be understood sufficiently for users 42 | to be able to reproduce the computations that created the derived data, and to 43 | trace lineage of the derived data objects. The method \code{describeWorkflow} 44 | will add provenance relationships between a script that was executed, the files 45 | that it used as sources, and the derived files that it generated. 46 | } 47 | \details{ 48 | This method operates on a DataPackage that has had DataObjects for 49 | the script, data sources (inputs), and data derivations (outputs) previously 50 | added to it, or can reference identifiers for objects that exist in other DataPackage 51 | instances. This allows a user to create a standalone package that contains all of 52 | its source, script, and derived data, or a set of data packages that are chained 53 | together via a set of derivation relationships between the members of those packages. 54 | 55 | Provenance relationships are described following the the ProvONE data model, which 56 | can be viewed at \url{https://purl.dataone.org/provone-v1-dev}. In particular, 57 | the following relationships are inserted (among others): 58 | \describe{ 59 | \item{\code{prov:used}}{indicates which source data was used by a program execution} 60 | \item{\code{prov:generatedBy}}{indicates which derived data was created by a program execution} 61 | \item{\code{prov:wasDerivedFrom}}{indicates the source data from which derived data were created using the program} 62 | } 63 | } 64 | \examples{ 65 | library(datapack) 66 | dp <- new("DataPackage") 67 | # Add the script to the DataPackage 68 | progFile <- system.file("./extdata/pkg-example/logit-regression-example.R", package="datapack") 69 | progObj <- new("DataObject", format="application/R", filename=progFile) 70 | dp <- addMember(dp, progObj) 71 | 72 | # Add a script input to the DataPackage 73 | inFile <- system.file("./extdata/pkg-example/binary.csv", package="datapack") 74 | inObj <- new("DataObject", format="text/csv", filename=inFile) 75 | dp <- addMember(dp, inObj) 76 | 77 | # Add a script output to the DataPackage 78 | outFile <- system.file("./extdata/pkg-example/gre-predicted.png", package="datapack") 79 | outObj <- new("DataObject", format="image/png", file=outFile) 80 | dp <- addMember(dp, outObj) 81 | 82 | # Add the provenenace relationshps, linking the input and output to the script execution 83 | # Note: 'sources' and 'derivations' can also be lists of "DataObjects" or "DataObject' identifiers 84 | dp <- describeWorkflow(dp, sources = inObj, program = progObj, derivations = outObj) 85 | # View the results 86 | utils::head(getRelationships(dp)) 87 | } 88 | \seealso{ 89 | The R 'recordr' package for run-time recording of provenance relationships. 90 | } 91 | -------------------------------------------------------------------------------- /R/Constants.R: -------------------------------------------------------------------------------- 1 | # This method of defining package wide constants is suggested in R help 2 | # by Duncun Murdoch, who has been one of the core R developers. Essentially these values are defined 3 | # outside of a function so that they will be available to any function in the package, 4 | # but are not exported using the NAMESPACE file so are not visible outside of the 5 | # package. 6 | 7 | # These constants are for the ProvONE data model that is described 8 | # at https://purl.dataone.org/provone-v1-dev. 9 | xsd_NS <- "http://www.w3.org/2001/XMLSchema#" 10 | xsdString <- sprintf("%s%s", xsd_NS, "string") 11 | xsdDateTime <- sprintf("%s%s", xsd_NS, "dateTime") 12 | dc_NS <- "http://purl.org/dc/elements/1.1/" 13 | dcterms_NS <- "http://purl.org/dc/terms/" 14 | DCTERMSidentifier <- sprintf("%s%s", dcterms_NS, "identifier") 15 | DCTERMSagent <- sprintf("%s%s", dcterms_NS, "Agent") 16 | DCTERMScreator <- sprintf("%s%s", dcterms_NS, "creator") 17 | DCTERMSmodified <- sprintf("%s%s", dcterms_NS, "modified") 18 | DCtitle <- sprintf("%s%s", dc_NS, "title") 19 | RDF_NS <- "http://www.w3.org/1999/02/22-rdf-syntax-ns#" 20 | FOAF_NS <- "http://xmlns.com/foaf/0.1/" 21 | foafName <- sprintf("%s%s", FOAF_NS, "name") 22 | RDFtype <- sprintf("%s%s", RDF_NS, "type") 23 | otherCreator <- sprintf("%s%s", dc_NS, "creator") 24 | # This is kept for backward compatibility 25 | rdfType <- RDFtype 26 | provNS <- "http://www.w3.org/ns/prov#" 27 | provQualifiedAssociation <- sprintf("%s%s", provNS, "qualifiedAssociation") 28 | provWasDerivedFrom <- sprintf("%s%s", provNS, "wasDerivedFrom") 29 | provHadPlan <- sprintf("%s%s", provNS, "hadPlan") 30 | provUsed <- sprintf("%s%s", provNS, "used") 31 | provWasGeneratedBy <- sprintf("%s%s", provNS, "wasGeneratedBy") 32 | provAssociation <- sprintf("%s%s", provNS, "Association") 33 | provWasAssociatedWith <- sprintf("%s%s", provNS, "wasAssociatedWith") 34 | provAgent <- sprintf("%s%s", provNS, "Agent") 35 | provAtLocation <- sprintf("%s%s", provNS, "atLocation") 36 | provONE_NS <- "http://purl.dataone.org/provone/2015/01/15/ontology#" 37 | provONEprogram <- sprintf("%s%s", provONE_NS, "Program") 38 | provONEexecution <- sprintf("%s%s", provONE_NS, "Execution") 39 | provONEdata <- sprintf("%s%s", provONE_NS, "Data") 40 | provONEuser <- sprintf("%s%s", provONE_NS, "User") 41 | D1_CN_URL <- "https://cn.dataone.org/cn/v2" 42 | D1_CN_Resolve_URL <- sprintf("%s/%s", D1_CN_URL, "resolve") 43 | cito_NS <- "http://purl.org/spar/cito/" 44 | citoDocuments <- sprintf("%s%s", cito_NS, "documents") 45 | citoIsDocumentedBy <- sprintf("%s%s", cito_NS, "isDocumentedBy") 46 | 47 | namespace_vector <- c(RDF_NS, 48 | "http://www.w3.org/2001/XMLSchema#", 49 | "http://www.w3.org/2000/01/rdf-schema#", 50 | provNS, 51 | provONE_NS, 52 | "http://purl.org/dc/elements/1.1/", 53 | "http://purl.org/dc/terms/", 54 | "http://xmlns.com/foaf/0.1/", 55 | "http://www.openarchives.org/ore/terms/", 56 | "http://purl.org/spar/cito/", 57 | "http://www.w3.org/ns/prov#") 58 | 59 | prefixes <- c("rdf", 60 | "xsd", 61 | "rdfs", 62 | "prov", 63 | "provone", 64 | "dc", 65 | "dcterms", 66 | "foaf", 67 | "ore", 68 | "cito", 69 | "prov") 70 | 71 | knownNamespaces <- data.frame(namespace = namespace_vector, prefix = prefixes, stringsAsFactors = FALSE) 72 | 73 | # Open Archives Initiative Object Reuse and Exchange (OAI-ORE) terms 74 | ORE_NS <- "http://www.openarchives.org/ore/terms/" 75 | OREresourceMap <- "http://www.openarchives.org/ore/terms/ResourceMap" 76 | OREdescribes <- "http://www.openarchives.org/ore/terms/describes" 77 | OREisDescribedBy <- "http://www.openarchives.org/ore/terms/isDescribedBy" 78 | aggregatedBy <- "http://www.openarchives.org/ore/terms/isAggregatedBy" 79 | aggregates <- "http://www.openarchives.org/ore/terms/aggregates" 80 | aggregationType <- "http://www.openarchives.org/ore/terms/Aggregation" 81 | -------------------------------------------------------------------------------- /man/DataObject-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataObject.R 3 | \docType{class} 4 | \name{DataObject-class} 5 | \alias{DataObject-class} 6 | \title{DataObject wraps raw data with system-level metadata} 7 | \description{ 8 | DataObject is a wrapper class that associates raw data or a data file with system-level metadata 9 | describing the data. The system metadata includes attributes such as the object's identifier, 10 | type, size, checksum, owner, version relationship to other objects, access rules, and other critical metadata. 11 | The SystemMetadata is compliant with the DataONE federated repository network's definition of SystemMetadata, and 12 | is encapsulated as a separate object of type \code{\link{SystemMetadata}} that can be manipulated as needed. Additional science-level and 13 | domain-specific metadata is out-of-scope for SystemMetadata, which is intended only for critical metadata for 14 | managing objects in a repository system. 15 | } 16 | \details{ 17 | A DataObject can be constructed by passing the data and SystemMetadata to the new() method, or by passing 18 | an identifier, data, format, user, and DataONE node identifier, in which case a SystemMetadata instance will 19 | be generated with these fields and others that are calculated (such as size and checksum). 20 | 21 | Data are associated with the DataObject either by passing it as a \code{'raw'} value to the \code{'dataobj'} 22 | parameter in the constructor, which is then stored in memory, or by passing a fully qualified file path to the 23 | data in the \code{'filename'} parameter, which is then stored on disk. One of dataobj or filename is required. 24 | Use the \code{'filename'} approach when data are too large to be managed effectively in memory. Callers can 25 | access the \code{'filename'} slot to get direct access to the file, or can call \code{'getData()'} to retrieve the 26 | contents of the data or file as a raw value (but this will read all of the data into memory). 27 | } 28 | \section{Slots}{ 29 | 30 | \describe{ 31 | \item{\code{sysmeta}}{A value of type \code{"SystemMetadata"}, containing the metadata about the object} 32 | 33 | \item{\code{data}}{A value of type \code{"raw"}, containing the data represented in this object} 34 | 35 | \item{\code{filename}}{A character value that contains the fully-qualified path to the object data on disk} 36 | 37 | \item{\code{dataURL}}{A character value for the URL used to load data into this DataObject} 38 | 39 | \item{\code{updated}}{A list containing logical values which indicate if system metadata or the data object have been updated since object creation.} 40 | 41 | \item{\code{oldId}}{A character string containing the previous identifier used, before a \code{"replaceMember"} call.} 42 | 43 | \item{\code{targetPath}}{An optional character string holding the path of where the file is placed in a downloaded package.} 44 | }} 45 | 46 | \section{Methods}{ 47 | 48 | \describe{ 49 | \item{\code{\link[=DataObject-initialize]{initialize}}}{: Initialize a DataObject} 50 | \item{\code{\link{addAccessRule}}}{: Add a Rule to the AccessPolicy} 51 | \item{\code{\link{canRead}}}{: Test whether the provided subject can read an object.} 52 | \item{\code{\link{getData}}}{: Get the data content of a specified data object} 53 | \item{\code{\link{getFormatId}}}{: Get the FormatId of the DataObject} 54 | \item{\code{\link{getIdentifier}}}{: Get the Identifier of the DataObject} 55 | \item{\code{\link{hasAccessRule}}}{: Determine if an access rules exists for a DataObject.} 56 | \item{\code{\link{setPublicAccess}}}{: Add a Rule to the AccessPolicy to make the object publicly readable.} 57 | \item{\code{\link{updateXML}}}{: Update selected elements of the xml content of a DataObject} 58 | } 59 | } 60 | 61 | \examples{ 62 | data <- charToRaw("1,2,3\n4,5,6\n") 63 | targetPath <- "myData/time-trials/trial_data.csv" 64 | do <- new("DataObject", "id1", dataobj=data, "text/csv", 65 | "uid=jones,DC=example,DC=com", "urn:node:KNB", targetPath=targetPath) 66 | getIdentifier(do) 67 | getFormatId(do) 68 | getData(do) 69 | canRead(do, "uid=anybody,DC=example,DC=com") 70 | do <- setPublicAccess(do) 71 | canRead(do, "public") 72 | canRead(do, "uid=anybody,DC=example,DC=com") 73 | # Also can create using a file for storage, rather than memory 74 | \dontrun{ 75 | tf <- tempfile() 76 | con <- file(tf, "wb") 77 | writeBin(data, con) 78 | close(con) 79 | targetPath <- "myData/time-trials/trial_data.csv" 80 | do <- new("DataObject", "id1", format="text/csv", user="uid=jones,DC=example,DC=com", 81 | mnNodeId="urn:node:KNB", filename=tf, targetPath=targetPath) 82 | } 83 | } 84 | \seealso{ 85 | \code{\link{datapack}} 86 | } 87 | \keyword{classes} 88 | -------------------------------------------------------------------------------- /inst/extdata/sample-data-filtered.csv: -------------------------------------------------------------------------------- 1 | "Species_Name","light","temp","cont","moist","react","nutr" 2 | "Achillea millefolium ",8,0,0,4,0,5 3 | "Aconitum lycoctonum",3,4,4,7,7,8 4 | "Aconitum variegatum",5,4,4,7,8,7 5 | "Actaea spicata",3,5,4,5,6,7 6 | "Aegopodium podagraria",5,5,3,6,7,8 7 | "Aethusa cynapium",5,6,4,5,7,7 8 | "Agrostis stolonifera",8,0,5,7,0,5 9 | "Ajuga reptans",6,0,2,6,6,6 10 | "Alisma plantago-aquatica",7,5,0,10,0,8 11 | "Alliaria petiolata",5,6,3,5,7,9 12 | "Anthriscus sylvestris",7,0,5,5,0,8 13 | "Arrhenatherum elatius",8,5,3,0,7,7 14 | "Artemisia vulgaris",7,6,0,6,0,8 15 | "Asarum europaeum",3,6,5,5,7,6 16 | "Athyrium filix-femina",3,0,3,7,0,6 17 | "Bidens frondosa",7,6,0,8,7,8 18 | "Bidens tripartita",8,6,0,9,0,8 19 | "Bromus benekenii",5,5,4,5,7,5 20 | "Calamagrostis arundinacea",6,5,4,5,4,5 21 | "Calamagrostis epigejos",7,5,7,0,0,6 22 | "Caltha palustris",7,0,0,9,0,6 23 | "Calystegia sepium",8,6,5,6,7,9 24 | "Campanula patula",8,6,4,5,7,5 25 | "Campanula trachelium",4,0,3,6,8,8 26 | "Cardamine flexuosa",6,5,2,8,4,5 27 | "Cardamine impatiens",5,0,4,6,7,8 28 | "Carduus personata",7,4,2,8,8,8 29 | "Carex buekii",8,6,6,8,8,6 30 | "Chaerophyllum hirsutum",6,3,4,8,0,7 31 | "Chaerophyllum temulum",5,6,3,5,0,8 32 | "Chelidonium majus",6,6,0,5,0,8 33 | "Circaea alpina",4,4,4,7,5,5 34 | "Cirsium oleraceum",6,0,3,7,7,5 35 | "Clematis vitalba",7,6,3,5,7,7 36 | "Cuscuta europaea",0,6,5,7,0,7 37 | "Cymbalaria muralis",7,7,4,6,8,5 38 | "Dactylis glomerata",7,0,3,5,0,6 39 | "Digitalis grandiflora",7,4,4,5,5,5 40 | "Doronicum austriacum",5,3,4,6,7,7 41 | "Dryopteris dilatata",4,0,3,6,0,7 42 | "Dryopteris filix-mas",3,0,3,5,5,6 43 | "Elymus caninus",6,6,3,6,7,8 44 | "Epilobium angustifolium",8,0,5,5,5,8 45 | "Epilobium hirsutum",7,5,5,8,8,8 46 | "Epilobium montanum",4,0,3,5,6,6 47 | "Epilobium roseum",7,6,4,9,8,8 48 | "Euphorbia dulcis",4,5,2,5,8,5 49 | "Fallopia convolvulus",7,6,0,5,0,6 50 | "Fallopia dumetorum",6,6,4,5,0,7 51 | "Festuca gigantea",4,5,3,7,6,6 52 | "Festuca heterophylla",5,6,4,4,5,5 53 | "Filipendula ulmaria",7,5,0,8,0,5 54 | "Fragaria moschata",6,6,4,5,6,6 55 | "Fragaria vesca",7,0,5,5,0,6 56 | "Galeobdolon montanum",3,4,5,6,7,6 57 | "Galeopsis bifida",7,5,5,5,6,6 58 | "Galeopsis pubescens",7,5,4,5,0,6 59 | "Galeopsis speciosa",7,0,6,5,0,8 60 | "Galium album ssp. album",7,0,3,5,7,5 61 | "Galium aparine",7,6,3,0,6,8 62 | "Galium odoratum",2,5,2,5,6,5 63 | "Galium sylvaticum",5,5,4,5,6,5 64 | "Geranium robertianum",5,0,3,0,0,7 65 | "Geum urbanum",4,5,5,5,0,7 66 | "Glechoma hederacea",6,6,3,6,0,7 67 | "Glyceria fluitans",7,0,3,9,0,7 68 | "Glyceria maxima",9,5,0,10,8,9 69 | "Gymnocarpium dryopteris",3,4,5,6,4,5 70 | "Hepatica nobilis",4,6,4,4,7,5 71 | "Heracleum sphondylium",7,5,2,5,0,8 72 | "Holcus lanatus",7,6,3,6,0,5 73 | "Humulus lupulus",7,6,3,8,6,8 74 | "Impatiens glandulifera",5,7,2,8,7,7 75 | "Impatiens noli-tangere",4,5,5,7,7,6 76 | "Impatiens parviflora",4,6,5,5,0,6 77 | "Iris pseudacorus",7,6,3,9,0,7 78 | "Knautia dipsacifolia",5,4,4,6,6,6 79 | "Lamium maculatum",5,0,4,6,7,8 80 | "Lapsana communis",5,6,3,5,0,7 81 | "Lilium martagon",4,0,5,5,7,5 82 | "Lunaria rediviva",4,5,4,6,7,8 83 | "Lycopus europaeus",7,6,5,9,7,7 84 | "Mentha longifolia",7,5,4,8,9,7 85 | "Mercurialis perennis",2,0,3,0,8,7 86 | "Milium effusum",4,0,3,5,5,5 87 | "Moehringia trinervia",4,5,3,5,6,7 88 | "Mycelis muralis",4,6,2,5,0,6 89 | "Myosotis palustris agg.",7,0,5,8,0,5 90 | "Myosotis sylvatica",6,0,3,5,0,7 91 | "Myosoton aquaticum",7,5,3,8,7,8 92 | "Oxalis acetosella",1,0,3,5,4,6 93 | "Paris quadrifolia",3,0,4,6,7,7 94 | "Persicaria hydropiper",7,6,0,8,5,8 95 | "Phalaris arundinacea",7,5,0,8,7,7 96 | "Poa palustris",7,5,5,9,8,7 97 | "Poa trivialis",6,0,3,7,0,7 98 | "Polygonatum multiflorum",2,0,5,5,6,5 99 | "Prenanthes purpurea",4,4,4,5,5,5 100 | "Pulmonaria obscura",4,5,6,6,8,7 101 | "Ranunculus lanuginosus",3,6,4,6,7,7 102 | "Ranunculus repens",6,0,0,7,0,7 103 | "Rumex aquaticus",7,6,7,8,7,8 104 | "Rumex conglomeratus",8,6,3,7,0,8 105 | "Rumex obtusifolius",7,5,3,6,0,9 106 | "Salvia glutinosa",4,5,4,6,7,7 107 | "Scrophularia nodosa",4,5,3,6,6,7 108 | "Scutellaria galericulata",7,6,5,9,7,6 109 | "Senecio ovatus",7,0,4,5,0,8 110 | "Solanum dulcamara",7,5,0,8,0,8 111 | "Stachys palustris",7,5,0,7,7,6 112 | "Stachys sylvatica",4,0,3,7,7,7 113 | "Stellaria holostea",5,6,3,5,6,5 114 | "Stellaria media",6,0,0,0,7,8 115 | "Stellaria nemorum",4,0,4,7,5,7 116 | "Symphytum officinale",7,6,3,7,0,8 117 | "Torilis japonica",6,6,3,5,8,8 118 | "Urtica dioica",0,0,0,6,7,9 119 | "Valeriana excelsa ssp. sambucifolia",7,6,5,8,6,5 120 | "Verbascum densiflorum",8,6,5,4,8,5 121 | "Verbascum nigrum",7,5,5,5,7,7 122 | "Veronica beccabunga",7,0,3,10,7,6 123 | "Viola reichenbachiana",4,0,4,5,7,6 124 | -------------------------------------------------------------------------------- /man/SystemMetadata-initialize.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/SystemMetadata.R 3 | \name{initialize,SystemMetadata-method} 4 | \alias{initialize,SystemMetadata-method} 5 | \alias{SystemMetadata-initialize} 6 | \title{Initialize a DataONE SystemMetadata object with default values or values passed in to the constructor} 7 | \usage{ 8 | \S4method{initialize}{SystemMetadata}( 9 | .Object, 10 | identifier = NA_character_, 11 | formatId = NA_character_, 12 | size = NA_real_, 13 | checksum = NA_character_, 14 | checksumAlgorithm = "SHA-256", 15 | submitter = NA_character_, 16 | rightsHolder = NA_character_, 17 | accessPolicy = data.frame(subject = character(), permission = character()), 18 | replicationAllowed = TRUE, 19 | numberReplicas = 3, 20 | obsoletes = NA_character_, 21 | obsoletedBy = NA_character_, 22 | archived = FALSE, 23 | dateUploaded = NA_character_, 24 | dateSysMetadataModified = NA_character_, 25 | originMemberNode = NA_character_, 26 | authoritativeMemberNode = NA_character_, 27 | preferredNodes = list(), 28 | blockedNodes = list(), 29 | seriesId = NA_character_, 30 | mediaType = NA_character_, 31 | fileName = NA_character_, 32 | mediaTypeProperty = list() 33 | ) 34 | } 35 | \arguments{ 36 | \item{.Object}{The object being initialized} 37 | 38 | \item{identifier}{value of type \code{"character"}, the identifier of the object that this system metadata describes.} 39 | 40 | \item{formatId}{value of type \code{"character"}, the DataONE object format for the object.} 41 | 42 | \item{size}{value of type \code{"numeric"}, the size of the object in bytes.} 43 | 44 | \item{checksum}{value of type \code{"character"}, the checksum for the object using the designated checksum algorithm.} 45 | 46 | \item{checksumAlgorithm}{value of type \code{"character"}, the name of the hash function used to generate a checksum, from the DataONE controlled list.} 47 | 48 | \item{submitter}{value of type \code{"character"}, the Distinguished Name or identifier of the person submitting the object.} 49 | 50 | \item{rightsHolder}{value of type \code{"character"}, the Distinguished Name or identifier of the person who holds access rights to the object.} 51 | 52 | \item{accessPolicy}{value of type \code{"data.frame"} containing (subject, permission) tuples to constitute the access authorization rules.} 53 | 54 | \item{replicationAllowed}{value of type \code{"logical"}, for replication policy allows replicas.} 55 | 56 | \item{numberReplicas}{value of type \code{"numeric"}, for number of supported replicas.} 57 | 58 | \item{obsoletes}{value of type \code{"character"}, the identifier of an object which this object replaces.} 59 | 60 | \item{obsoletedBy}{value of type \code{"character"}, the identifier of an object that replaces this object.} 61 | 62 | \item{archived}{value of type \code{"logical"}, a boolean flag indicating whether the object has been archived and thus hidden.} 63 | 64 | \item{dateUploaded}{value of type \code{"character"}, the date on which the object was uploaded to a member node.} 65 | 66 | \item{dateSysMetadataModified}{value of type \code{"character"}, the last date on which this system metadata was modified.} 67 | 68 | \item{originMemberNode}{value of type \code{"character"}, the node identifier of the node on which the object was originally registered.} 69 | 70 | \item{authoritativeMemberNode}{value of type \code{"character"}, the node identifier of the node which currently is authoritative for the object.} 71 | 72 | \item{preferredNodes}{list of \code{"character"}, each of which is the node identifier for a node to which a replica should be sent.} 73 | 74 | \item{blockedNodes}{list of \code{"character"}, each of which is the node identifier for a node blocked from housing replicas.} 75 | 76 | \item{seriesId}{value of type \code{"character"}, a unique Unicode string that identifies an object revision chain. A seriesId will resolve to the latest version of an object.} 77 | 78 | \item{mediaType}{value of type \code{"character"}, the IANA Media Type (aka MIME-Type) of the object, e.g. "text/csv".} 79 | 80 | \item{fileName}{value of type \code{"character"}, the name of the file to create when this object is downloaded from DataONE.} 81 | 82 | \item{mediaTypeProperty}{value of type a \code{"list"} of \code{"character"}, IANA Media Type properties for the \code{"mediaType"} argument} 83 | } 84 | \value{ 85 | the SystemMetadata instance representing an object 86 | } 87 | \description{ 88 | Initialize a SystemMetadata object by providing default values for core information 89 | needed to manage objects across repository systems. SystemMetadata contains basic identification, ownership, 90 | access policy, replication policy, and related metadata. 91 | } 92 | \seealso{ 93 | \url{https://releases.dataone.org/online/api-documentation-v2.0/apis/Types.html} 94 | 95 | \code{\link{SystemMetadata-class}} 96 | } 97 | -------------------------------------------------------------------------------- /man/SystemMetadata-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/SystemMetadata.R 3 | \docType{class} 4 | \name{SystemMetadata-class} 5 | \alias{SystemMetadata-class} 6 | \title{A DataONE SystemMetadata object containing basic identification, ownership, access policy, replication policy, and related metadata} 7 | \description{ 8 | A class representing DataONE SystemMetadata, which is core information about objects stored in a repository 9 | and needed to manage those objects across systems. SystemMetadata contains basic identification, ownership, 10 | access policy, replication policy, and related metadata. 11 | } 12 | \section{Slots}{ 13 | 14 | \describe{ 15 | \item{\code{serialVersion}}{value of type \code{"numeric"}, the current version of this system metadata; only update the current version} 16 | 17 | \item{\code{identifier}}{value of type \code{"character"}, the identifier of the object that this system metadata describes.} 18 | 19 | \item{\code{replicationAllowed}}{value of type \code{"logical"}, replication policy allows replicas.} 20 | 21 | \item{\code{numberReplicas}}{value of type \code{"numeric"}, for number of supported replicas.} 22 | 23 | \item{\code{preferredNodes}}{value of type \code{"list"}, of preferred member nodes.} 24 | 25 | \item{\code{blockedNodes}}{value of type \code{"list"}, of blocked member nodes.} 26 | 27 | \item{\code{formatId}}{value of type \code{"character"}, the DataONE object format for the object.} 28 | 29 | \item{\code{size}}{value of type \code{"numeric"}, the size of the object in bytes.} 30 | 31 | \item{\code{checksum}}{value of type \code{"character"}, the checksum for the object using the designated checksum algorithm.} 32 | 33 | \item{\code{checksumAlgorithm}}{value of type \code{"character"}, the name of the hash function used to generate a checksum, from the DataONE controlled list.} 34 | 35 | \item{\code{submitter}}{value of type \code{"character"}, the Distinguished Name or identifier of the person submitting the object.} 36 | 37 | \item{\code{rightsHolder}}{value of type \code{"character"}, the Distinguished Name or identifier of the person who holds access rights to the object.} 38 | 39 | \item{\code{accessPolicy}}{value of type \code{"data.frame"}, a list of access rules as (subject, permission) tuples to be applied to the object.} 40 | 41 | \item{\code{obsoletes}}{value of type \code{"character"}, the identifier of an object which this object replaces.} 42 | 43 | \item{\code{obsoletedBy}}{value of type \code{"character"}, the identifier of an object that replaces this object.} 44 | 45 | \item{\code{archived}}{value of type \code{"logical"}, a boolean flag indicating whether the object has been archived and thus hidden.} 46 | 47 | \item{\code{dateUploaded}}{value of type \code{"character"}, the date on which the object was uploaded to a member node.} 48 | 49 | \item{\code{dateSysMetadataModified}}{value of type \code{"character"}, the last date on which this system metadata was modified.} 50 | 51 | \item{\code{originMemberNode}}{value of type \code{"character"}, the node identifier of the node on which the object was originally registered.} 52 | 53 | \item{\code{authoritativeMemberNode}}{value of type \code{"character"}, the node identifier of the node which currently is authoritative for the object.} 54 | 55 | \item{\code{seriesId}}{value of type \code{"character"}, a unique Unicode string that identifies an object revision chain. A seriesId will resolve to the latest version of an object.} 56 | 57 | \item{\code{mediaType}}{value of type \code{"character"}, the IANA Media Type (aka MIME-Type) of the object, e.g. "text/csv".} 58 | 59 | \item{\code{fileName}}{value of type \code{"character"}, the name of the file to create when this object is downloaded from DataONE.} 60 | 61 | \item{\code{mediaTypeProperty}}{value of type a \code{"list"} of \code{"character"}, IANA Media Type properties for the \code{"mediaType"} argument} 62 | }} 63 | 64 | \section{Methods}{ 65 | 66 | \describe{ 67 | \item{\code{\link[=SystemMetadata-initialize]{initialize}}}{: Initialize a DataONE SystemMetadata object with default values or values passed in to the constructor object} 68 | \item{\code{\link{SystemMetadata}}}{: Create a SystemMetadata object, with all fields set to the value found in an XML document} 69 | \item{\code{\link{parseSystemMetadata}}}{: Parse an external XML document and populate a SystemMetadata object with the parsed data} 70 | \item{\code{\link{serializeSystemMetadata}}}{: Get the Count of Objects in the Package} 71 | \item{\code{\link{validate}}}{: Validate a SystemMetadata object} 72 | \item{\code{\link{addAccessRule}}}{: Add access rules to an object such as system metadata} 73 | \item{\code{\link{hasAccessRule}}}{: Determine if a particular access rules exists within SystemMetadata.} 74 | \item{\code{\link{clearAccessPolicy}}}{: Clear the accessPolicy from the specified object.} 75 | } 76 | } 77 | 78 | \seealso{ 79 | \code{\link{datapack}} 80 | } 81 | -------------------------------------------------------------------------------- /man/DataPackage-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/DataPackage.R 3 | \docType{class} 4 | \name{DataPackage-class} 5 | \alias{DataPackage-class} 6 | \title{A class representing a data package} 7 | \description{ 8 | The DataPackage class provides methods for adding and extracting 9 | data objects from a data package. The contents of a data package 10 | can include arbitrary types of objects, including data files, program code, 11 | visualizations and images, animations, and any other type of file. The DataPackage class 12 | stores the individual members of the data package along with key system-level metadata 13 | about each object, including its size, checksum, identifier, and other key information 14 | needed to effectively archive the members of the package. In addition, the 15 | DataPackage class can include key provenance metadata about the relationships among 16 | the objects in the data package. For example, the data package can document that one object 17 | provides documentation for another (\code{cito:documents}), and that one object was 18 | derived from another (\code{prov:wasDerivedFrom}) by executing a program that 19 | used source data (\code{prov:used}) to create a derived data object 20 | \code{{prov:wasGeneratedBy}}. These relationships are integral to the data package, 21 | and can be visualized by programs that understand the ProvONE provenance 22 | model (see \url{https://purl.dataone.org/provone-v1-dev}). 23 | 24 | The DataPackage class is an R representation of an underlying Open Archives 25 | Initiative ORE model (Object Reuse and Exchange; 26 | see \url{https://www.openarchives.org/ore/}), and follows the DataONE Data 27 | Packaging model 28 | (see \url{https://releases.dataone.org/online/api-documentation-v2.0.1/design/DataPackage.html}). 29 | } 30 | \section{Slots}{ 31 | 32 | \describe{ 33 | \item{\code{relations}}{A list containing provenance relationships of package objects} 34 | 35 | \item{\code{objects}}{A list containing identifiers for objects in the DataPackage} 36 | 37 | \item{\code{sysmeta}}{A SystemMetadata class instance describing the package} 38 | 39 | \item{\code{externalIds}}{A list containing identifiers for objects associated with the DataPackage} 40 | 41 | \item{\code{resmapId}}{A character string specifying the identifier for the package resource map. 42 | This is assigned after a package is uploaded or downloaded from a repository.} 43 | }} 44 | 45 | \section{Methods}{ 46 | 47 | \describe{ 48 | \item{\code{\link[=DataPackage-initialize]{initialize}}}{: Initialize a DataPackage object.} 49 | \item{\code{\link{addAccessRule}}}{: Add access rules to DataObjects in a DataPackage.} 50 | \item{\code{\link{addMember}}}{: Add a DataObject to a DataPackage.} 51 | \item{\code{\link{clearAccessPolicy}}}{: Clear access policies for DataObjects in a DataPackage.} 52 | \item{\code{\link{containsId}}}{: Returns true if the specified object is a member of the data package.} 53 | \item{\code{\link{describeWorkflow}}}{: Add data derivation information to a DataPackage.} 54 | \item{\code{\link{getData}}}{: Get the data content of a specified data object.} 55 | \item{\code{\link{getSize}}}{: Get the Count of Objects in the DataPackage.} 56 | \item{\code{\link{getIdentifiers}}}{: Get the Identifiers of DataPackage members.} 57 | \item{\code{\link{getMember}}}{: Return the DataPackage Member by Identifier.} 58 | \item{\code{\link{getRelationships}}}{: Retrieve relationships of data package objects.} 59 | \item{\code{\link{getValue}}}{: Get values for selected DataPackage members.} 60 | \item{\code{\link{hasAccessRule}}}{: Determine if access rules exists for DataObjects in a DataPackage.} 61 | \item{\code{\link{insertRelationship}}}{: Insert relationships between objects in a DataPackage.} 62 | \item{\code{\link{removeAccessRule}}}{: Remove an access rule from DataObject in a DataPackage.} 63 | \item{\code{\link{removeMember}}}{: Remove the specified DataObject from a DataPackage.} 64 | \item{\code{\link{removeRelationships}}}{: Remove relationships of objects in a DataPackage.} 65 | \item{\code{\link{replaceMember}}}{: Replace the raw data or file associated with a DataObject.} 66 | \item{\code{\link{selectMember}}}{: Select package members based on slot values.} 67 | \item{\code{\link{serializePackage}}}{: Create an OAI-ORE resource map from the DataPackage.} 68 | \item{\code{\link{serializeToBagIt}}}{: Serialize A DataPackage into a BagIt Archive File.} 69 | \item{\code{\link{setPublicAccess}}}{: Set the access policy to readable by anyone for DataObject in a DataPackage.} 70 | \item{\code{\link{setValue}}}{: Set values for selected DataPackage members} 71 | \item{\code{\link{show}}}{: Print DataPackage information in a formatted view.} 72 | \item{\code{\link{updateMetadata}}}{: Update selected elements of the XML content of a DataObject in a DataPackage} 73 | \item{\code{\link{updateRelationships}}}{: Update package relationships by replacing an old identifier with a new one.} 74 | } 75 | } 76 | 77 | \seealso{ 78 | \code{\link{datapack}} 79 | } 80 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # datapack 1.4.2 2 | 3 | BUGS 4 | 5 | * Fix documentation errors due to API changes (#139) 6 | 7 | # datapack 1.4.1 8 | 9 | BUGS 10 | 11 | * Remove LazyData from DESCRIPTION (#132) 12 | * Remove dependency on hash package (#133) 13 | * Replace instances of `if (class(...))` with `inherits(...)` (#136) 14 | 15 | NEW FEATURES 16 | 17 | * Refactor BagIt serialization to match new specification (#109) 18 | 19 | # datapack 1.4.0 20 | 21 | BUGS 22 | 23 | * Handle dc:creator in resource map properly (#116) 24 | 25 | NEW FEATURES 26 | 27 | * Use SHA-256 as the default hash algorithm (#117) 28 | * Added 'checksumAlgorithm' argument to DataObject initialization method (#117) 29 | * Update tests for compatibility with testthat 3e (#125) 30 | * Added 'targetPath' argument to DataObject to set 'prov:atLocation' for an object (#109) 31 | 32 | # datapack 1.3.2 33 | 34 | BUGS 35 | 36 | * Ensure that a 'dc:creator' element is always present (#93) 37 | * Ensure that the resource map dcterms:modified time is always present/updated. (#93) 38 | * Ensure that a DataPackage is marked as updated after addAccessRule, setPublicAccess, clearAccessPolicy methods called (#92). 39 | * Remove dependency on redland::getNextResult (#110) 40 | 41 | NEW FEATURES 42 | * Added function removeRelationships() which can remove all or specified relationships from a DataPackage (#99) 43 | 44 | # datapack 1.3.1 45 | 46 | BUGS 47 | 48 | * fixed bug in updateMetadata() that would cause package relationships 49 | for the metadata object to be lost. 50 | 51 | # datapack 1.3.0 52 | 53 | NEW FEATURES 54 | 55 | * Added support for DataPackage download, edit, upload workflow. (#85) 56 | 57 | * Added new method parseRDF() to parses an RDF/XML resource map from a file. (#85) 58 | 59 | * Added new method removeMember() which removes a member from a Package. (#85) 60 | 61 | * Added new method replaceMember() which replaces the raw data or file associated with a DataObject. (#85) 62 | 63 | * Added new method selectMember(0) which selects package members based on slot values. (#85) 64 | 65 | * Added new method updateRelationships() which updates package relationships by replacing an old 66 | identifier with a new one. (#85) 67 | 68 | * Added new method updateMetadata() to update XML content of a DataOBject in a DataPackage. (#85) 69 | 70 | * Added new method getValue() which gets values for selected DataPackage member slots. (#85) 71 | 72 | * Added new method setValue(0) which sets values for selected DataPackage member slots. (#85) 73 | 74 | * Added new method removeAccessRule() to SystemMetadata, DataObject, DataPackage classes. (#78) 75 | 76 | * Added new method hasAccessRule() to DataObject, DataPackage classes. (#78) 77 | 78 | * Added new method clearAccessPolicy() DataObject, DataPackage classes. (#78) 79 | 80 | * Added new method addAccessRule() to DataPackage. class (#85) 81 | 82 | * Added new method setPublicAccess() to DataPackage. class (#85) 83 | 84 | * Access policies can now be modified for DataPackage, DataObject. (#78) 85 | 86 | * Resource map identifiers now include metadata object identifier. (#82) 87 | 88 | BUGS 89 | 90 | * fixed bug where resource maps had invalid XML names for blank node identifiers. (#79) 91 | 92 | * fixed bug where resource maps did not include creator or modification time. (#80) 93 | 94 | DEPRECATED 95 | 96 | - deprecated function addData(), renamed to addMember(). 97 | 98 | # datapack 1.2.0 99 | 100 | BUGS 101 | 102 | * Fixed bug where replicationAllowed was not set correctly when parsing if it is 103 | false (#61) 104 | 105 | * Fixed bug where numberReplicas was not set correctly when parsing (#63) 106 | 107 | * Fixed bug where the `mediaType` argument to DataObject `initialize()` 108 | was not being handled correctly and resulted in an invalid system metadata 109 | object to be serialized from the DataObject. (#67) 110 | 111 | * Added argument 'mediaTypeProperty' to DataObject `initialize()` which was 112 | needed to fully support 'mediaType'. (#67) 113 | 114 | NEW FEATURES 115 | 116 | * Added new function to reset access policies `clearAccessPolicy()` (#56) 117 | 118 | * Added new function `describeWorkflow()` to add run provenance relationships to a DataPackage (#64) 119 | 120 | * Added 'Show' methods for DataObject and DataPackage classes. (#71, #73) 121 | 122 | DEPRECATED 123 | 124 | * The method `recordDerivation` is deprecated in this release and may be marked as Defunct and 125 | removed in a future release (#68) 126 | 127 | # datapack 1.1.0 128 | 129 | This # datapack was not released publicly. 130 | 131 | # datapack 1.0.1 132 | 133 | BUGS 134 | 135 | * Fixed bug where Roxygen example for serializePackage() was writing to the "/tmp" 136 | directory 137 | 138 | * Serializing system metadata to XML with serializeSystemMetadata() now gathers all 139 | elements together for a so that the subject does not appear 140 | under multiple elements. 141 | 142 | # datapack 1.0.0 143 | 144 | NEW FEATURES 145 | 146 | * Initial # datapack (see help topic for 'datapack', e.g. "?datapack") 147 | 148 | * Provides an API for building and serializing packages of data and associated metadata. 149 | 150 | * The package name has been changed from 'datapackage' to 'datapack' 151 | 152 | NEW S4 CLASSES 153 | 154 | * Class DataPackage for building and serializing data packages. 155 | 156 | * Class SystemMetadata and DataObject for representing a member of a data package. 157 | 158 | * Class ResourceMap for building and serializing a Resource Description Framework 159 | representation of a data package. 160 | -------------------------------------------------------------------------------- /man/removeAccessRule.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/SystemMetadata.R, R/DataObject.R, 3 | % R/DataPackage.R 4 | \name{removeAccessRule} 5 | \alias{removeAccessRule} 6 | \alias{removeAccessRule,SystemMetadata-method} 7 | \alias{removeAccessRule,DataObject-method} 8 | \alias{removeAccessRule,DataPackage-method} 9 | \title{Remove an access rule from the specified object} 10 | \usage{ 11 | removeAccessRule(x, ...) 12 | 13 | \S4method{removeAccessRule}{SystemMetadata}(x, y, ...) 14 | 15 | \S4method{removeAccessRule}{DataObject}(x, y, ...) 16 | 17 | \S4method{removeAccessRule}{DataPackage}(x, y, permission = NA_character_, identifiers = list(), ...) 18 | } 19 | \arguments{ 20 | \item{x}{The object instance to which to remove the rule} 21 | 22 | \item{...}{Additional arguments 23 | \itemize{ 24 | \item \code{permission}: The permission to be remove to subject if x is character (read, write, changePermission) 25 | }} 26 | 27 | \item{y}{The subject of the rule to be removed, or a data.frame containing access rules.} 28 | 29 | \item{permission}{The permission to remove, if parameter \code{x} is a character string containing a \code{subject}.} 30 | 31 | \item{identifiers}{A list of \code{character} values containing package member identifiers that the access rule will be 32 | applied to (default is all package members).} 33 | } 34 | \value{ 35 | The SystemMetadata object with the updated access policy. 36 | 37 | The DataObject object with the updated access policy. 38 | 39 | The Datapackage with members having updated access policies. 40 | } 41 | \description{ 42 | Remove access rules from the access policy of the specified object. 43 | } 44 | \examples{ 45 | # 46 | # Remove access rules from a SystemMetadata object. 47 | # Parameter "y" can be character string containing the subject of the access rule: 48 | sysmeta <- new("SystemMetadata") 49 | sysmeta <- addAccessRule(sysmeta, "uid=smith,ou=Account,dc=example,dc=com", "write") 50 | sysmeta <- addAccessRule(sysmeta, "uid=smith,ou=Account,dc=example,dc=com", "changePermission") 51 | sysmeta <- removeAccessRule(sysmeta, "uid=smith,ou=Account,dc=example,dc=com", "changePermission") 52 | 53 | # Alternatively, parameter "y" can be a data.frame containing one or more access rules: 54 | # Add write, changePermission for uid=jones,... 55 | sysmeta <- addAccessRule(sysmeta, "uid=jones,ou=Account,dc=example,dc=com", "write") 56 | sysmeta <- addAccessRule(sysmeta, "uid=jones,ou=Account,dc=example,dc=com", "changePermission") 57 | # Now take privs for uid=jones,... away 58 | accessRules <- data.frame(subject=c("uid=jones,ou=Account,dc=example,dc=com", 59 | "uid=jones,ou=Account,dc=example,dc=com"), 60 | permission=c("write", "changePermission")) 61 | sysmeta <- removeAccessRule(sysmeta, accessRules) 62 | # 63 | # Remove access rules form a DataObject. 64 | library(datapack) 65 | do <- new("DataObject", file=system.file("./extdata/sample-data.csv", package="datapack"), 66 | format="text/csv") 67 | do <- setPublicAccess(do) 68 | isPublic <- hasAccessRule(do, "public", "read") 69 | accessRules <- data.frame(subject=c("uid=smith,ou=Account,dc=example,dc=com", 70 | "uid=wiggens,o=unaffiliated,dc=example,dc=org"), 71 | permission=c("write", "changePermission"), 72 | stringsAsFactors=FALSE) 73 | do <- addAccessRule(do, accessRules) 74 | do <- removeAccessRule(do, "uid=smith,ou=Account,dc=example,dc=com", "changePermission") 75 | # hasAccessRule should return FALSE 76 | hasWrite <- hasAccessRule(do, "smith", "write") 77 | 78 | # Alternatively, parameter "y" can be a data.frame containing one or more access rules: 79 | do <- addAccessRule(do, "uid=smith,ou=Account,dc=example,dc=com", "write") 80 | accessRules <- data.frame(subject=c("uid=smith,ou=Account,dc=example,dc=com", 81 | "uid=slaughter,o=unaffiliated,dc=example,dc=org"), 82 | permission=c("write", "changePermission")) 83 | sysmeta <- removeAccessRule(do, accessRules) 84 | # 85 | # Remove access rules from a DataPackage. 86 | dp <- new("DataPackage") 87 | data <- charToRaw("1,2,3\n4,5,6\n") 88 | obj <- new("DataObject", id="id1", dataobj=data, format="text/csv") 89 | dp <- addMember(dp, obj) 90 | data2 <- charToRaw("7,8,9\n4,10,11\n") 91 | obj2 <- new("DataObject", id="id2", dataobj=data2, format="text/csv") 92 | dp <- addMember(dp, obj2) 93 | # Add access rule to all package members 94 | dp <- addAccessRule(dp, "uid=smith,ou=Account,dc=example,dc=com", "write") 95 | dp <- addAccessRule(dp, "uid=smith,ou=Account,dc=example,dc=com", "changePermission" ) 96 | # Now take 'changePermission' away for user 'uid=smith...', specifying parameter 'y' 97 | # as a character string containing a 'subject'. 98 | dp <- removeAccessRule(dp, "uid=smith,ou=Account,dc=example,dc=com", "write") 99 | dp <- removeAccessRule(dp, "uid=smith,ou=Account,dc=example,dc=com", "changePermission") 100 | 101 | # Alternatively, parameter "y" can be a data.frame containing one or more access rules: 102 | # Add write, changePermission for uid=jones,... 103 | dp <- addAccessRule(dp, "uid=jones,ou=Account,dc=example,dc=com", "write") 104 | dp <- addAccessRule(dp, "uid=jones,ou=Account,dc=example,dc=com", "changePermission") 105 | # Now take privs for uid=jones,... away 106 | accessRules <- data.frame(subject=c("uid=jones,ou=Account,dc=example,dc=com", 107 | "uid=jones,ou=Account,dc=example,dc=com"), 108 | permission=c("write", "changePermission")) 109 | dp <- removeAccessRule(dp, accessRules) 110 | } 111 | \seealso{ 112 | \code{\link{SystemMetadata-class}} 113 | 114 | \code{\link{DataObject-class}} 115 | 116 | \code{\link{DataPackage-class}} 117 | } 118 | -------------------------------------------------------------------------------- /inst/extdata/sample-eml.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | uid=jsmith,o=unaffiliated,dc=ecoinformatics,dc=org 6 | all 7 | 8 | 9 | public 10 | read 11 | 12 | 13 | 14 | Sample test data 15 | Sample test data for R package "datapack" 16 | 17 | 18 | Mr. 19 | John 20 | Smith 21 | 22 |
23 | NCEAS 24 | University of California 25 | Santa Barbara 26 | California 27 | 93106-6150 28 | United States 29 |
30 | 805 123 4567 31 | jsmith@nceas.ucsb.edu 32 |
33 | 2013-04-10 34 | 35 | This is test data for the R package "datapack". 36 | 37 | 38 | 39 | Arroyo Burro Reef 40 | 41 | -119.7443 42 | -119.7443 43 | 34.4000 44 | 34.4000 45 | 46 | 47 | 48 | 49 | 50 | 2000-08-01 51 | 52 | 53 | 2012-07-25 54 | 55 | 56 | 57 | 58 | 59 | sample-data.csv 60 | sample data for R package "datapack" 61 | 62 | sample-data.csv 63 | ASCII 64 | 3.6 65 | 66 | 67 | 1 68 | \r\n 69 | column 70 | 71 | " 72 | , 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | Species_name 85 | Species name 86 | Name of the plant species 87 | string 88 | 89 | NA 90 | value not recorded or not available 91 | 92 | 93 | 94 | light 95 | Light 96 | Ambient light level 97 | string 98 | 99 | 100 | temp 101 | Temperature 102 | Ambient air temperature in Celsius 103 | string 104 | 105 | 106 | cont 107 | cont 108 | Continentality 109 | string 110 | 111 | 112 | moist 113 | Moisture 114 | Soil Moisture content 115 | string 116 | 117 | 118 | react 119 | Reactivitiy 120 | Reactivity to nutrients 121 | string 122 | 123 | 124 | nutr 125 | Nutrients 126 | Nutriets measured in soil 127 | string 128 | 129 | 130 | 231 131 | 132 |
133 |
-------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## datapack: A Flexible Container to Transport and Manipulate Data and Associated Resources 2 | [![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/datapack)](https://cran.r-project.org/package=datapack) 3 | [![R-CMD-check](https://github.com/ropensci/datapack/workflows/R-CMD-check/badge.svg)](https://github.com/ropensci/datapack/actions) 4 | 5 | - **Author**: Matthew B. Jones and Peter Slaughter and S. Jeanette Clark ([NCEAS](https://www.nceas.ucsb.edu)) 6 | - [doi:10.5063/F1QV3JGM](https://doi.org/10.5063/F1QV3JGM) 7 | - **License**: [Apache 2](https://opensource.org/license/apache-2-0) 8 | - [Package source code on Github](https://github.com/ropensci/datapack) 9 | - [**Submit Bugs and feature requests**](https://github.com/ropensci/datapack/issues) 10 | 11 | The *datapack* R package provides an abstraction for collating 12 | heterogeneous collections of data objects and metadata into a bundle that can 13 | be transported and loaded into a single composite file. The methods in 14 | this package provide a convenient way to load data from common repositories 15 | such as DataONE into the R environment, and to document, serialize, and save 16 | data from R to data repositories worldwide. 17 | 18 | > Note that this package ('datapack') is not related to the similarly named rOpenSci package 'DataPackageR'. 19 | > Documentation from the DataPackageR github repository states that "DataPackageR is used to reproducibly 20 | > process raw data into packaged, analysis-ready data sets." 21 | 22 | ## Installation Notes 23 | 24 | The *datapack* R package requires the R package *redland*. If you are installing on Ubuntu then the Redland C libraries 25 | must be installed before the *redland* and *datapack* package can be installed. If you are installing on Mac OS X or Windows then installing these libraries is not required. 26 | 27 | The following instructions illustrate how to install *datapack* and its requirements. 28 | 29 | ### Installing on Mac OS X 30 | 31 | On Mac OS X datapack can be installed with the following commands: 32 | 33 | ``` 34 | install.packages("datapack") 35 | library(datapack) 36 | ``` 37 | 38 | The *datapack* R package should be available for use at this point. 39 | 40 | Note: if you wish to build the required *redland* package from source before installing *datapack*, please see the redland [installation instructions](https://github.com/ropensci/redland-bindings/tree/master/R/redland). 41 | 42 | ## Installing on Ubuntu 43 | 44 | For Ubuntu, install the required Redland C libraries by entering the following commands 45 | in a terminal window: 46 | 47 | ``` 48 | sudo apt-get update 49 | sudo apt-get install librdf0 librdf0-dev 50 | ``` 51 | 52 | Then install the R packages from the R console: 53 | 54 | ``` 55 | install.packages("datapack") 56 | library(datapack) 57 | ``` 58 | 59 | The *datapack* R package should be available for use at this point 60 | 61 | ## Installing on Windows 62 | 63 | For windows, the required redland R package is distributed as a binary release, so it is not 64 | necessary to install any additional system libraries. 65 | 66 | To install the R packages from the R console: 67 | 68 | ``` 69 | install.packages("datapack") 70 | library(datapack) 71 | ``` 72 | 73 | ## Quick Start 74 | 75 | See the full manual for documentation, but once installed, the package can be run in R using: 76 | 77 | ``` 78 | library(datapack) 79 | help("datapack") 80 | ``` 81 | 82 | Create a DataPackage and add metadata and data DataObjects to it: 83 | 84 | ``` 85 | library(datapack) 86 | library(uuid) 87 | dp <- new("DataPackage") 88 | mdFile <- system.file("extdata/sample-eml.xml", package="datapack") 89 | mdId <- paste("urn:uuid:", UUIDgenerate(), sep="") 90 | md <- new("DataObject", id=mdId, format="eml://ecoinformatics.org/eml-2.1.0", file=mdFile) 91 | addData(dp, md) 92 | 93 | csvfile <- system.file("extdata/sample-data.csv", package="datapack") 94 | sciId <- paste("urn:uuid:", UUIDgenerate(), sep="") 95 | sciObj <- new("DataObject", id=sciId, format="text/csv", filename=csvfile) 96 | dp <- addData(dp, sciObj) 97 | ids <- getIdentifiers(dp) 98 | ``` 99 | 100 | Add a relationship to the DataPackage that shows that the metadata describes, or "documents", the science data: 101 | 102 | ``` 103 | dp <- insertRelationship(dp, subjectID=mdId, objectIDs=sciId) 104 | relations <- getRelationships(dp) 105 | ``` 106 | 107 | Create an Resource Description Framework representation of the relationships in the package: 108 | 109 | ``` 110 | serializationId <- paste("resourceMap", UUIDgenerate(), sep="") 111 | filePath <- file.path(sprintf("%s/%s.rdf", tempdir(), serializationId)) 112 | status <- serializePackage(dp, filePath, id=serializationId, resolveURI="") 113 | ``` 114 | Save the DataPackage to a file, using the BagIt packaging format: 115 | 116 | ``` 117 | bagitFile <- serializeToBagIt(dp) 118 | ``` 119 | 120 | Note that the *dataone* R package can be used to upload a DataPackage to a DataONE Member Node 121 | using the *uploadDataPackage* method. Please see the documentation for the *dataone* R package, 122 | for example: 123 | 124 | ``` 125 | vignette("upload-data", package="dataone") 126 | ``` 127 | 128 | ## Acknowledgements 129 | Work on this package was supported by: 130 | 131 | - NSF-ABI grant #[1262458](https://www.nsf.gov/awardsearch/showAward?AWD_ID=1262458) to C. Gries, M. B. Jones, and S. Collins. 132 | - NSF-DATANET grants #[0830944](https://www.nsf.gov/awardsearch/showAward?AWD_ID=0830944) and #[1430508](https://www.nsf.gov/awardsearch/showAward?AWD_ID=1430508) to W. Michener, M. B. Jones, D. Vieglais, S. Allard and P. Cruse 133 | - NSF DIBBS grant #[1443062](https://www.nsf.gov/awardsearch/showAward?AWD_ID=1443062) to T. Habermann and M. B. Jones 134 | - NSF-PLR grant #[1546024](https://www.nsf.gov/awardsearch/showAward?AWD_ID=1546024) to M. B. Jones, S. Baker-Yeboah, J. Dozier, M. Schildhauer, and A. Budden 135 | - NSF-PLR grant #[2042102](https://www.nsf.gov/awardsearch/showAward?AWD_ID=2042102) to M. B. Jones, A. Budden, J. Dozier, and M. Schildhauer 136 | 137 | Additional support was provided for working group collaboration by the National Center for Ecological Analysis and Synthesis, a Center funded by the University of California, Santa Barbara, and the State of California. 138 | 139 | [![nceas_footer](https://live-ncea-ucsb-edu-v01.pantheonsite.io/sites/default/files/2020-03/NCEAS-full%20logo-4C.png)](https://www.nceas.ucsb.edu) 140 | 141 | [![dataone_footer](https://user-images.githubusercontent.com/6643222/162324180-b5cf0f5f-ae7a-4ca6-87c3-9733a2590634.png)](https://www.dataone.org) 142 | 143 | [![ropensci_footer](https://ropensci.org/public_images/github_footer.png)](https://ropensci.org/) 144 | -------------------------------------------------------------------------------- /inst/extdata/resourceMap-sample.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | urn:uuid:c994e155-b730-4707-8825-4fd1347d24f1 23 | 24 | 25 | urn:uuid:0f33c9d6-57db-46ab-83e9-c1b808d7fdc6 26 | 27 | 28 | 29 | 30 | 31 | urn:uuid:9fcf1700-e1d7-4c19-b795-6690425e3513 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | urn:uuid:615206e1-e172-43e7-99ec-3de618690460 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | DataONE Aggregation 74 | 75 | 76 | urn:uuid:e1f9f28a-c7ee-4e67-acb5-ca9796fd9fd8 77 | 78 | 79 | -------------------------------------------------------------------------------- /tests/testthat/test.ResourceMap.R: -------------------------------------------------------------------------------- 1 | test_that("datapack library loads", { 2 | expect_true(library(datapack, logical.return=TRUE)) 3 | }) 4 | test_that("ResourceMap initialization", { 5 | expect_true(library(datapack, logical.return=TRUE)) 6 | resMap <- new("ResourceMap") 7 | 8 | }) 9 | test_that("ResourceMap creation from DataPackage triples", { 10 | library(datapack) 11 | library(redland) 12 | library(uuid) 13 | 14 | D1ResolveURI <- "https://cn.dataone.org/cn/v2/resolve/" 15 | dp <- new("DataPackage") 16 | # Add colons to the id names, so we can check the URL encoding, decoding 17 | # in the serialzed resource map (URLs encoded, dcterms:identifier not encoded). 18 | mdId <- sprintf("scimetaId:%s", UUIDgenerate()) 19 | doInId <- sprintf("scidataId:%s", UUIDgenerate()) 20 | doOutId <- sprintf("sciprodId:%s", UUIDgenerate()) 21 | executionId <- sprintf("execution:%s", UUIDgenerate()) 22 | 23 | # See if the resolve URI is added only once to serialized id 24 | doId2 <- paste(D1ResolveURI, "id2", sep="") 25 | doId2 <- sprintf("%s/id2:%s", D1ResolveURI, UUIDgenerate()) 26 | 27 | user <- "smith" 28 | data <- charToRaw("1,2,3\n4,5,6") 29 | format <- "text/csv" 30 | node <- "urn:node:KNB" 31 | md1 <- new("DataObject", id=mdId, data, format="eml://ecoinformatics.org/eml-2.1.1", user, node) 32 | doIn <- new("DataObject", id=doInId, data, format, user, node) 33 | doOut <- new("DataObject", id=doOutId, data, format, user, node) 34 | dp <- addMember(dp, md1) 35 | dp <- addMember(dp, doIn) 36 | dp <- addMember(dp, doOut) 37 | 38 | # Insert metadata document <-> relationships 39 | dp <- insertRelationship(dp, subjectID=mdId, objectIDs=c(doOutId)) 40 | 41 | # Insert a typical provenance relationship 42 | dp <- insertRelationship(dp, subjectID=doOutId, objectIDs=doInId, predicate="http://www.w3.org/ns/prov#wasDerivedFrom") 43 | dp <- insertRelationship(dp, subjectID=executionId, objectIDs=doInId, predicate="http://www.w3.org/ns/prov#used") 44 | dp <- insertRelationship(dp, subjectID=doOutId, objectIDs=executionId, predicate="http://www.w3.org/ns/prov#wasGeneratedBy") 45 | dp <- insertRelationship(dp, subjectID=doId2, objectIDs=doOutId, predicate="http://www.w3.org/ns/prov#wasInformedBy") 46 | dp <- insertRelationship(dp, subjectID=executionId, objectIDs="2015-01-01T10:02:00", predicate="http://www.w3.org/ns/prov#startedAtTime") 47 | 48 | relations <- getRelationships(dp) 49 | # Test if the data frame with retrieved relationships was constructed correctly 50 | expect_equal(nrow(relations), 7) 51 | expect_match(relations[relations$subject == mdId, 'predicate'], "documents") 52 | 53 | # Now initialize a ResourceMap with the relationships. 54 | resMapId <- sprintf("resourceMap:%s", UUIDgenerate()) 55 | resMap <- new("ResourceMap", id=resMapId) 56 | expect_equal(class(resMap)[[1]], "ResourceMap") 57 | resMap <- createFromTriples(resMap, relations, getIdentifiers(dp)) 58 | 59 | # Serialize the ResourceMap to a file. 60 | filePath <- sprintf("%s/%s.rdf", tempdir(), resMapId) 61 | status <- serializeRDF(resMap, filePath) 62 | found <- grep("wasDerivedFrom", readLines(filePath)) 63 | expect_gt(length(found), 0) 64 | 65 | freeResourceMap(resMap) 66 | rm(resMap) 67 | 68 | unlink(filePath) 69 | 70 | }) 71 | 72 | test_that("Resource map parsing works", { 73 | 74 | # Test methods with a DataPackage that has only one member and no package relationships 75 | #resMap <- new("ResourceMap", id="urn-uuid-5f3780e4-94a9-4ee6-996e-6b9f0a380f1a") 76 | #resMap <- parseRDF(resMap, rdf="/Users/slaughter/Downloads/resmap.rdf", asText=FALSE) 77 | 78 | resMap <- new("ResourceMap") 79 | resMap <- parseRDF(resMap, rdf=system.file("./extdata/resourceMap-sample.xml", package="datapack"), 80 | asText=FALSE) 81 | 82 | # Package member ids would typically be obtained from the 'documents' relationship from DataONE solr index, 83 | # but we don't have that available for this test, so they are manually entered here, to assist in the 84 | # DataONE identifier 'demotion'. 85 | ids <- c("urn:uuid:c994e155-b730-4707-8825-4fd1347d24f1", 86 | "urn:uuid:0f33c9d6-57db-46ab-83e9-c1b808d7fdc6", 87 | "urn:uuid:9fcf1700-e1d7-4c19-b795-6690425e3513", 88 | "urn:uuid:615206e1-e172-43e7-99ec-3de618690460", 89 | "urn:uuid:e1f9f28a-c7ee-4e67-acb5-ca9796fd9fd8") 90 | 91 | relations <- data.frame(row.names=NULL, stringsAsFactors=F) 92 | 93 | parser <- new("Parser", resMap@world) 94 | # Query the RDF model with a SPARQL query that should return all triples 95 | queryString <- 'SELECT ?s ?p ?o WHERE { ?s ?p ?o . }' 96 | queryObj <- new("Query", resMap@world, queryString, base_uri=NULL, query_language="sparql", query_uri=NULL) 97 | 98 | relations <- getTriples(resMap, identifiers=ids) 99 | 100 | status <- freeResourceMap(resMap) 101 | 102 | execId <- relations[relations$object == datapack:::provONEexecution,'subject'] 103 | expect_match(execId, "urn:uuid:c994e155-b730-4707-8825-4fd1347d24f1") 104 | expect_match(relations[relations$predicate == datapack:::provWasGeneratedBy,'subject'], "urn:uuid:0f33c9d6-57db-46ab-83e9-c1b808d7fdc6") 105 | expect_match(relations[relations$predicate == datapack:::provUsed,'object'], "urn:uuid:e1f9f28a-c7ee-4e67-acb5-ca9796fd9fd8") 106 | expect_match(relations[relations$predicate == datapack:::provWasGeneratedBy,'object'], execId) 107 | expect_match(relations[relations$predicate == datapack:::provUsed,'subject'], execId) 108 | 109 | expect_match(relations[relations$predicate == datapack:::provHadPlan,'object'], "urn:uuid:615206e1-e172-43e7-99ec-3de618690460") 110 | expect_match(relations[relations$predicate == datapack:::provWasDerivedFrom,'subject'], "urn:uuid:0f33c9d6-57db-46ab-83e9-c1b808d7fdc6") 111 | expect_match(relations[relations$predicate == datapack:::provWasDerivedFrom,'object'], "urn:uuid:e1f9f28a-c7ee-4e67-acb5-ca9796fd9fd8") 112 | 113 | 114 | # Another test of parsing a DataONE resource map 115 | 116 | resMap <- new("ResourceMap") 117 | resMap <- parseRDF(resMap, rdf=system.file("./extdata/hcdb-resmap.xml", package="datapack"), 118 | asText=FALSE) 119 | 120 | relations <- data.frame(row.names=NULL, stringsAsFactors=F) 121 | 122 | parser <- new("Parser", resMap@world) 123 | # Query the RDF model with a SPARQL query that should return all triples 124 | queryString <- 'SELECT ?s ?p ?o WHERE { ?s ?p ?o . }' 125 | queryObj <- new("Query", resMap@world, queryString, base_uri=NULL, query_language="sparql", query_uri=NULL) 126 | 127 | relations <- getTriples(resMap, filter=FALSE) 128 | 129 | status <- freeResourceMap(resMap) 130 | 131 | #execId <- relations[relations$object == datapack:::provONEexecution,'subject'] 132 | 133 | expect_match(relations[relations$predicate == datapack:::foafName, 'object'], "DataONE R Client") 134 | 135 | }) 136 | -------------------------------------------------------------------------------- /inst/extdata/pkg-example/binary.csv: -------------------------------------------------------------------------------- 1 | admit,gre,gpa,rank 2 | 0,380,3.61,3 3 | 1,660,3.67,3 4 | 1,800,4,1 5 | 1,640,3.19,4 6 | 0,520,2.93,4 7 | 1,760,3,2 8 | 1,560,2.98,1 9 | 0,400,3.08,2 10 | 1,540,3.39,3 11 | 0,700,3.92,2 12 | 0,800,4,4 13 | 0,440,3.22,1 14 | 1,760,4,1 15 | 0,700,3.08,2 16 | 1,700,4,1 17 | 0,480,3.44,3 18 | 0,780,3.87,4 19 | 0,360,2.56,3 20 | 0,800,3.75,2 21 | 1,540,3.81,1 22 | 0,500,3.17,3 23 | 1,660,3.63,2 24 | 0,600,2.82,4 25 | 0,680,3.19,4 26 | 1,760,3.35,2 27 | 1,800,3.66,1 28 | 1,620,3.61,1 29 | 1,520,3.74,4 30 | 1,780,3.22,2 31 | 0,520,3.29,1 32 | 0,540,3.78,4 33 | 0,760,3.35,3 34 | 0,600,3.4,3 35 | 1,800,4,3 36 | 0,360,3.14,1 37 | 0,400,3.05,2 38 | 0,580,3.25,1 39 | 0,520,2.9,3 40 | 1,500,3.13,2 41 | 1,520,2.68,3 42 | 0,560,2.42,2 43 | 1,580,3.32,2 44 | 1,600,3.15,2 45 | 0,500,3.31,3 46 | 0,700,2.94,2 47 | 1,460,3.45,3 48 | 1,580,3.46,2 49 | 0,500,2.97,4 50 | 0,440,2.48,4 51 | 0,400,3.35,3 52 | 0,640,3.86,3 53 | 0,440,3.13,4 54 | 0,740,3.37,4 55 | 1,680,3.27,2 56 | 0,660,3.34,3 57 | 1,740,4,3 58 | 0,560,3.19,3 59 | 0,380,2.94,3 60 | 0,400,3.65,2 61 | 0,600,2.82,4 62 | 1,620,3.18,2 63 | 0,560,3.32,4 64 | 0,640,3.67,3 65 | 1,680,3.85,3 66 | 0,580,4,3 67 | 0,600,3.59,2 68 | 0,740,3.62,4 69 | 0,620,3.3,1 70 | 0,580,3.69,1 71 | 0,800,3.73,1 72 | 0,640,4,3 73 | 0,300,2.92,4 74 | 0,480,3.39,4 75 | 0,580,4,2 76 | 0,720,3.45,4 77 | 0,720,4,3 78 | 0,560,3.36,3 79 | 1,800,4,3 80 | 0,540,3.12,1 81 | 1,620,4,1 82 | 0,700,2.9,4 83 | 0,620,3.07,2 84 | 0,500,2.71,2 85 | 0,380,2.91,4 86 | 1,500,3.6,3 87 | 0,520,2.98,2 88 | 0,600,3.32,2 89 | 0,600,3.48,2 90 | 0,700,3.28,1 91 | 1,660,4,2 92 | 0,700,3.83,2 93 | 1,720,3.64,1 94 | 0,800,3.9,2 95 | 0,580,2.93,2 96 | 1,660,3.44,2 97 | 0,660,3.33,2 98 | 0,640,3.52,4 99 | 0,480,3.57,2 100 | 0,700,2.88,2 101 | 0,400,3.31,3 102 | 0,340,3.15,3 103 | 0,580,3.57,3 104 | 0,380,3.33,4 105 | 0,540,3.94,3 106 | 1,660,3.95,2 107 | 1,740,2.97,2 108 | 1,700,3.56,1 109 | 0,480,3.13,2 110 | 0,400,2.93,3 111 | 0,480,3.45,2 112 | 0,680,3.08,4 113 | 0,420,3.41,4 114 | 0,360,3,3 115 | 0,600,3.22,1 116 | 0,720,3.84,3 117 | 0,620,3.99,3 118 | 1,440,3.45,2 119 | 0,700,3.72,2 120 | 1,800,3.7,1 121 | 0,340,2.92,3 122 | 1,520,3.74,2 123 | 1,480,2.67,2 124 | 0,520,2.85,3 125 | 0,500,2.98,3 126 | 0,720,3.88,3 127 | 0,540,3.38,4 128 | 1,600,3.54,1 129 | 0,740,3.74,4 130 | 0,540,3.19,2 131 | 0,460,3.15,4 132 | 1,620,3.17,2 133 | 0,640,2.79,2 134 | 0,580,3.4,2 135 | 0,500,3.08,3 136 | 0,560,2.95,2 137 | 0,500,3.57,3 138 | 0,560,3.33,4 139 | 0,700,4,3 140 | 0,620,3.4,2 141 | 1,600,3.58,1 142 | 0,640,3.93,2 143 | 1,700,3.52,4 144 | 0,620,3.94,4 145 | 0,580,3.4,3 146 | 0,580,3.4,4 147 | 0,380,3.43,3 148 | 0,480,3.4,2 149 | 0,560,2.71,3 150 | 1,480,2.91,1 151 | 0,740,3.31,1 152 | 1,800,3.74,1 153 | 0,400,3.38,2 154 | 1,640,3.94,2 155 | 0,580,3.46,3 156 | 0,620,3.69,3 157 | 1,580,2.86,4 158 | 0,560,2.52,2 159 | 1,480,3.58,1 160 | 0,660,3.49,2 161 | 0,700,3.82,3 162 | 0,600,3.13,2 163 | 0,640,3.5,2 164 | 1,700,3.56,2 165 | 0,520,2.73,2 166 | 0,580,3.3,2 167 | 0,700,4,1 168 | 0,440,3.24,4 169 | 0,720,3.77,3 170 | 0,500,4,3 171 | 0,600,3.62,3 172 | 0,400,3.51,3 173 | 0,540,2.81,3 174 | 0,680,3.48,3 175 | 1,800,3.43,2 176 | 0,500,3.53,4 177 | 1,620,3.37,2 178 | 0,520,2.62,2 179 | 1,620,3.23,3 180 | 0,620,3.33,3 181 | 0,300,3.01,3 182 | 0,620,3.78,3 183 | 0,500,3.88,4 184 | 0,700,4,2 185 | 1,540,3.84,2 186 | 0,500,2.79,4 187 | 0,800,3.6,2 188 | 0,560,3.61,3 189 | 0,580,2.88,2 190 | 0,560,3.07,2 191 | 0,500,3.35,2 192 | 1,640,2.94,2 193 | 0,800,3.54,3 194 | 0,640,3.76,3 195 | 0,380,3.59,4 196 | 1,600,3.47,2 197 | 0,560,3.59,2 198 | 0,660,3.07,3 199 | 1,400,3.23,4 200 | 0,600,3.63,3 201 | 0,580,3.77,4 202 | 0,800,3.31,3 203 | 1,580,3.2,2 204 | 1,700,4,1 205 | 0,420,3.92,4 206 | 1,600,3.89,1 207 | 1,780,3.8,3 208 | 0,740,3.54,1 209 | 1,640,3.63,1 210 | 0,540,3.16,3 211 | 0,580,3.5,2 212 | 0,740,3.34,4 213 | 0,580,3.02,2 214 | 0,460,2.87,2 215 | 0,640,3.38,3 216 | 1,600,3.56,2 217 | 1,660,2.91,3 218 | 0,340,2.9,1 219 | 1,460,3.64,1 220 | 0,460,2.98,1 221 | 1,560,3.59,2 222 | 0,540,3.28,3 223 | 0,680,3.99,3 224 | 1,480,3.02,1 225 | 0,800,3.47,3 226 | 0,800,2.9,2 227 | 1,720,3.5,3 228 | 0,620,3.58,2 229 | 0,540,3.02,4 230 | 0,480,3.43,2 231 | 1,720,3.42,2 232 | 0,580,3.29,4 233 | 0,600,3.28,3 234 | 0,380,3.38,2 235 | 0,420,2.67,3 236 | 1,800,3.53,1 237 | 0,620,3.05,2 238 | 1,660,3.49,2 239 | 0,480,4,2 240 | 0,500,2.86,4 241 | 0,700,3.45,3 242 | 0,440,2.76,2 243 | 1,520,3.81,1 244 | 1,680,2.96,3 245 | 0,620,3.22,2 246 | 0,540,3.04,1 247 | 0,800,3.91,3 248 | 0,680,3.34,2 249 | 0,440,3.17,2 250 | 0,680,3.64,3 251 | 0,640,3.73,3 252 | 0,660,3.31,4 253 | 0,620,3.21,4 254 | 1,520,4,2 255 | 1,540,3.55,4 256 | 1,740,3.52,4 257 | 0,640,3.35,3 258 | 1,520,3.3,2 259 | 1,620,3.95,3 260 | 0,520,3.51,2 261 | 0,640,3.81,2 262 | 0,680,3.11,2 263 | 0,440,3.15,2 264 | 1,520,3.19,3 265 | 1,620,3.95,3 266 | 1,520,3.9,3 267 | 0,380,3.34,3 268 | 0,560,3.24,4 269 | 1,600,3.64,3 270 | 1,680,3.46,2 271 | 0,500,2.81,3 272 | 1,640,3.95,2 273 | 0,540,3.33,3 274 | 1,680,3.67,2 275 | 0,660,3.32,1 276 | 0,520,3.12,2 277 | 1,600,2.98,2 278 | 0,460,3.77,3 279 | 1,580,3.58,1 280 | 1,680,3,4 281 | 1,660,3.14,2 282 | 0,660,3.94,2 283 | 0,360,3.27,3 284 | 0,660,3.45,4 285 | 0,520,3.1,4 286 | 1,440,3.39,2 287 | 0,600,3.31,4 288 | 1,800,3.22,1 289 | 1,660,3.7,4 290 | 0,800,3.15,4 291 | 0,420,2.26,4 292 | 1,620,3.45,2 293 | 0,800,2.78,2 294 | 0,680,3.7,2 295 | 0,800,3.97,1 296 | 0,480,2.55,1 297 | 0,520,3.25,3 298 | 0,560,3.16,1 299 | 0,460,3.07,2 300 | 0,540,3.5,2 301 | 0,720,3.4,3 302 | 0,640,3.3,2 303 | 1,660,3.6,3 304 | 1,400,3.15,2 305 | 1,680,3.98,2 306 | 0,220,2.83,3 307 | 0,580,3.46,4 308 | 1,540,3.17,1 309 | 0,580,3.51,2 310 | 0,540,3.13,2 311 | 0,440,2.98,3 312 | 0,560,4,3 313 | 0,660,3.67,2 314 | 0,660,3.77,3 315 | 1,520,3.65,4 316 | 0,540,3.46,4 317 | 1,300,2.84,2 318 | 1,340,3,2 319 | 1,780,3.63,4 320 | 1,480,3.71,4 321 | 0,540,3.28,1 322 | 0,460,3.14,3 323 | 0,460,3.58,2 324 | 0,500,3.01,4 325 | 0,420,2.69,2 326 | 0,520,2.7,3 327 | 0,680,3.9,1 328 | 0,680,3.31,2 329 | 1,560,3.48,2 330 | 0,580,3.34,2 331 | 0,500,2.93,4 332 | 0,740,4,3 333 | 0,660,3.59,3 334 | 0,420,2.96,1 335 | 0,560,3.43,3 336 | 1,460,3.64,3 337 | 1,620,3.71,1 338 | 0,520,3.15,3 339 | 0,620,3.09,4 340 | 0,540,3.2,1 341 | 1,660,3.47,3 342 | 0,500,3.23,4 343 | 1,560,2.65,3 344 | 0,500,3.95,4 345 | 0,580,3.06,2 346 | 0,520,3.35,3 347 | 0,500,3.03,3 348 | 0,600,3.35,2 349 | 0,580,3.8,2 350 | 0,400,3.36,2 351 | 0,620,2.85,2 352 | 1,780,4,2 353 | 0,620,3.43,3 354 | 1,580,3.12,3 355 | 0,700,3.52,2 356 | 1,540,3.78,2 357 | 1,760,2.81,1 358 | 0,700,3.27,2 359 | 0,720,3.31,1 360 | 1,560,3.69,3 361 | 0,720,3.94,3 362 | 1,520,4,1 363 | 1,540,3.49,1 364 | 0,680,3.14,2 365 | 0,460,3.44,2 366 | 1,560,3.36,1 367 | 0,480,2.78,3 368 | 0,460,2.93,3 369 | 0,620,3.63,3 370 | 0,580,4,1 371 | 0,800,3.89,2 372 | 1,540,3.77,2 373 | 1,680,3.76,3 374 | 1,680,2.42,1 375 | 1,620,3.37,1 376 | 0,560,3.78,2 377 | 0,560,3.49,4 378 | 0,620,3.63,2 379 | 1,800,4,2 380 | 0,640,3.12,3 381 | 0,540,2.7,2 382 | 0,700,3.65,2 383 | 1,540,3.49,2 384 | 0,540,3.51,2 385 | 0,660,4,1 386 | 1,480,2.62,2 387 | 0,420,3.02,1 388 | 1,740,3.86,2 389 | 0,580,3.36,2 390 | 0,640,3.17,2 391 | 0,640,3.51,2 392 | 1,800,3.05,2 393 | 1,660,3.88,2 394 | 1,600,3.38,3 395 | 1,620,3.75,2 396 | 1,460,3.99,3 397 | 0,620,4,2 398 | 0,560,3.04,3 399 | 0,460,2.63,2 400 | 0,700,3.65,2 401 | 0,600,3.89,3 402 | -------------------------------------------------------------------------------- /inst/extdata/sample-data.csv: -------------------------------------------------------------------------------- 1 | "Species_Name","light","temp","cont","moist","react","nutr" 2 | "Achillea millefolium ",8,0,0,4,0,5 3 | "Achillea tanacetifolia",0,0,0,0,0,0 4 | "Aconitum lycoctonum",3,4,4,7,7,8 5 | "Aconitum variegatum",5,4,4,7,8,7 6 | "Actaea spicata",3,5,4,5,6,7 7 | "Aegopodium podagraria",5,5,3,6,7,8 8 | "Aethusa cynapium",5,6,4,5,7,7 9 | "Agrostis canina",9,5,5,9,3,2 10 | "Agrostis capillaris",7,0,3,0,4,4 11 | "Agrostis stolonifera",8,0,5,7,0,5 12 | "Ajuga genevensis",8,0,0,3,7,2 13 | "Ajuga reptans",6,0,2,6,6,6 14 | "Alisma plantago-aquatica",7,5,0,10,0,8 15 | "Alliaria petiolata",5,6,3,5,7,9 16 | "Allium senescens ssp. montanum",9,0,5,2,6,2 17 | "Allium species",0,0,0,0,0,0 18 | "Anemone nemorosa",0,0,3,5,0,0 19 | "Angelica sylvestris",7,0,4,8,0,4 20 | "Anthericum ramosum",7,5,4,3,7,3 21 | "Anthriscus sylvestris",7,0,5,5,0,8 22 | "Arrhenatherum elatius",8,5,3,0,7,7 23 | "Artemisia vulgaris",7,6,0,6,0,8 24 | "Asarum europaeum",3,6,5,5,7,6 25 | "Asplenium septentrionale",8,0,4,3,2,2 26 | "Asplenium trichomanes",5,0,3,5,0,3 27 | "Astragalus glycyphyllos",6,6,4,4,7,3 28 | "Athyrium filix-femina",3,0,3,7,0,6 29 | "Aurinia saxatilis ssp. arduini",9,7,4,2,8,1 30 | "Avenella flexuosa",6,0,2,0,2,3 31 | "Betonica officinalis",7,6,5,0,0,3 32 | "Bidens frondosa",7,6,0,8,7,8 33 | "Bidens tripartita",8,6,0,9,0,8 34 | "Brachypodium pinnatum",6,5,5,4,7,4 35 | "Bromus benekenii",5,5,4,5,7,5 36 | "Calamagrostis arundinacea",6,5,4,5,4,5 37 | "Calamagrostis epigejos",7,5,7,0,0,6 38 | "Calluna vulgaris",8,0,3,0,1,1 39 | "Caltha palustris",7,0,0,9,0,6 40 | "Calystegia sepium",8,6,5,6,7,9 41 | "Campanula patula",8,6,4,5,7,5 42 | "Campanula persicifolia",5,5,4,4,8,3 43 | "Campanula rapunculoides",6,6,4,4,7,4 44 | "Campanula rotundifolia",7,5,0,0,0,2 45 | "Campanula trachelium",4,0,3,6,8,8 46 | "Cardamine amara",7,0,4,9,6,4 47 | "Cardamine flexuosa",6,5,2,8,4,5 48 | "Cardamine impatiens",5,0,4,6,7,8 49 | "Cardaminopsis arenosa",9,0,4,4,6,2 50 | "Carduus personata",7,4,2,8,8,8 51 | "Carduus species",0,0,0,0,0,0 52 | "Carex acuta",7,5,7,9,6,4 53 | "Carex brizoides",6,5,4,6,4,3 54 | "Carex buekii",8,6,6,8,8,6 55 | "Carex digitata",3,0,4,5,0,4 56 | "Carex muricata agg.",0,0,0,0,0,0 57 | "Carex species",0,0,0,0,0,0 58 | "Chaerophyllum hirsutum",6,3,4,8,0,7 59 | "Chaerophyllum temulum",5,6,3,5,0,8 60 | "Chelidonium majus",6,6,0,5,0,8 61 | "Circaea alpina",4,4,4,7,5,5 62 | "Cirsium oleraceum",6,0,3,7,7,5 63 | "Clematis vitalba",7,6,3,5,7,7 64 | "Clinopodium vulgare",7,0,3,4,7,3 65 | "Convallaria majalis",5,0,3,4,0,4 66 | "Convolvulus arvensis",7,6,0,4,7,0 67 | "Cuscuta europaea",0,6,5,7,0,7 68 | "Cymbalaria muralis",7,7,4,6,8,5 69 | "Cystopteris fragilis",5,0,3,7,8,4 70 | "Cytisus nigricans",6,6,5,4,6,2 71 | "Dactylis glomerata",7,0,3,5,0,6 72 | "Danthonia decumbens",8,0,2,0,3,2 73 | "Deschampsia cespitosa",6,0,0,7,0,3 74 | "Dianthus carthusianorum ssp. carthusianorum",8,5,4,3,7,2 75 | "Dianthus deltoides",8,5,4,3,3,2 76 | "Digitalis grandiflora",7,4,4,5,5,5 77 | "Doronicum austriacum",5,3,4,6,7,7 78 | "Dryopteris carthusiana",5,0,3,0,4,3 79 | "Dryopteris dilatata",4,0,3,6,0,7 80 | "Dryopteris expansa",4,3,0,6,2,2 81 | "Dryopteris filix-mas",3,0,3,5,5,6 82 | "Elymus caninus",6,6,3,6,7,8 83 | "Epilobium angustifolium",8,0,5,5,5,8 84 | "Epilobium collinum",8,4,5,5,2,2 85 | "Epilobium hirsutum",7,5,5,8,8,8 86 | "Epilobium montanum",4,0,3,5,6,6 87 | "Epilobium roseum",7,6,4,9,8,8 88 | "Epilobium species",0,0,0,0,0,0 89 | "Equisetum arvense",6,0,0,0,0,3 90 | "Equisetum palustre",7,0,5,8,0,3 91 | "Euphorbia cyparissias",8,0,4,3,0,3 92 | "Euphorbia dulcis",4,5,2,5,8,5 93 | "Fallopia convolvulus",7,6,0,5,0,6 94 | "Fallopia dumetorum",6,6,4,5,0,7 95 | "Festuca gigantea",4,5,3,7,6,6 96 | "Festuca heterophylla",5,6,4,4,5,5 97 | "Festuca ovina",7,0,3,0,3,1 98 | "Festuca pallens",9,7,4,2,8,1 99 | "Festuca rubra",0,0,5,6,6,0 100 | "Filipendula ulmaria",7,5,0,8,0,5 101 | "Fragaria moschata",6,6,4,5,6,6 102 | "Fragaria vesca",7,0,5,5,0,6 103 | "Galeobdolon montanum",3,4,5,6,7,6 104 | "Galeopsis bifida",7,5,5,5,6,6 105 | "Galeopsis pubescens",7,5,4,5,0,6 106 | "Galeopsis species",0,0,0,0,0,0 107 | "Galeopsis speciosa",7,0,6,5,0,8 108 | "Galium album ssp. album",7,0,3,5,7,5 109 | "Galium aparine",7,6,3,0,6,8 110 | "Galium odoratum",2,5,2,5,6,5 111 | "Galium palustre",6,5,3,9,0,4 112 | "Galium rotundifolium",2,5,2,5,5,4 113 | "Galium sylvaticum",5,5,4,5,6,5 114 | "Galium uliginosum",6,5,0,8,0,2 115 | "Genista germanica",7,5,4,4,2,2 116 | "Genista tinctoria",8,6,3,6,6,1 117 | "Geranium robertianum",5,0,3,0,0,7 118 | "Geum urbanum",4,5,5,5,0,7 119 | "Glechoma hederacea",6,6,3,6,0,7 120 | "Glyceria fluitans",7,0,3,9,0,7 121 | "Glyceria maxima",9,5,0,10,8,9 122 | "Gymnocarpium dryopteris",3,4,5,6,4,5 123 | "Hedera helix",4,5,2,5,0,0 124 | "Hepatica nobilis",4,6,4,4,7,5 125 | "Heracleum sphondylium",7,5,2,5,0,8 126 | "Hieracium lachenalii",5,5,0,4,4,2 127 | "Hieracium murorum",4,0,3,5,5,4 128 | "Hieracium pilosella",7,0,3,4,0,2 129 | "Hieracium sabaudum",5,6,3,4,4,2 130 | "Hieracium umbellatum",6,6,0,4,4,2 131 | "Holcus lanatus",7,6,3,6,0,5 132 | "Humulus lupulus",7,6,3,8,6,8 133 | "Hylotelephium maximum",8,6,4,3,5,3 134 | "Hypericum montanum",5,6,4,4,7,3 135 | "Hypericum perforatum",7,6,5,4,6,4 136 | "Impatiens glandulifera",5,7,2,8,7,7 137 | "Impatiens noli-tangere",4,5,5,7,7,6 138 | "Impatiens parviflora",4,6,5,5,0,6 139 | "Iris pseudacorus",7,6,3,9,0,7 140 | "Juncus articulatus",8,0,3,9,0,2 141 | "Juncus effusus",8,5,3,7,3,4 142 | "Knautia arvensis",7,6,3,4,0,4 143 | "Knautia dipsacifolia",5,4,4,6,6,6 144 | "Koeleria pyramidata s.lat.",0,0,0,0,0,0 145 | "Lactuca serriola",9,7,7,4,0,4 146 | "Lamium maculatum",5,0,4,6,7,8 147 | "Lapsana communis",5,6,3,5,0,7 148 | "Lathyrus vernus",4,6,4,5,8,4 149 | "Lilium martagon",4,0,5,5,7,5 150 | "Lunaria rediviva",4,5,4,6,7,8 151 | "Luzula luzuloides",4,0,4,5,3,4 152 | "Luzula pilosa",2,0,3,5,5,4 153 | "Lychnis viscaria",7,6,4,3,4,2 154 | "Lycopus europaeus",7,6,5,9,7,7 155 | "Lysimachia vulgaris",6,0,0,8,0,0 156 | "Lythrum salicaria",7,5,5,8,6,0 157 | "Melampyrum nemorosum",5,6,4,4,6,4 158 | "Melampyrum pratense",0,0,3,0,3,2 159 | "Melica nutans",4,0,3,4,0,3 160 | "Mentha longifolia",7,5,4,8,9,7 161 | "Mentha x verticillata",7,5,0,8,7,0 162 | "Mercurialis perennis",2,0,3,0,8,7 163 | "Milium effusum",4,0,3,5,5,5 164 | "Moehringia trinervia",4,5,3,5,6,7 165 | "Mycelis muralis",4,6,2,5,0,6 166 | "Myosotis palustris agg.",7,0,5,8,0,5 167 | "Myosotis sylvatica",6,0,3,5,0,7 168 | "Myosoton aquaticum",7,5,3,8,7,8 169 | "Origanum vulgare",7,0,3,3,8,3 170 | "Oxalis acetosella",1,0,3,5,4,6 171 | "Paris quadrifolia",3,0,4,6,7,7 172 | "Persicaria amphibia",7,6,0,11,6,4 173 | "Persicaria hydropiper",7,6,0,8,5,8 174 | "Phalaris arundinacea",7,5,0,8,7,7 175 | "Pimpinella saxifraga ssp. saxifraga",7,0,5,3,0,2 176 | "Plantago lanceolata",6,0,3,0,0,0 177 | "Poa angustifolia",7,6,0,0,0,3 178 | "Poa nemoralis",5,0,5,5,5,4 179 | "Poa palustris",7,5,5,9,8,7 180 | "Poa trivialis",6,0,3,7,0,7 181 | "Polygonatum multiflorum",2,0,5,5,6,5 182 | "Polygonatum odoratum",7,5,5,3,7,3 183 | "Polypodium vulgare",5,5,3,4,2,2 184 | "Prenanthes purpurea",4,4,4,5,5,5 185 | "Pulmonaria obscura",4,5,6,6,8,7 186 | "Ranunculus lanuginosus",3,6,4,6,7,7 187 | "Ranunculus repens",6,0,0,7,0,7 188 | "Rumex acetosella",8,5,3,3,2,2 189 | "Rumex aquaticus",7,6,7,8,7,8 190 | "Rumex conglomeratus",8,6,3,7,0,8 191 | "Rumex obtusifolius",7,5,3,6,0,9 192 | "Salvia glutinosa",4,5,4,6,7,7 193 | "Scrophularia nodosa",4,5,3,6,6,7 194 | "Scutellaria galericulata",7,6,5,9,7,6 195 | "Securigera varia",7,6,5,4,9,3 196 | "Senecio germanicus",0,0,0,0,0,0 197 | "Senecio ovatus",7,0,4,5,0,8 198 | "Senecio viscosus",8,6,4,3,0,4 199 | "Silene nutans",7,0,5,3,7,3 200 | "Silene species",0,0,0,0,0,0 201 | "Silene vulgaris",8,0,0,4,7,4 202 | "Solanum dulcamara",7,5,0,8,0,8 203 | "Solidago virgaurea",5,0,0,5,0,4 204 | "Stachys palustris",7,5,0,7,7,6 205 | "Stachys sylvatica",4,0,3,7,7,7 206 | "Stellaria graminea",6,0,0,5,4,3 207 | "Stellaria holostea",5,6,3,5,6,5 208 | "Stellaria media",6,0,0,0,7,8 209 | "Stellaria nemorum",4,0,4,7,5,7 210 | "Symphytum officinale",7,6,3,7,0,8 211 | "Taraxacum species",0,0,0,0,0,0 212 | "Thymus pulegioides",8,0,4,4,0,1 213 | "Torilis japonica",6,6,3,5,8,8 214 | "Trifolium alpestre",7,6,4,3,6,3 215 | "Urtica dioica",0,0,0,6,7,9 216 | "Vaccinium myrtillus",5,0,5,0,2,3 217 | "Vaccinium vitis-idaea",5,0,5,4,2,1 218 | "Valeriana excelsa ssp. sambucifolia",7,6,5,8,6,5 219 | "Verbascum densiflorum",8,6,5,4,8,5 220 | "Verbascum nigrum",7,5,5,5,7,7 221 | "Verbascum species",0,0,0,0,0,0 222 | "Veronica beccabunga",7,0,3,10,7,6 223 | "Veronica chamaedrys",6,0,0,5,0,0 224 | "Veronica officinalis",6,0,3,4,3,4 225 | "Vicia dumetorum",6,6,4,5,8,4 226 | "Vicia species",0,0,0,0,0,0 227 | "Vicia sylvatica",7,0,4,4,8,0 228 | "Vincetoxicum hirundinaria",6,5,5,3,7,3 229 | "Viola collina",6,5,7,3,8,2 230 | "Viola reichenbachiana",4,0,4,5,7,6 231 | "Viola species",0,0,0,0,0,0 232 | "Viola tricolor",0,0,0,0,0,0 233 | -------------------------------------------------------------------------------- /tests/testthat/test_DataObject.R: -------------------------------------------------------------------------------- 1 | test_that("datapack library loads", { 2 | expect_true(library(datapack, logical.return = TRUE)) 3 | }) 4 | 5 | test_that("DataObject constructors work", { 6 | library(datapack) 7 | library(digest) 8 | identifier <- "id1" 9 | user <- "matt" 10 | data <- charToRaw("1,2,3\n4,5,6\n") 11 | format <- "text/csv" 12 | node <- "urn:node:KNB" 13 | 14 | # Test the constructor that builds a DataObject object 15 | do <- new("DataObject", identifier, data, filename="test.cvs", format=format, user=user, mnNodeId=node) 16 | expect_equal(class(do)[[1]], "DataObject") 17 | expect_equal(do@sysmeta@serialVersion, 1) 18 | expect_equal(do@sysmeta@identifier, identifier) 19 | expect_equal(do@sysmeta@submitter, user) 20 | expect_equal(do@sysmeta@size, length(data)) 21 | expect_equal(length(do@data), length(data)) 22 | expect_equal(getIdentifier(do), identifier) 23 | expect_equal(getFormatId(do), format) 24 | sha <- digest(data, algo="sha256", serialize=FALSE, file=FALSE) 25 | sm <- new("SystemMetadata", identifier=identifier, formatId=format, size=length(data), submitter=user, rightsHolder=user, checksum=sha, originMemberNode=node, authoritativeMemberNode=node) 26 | expect_equal(sm@identifier, identifier) 27 | 28 | # Now test the constructor that passes in SystemMetadata and data 29 | do <- new("DataObject", sm, data, filename="test.csv") 30 | expect_equal(do@sysmeta@serialVersion, 1) 31 | expect_equal(do@sysmeta@identifier, identifier) 32 | expect_equal(do@sysmeta@submitter, user) 33 | expect_equal(do@sysmeta@checksumAlgorithm, "SHA-256") 34 | expect_equal(do@sysmeta@checksum, sha) 35 | expect_equal(do@sysmeta@size, length(data)) 36 | expect_equal(do@sysmeta@size, length(data)) 37 | expect_equal(length(do@data), length(data)) 38 | expect_equal(getIdentifier(do), identifier) 39 | expect_equal(getFormatId(do), format) 40 | 41 | # Now test the constructor that passes in SystemMetadata and a filename (not data) 42 | tf <- tempfile() 43 | con <- file(tf, "wb") 44 | writeBin(data, con) 45 | close(con) 46 | sha_file <- digest(tf, algo="sha256", serialize=FALSE, file=TRUE) 47 | do <- new("DataObject", sm, filename=tf, checksumAlgorith="SHA-256") 48 | expect_equal(do@sysmeta@serialVersion, 1) 49 | expect_equal(do@sysmeta@identifier, identifier) 50 | expect_equal(do@sysmeta@submitter, user) 51 | expect_equal(do@sysmeta@checksumAlgorithm, "SHA-256") 52 | expect_equal(do@sysmeta@checksum, sha) 53 | expect_equal(do@sysmeta@size, length(data)) 54 | expect_equal(file.info(tf)$size, length(data)) 55 | expect_equal(getIdentifier(do), identifier) 56 | expect_equal(getFormatId(do), format) 57 | data2 <- getData(do) 58 | sha_get_data <- digest(data2, algo="sha256", serialize=FALSE, file=FALSE) 59 | expect_match(sha_get_data, sha) 60 | expect_match(sha_file, do@sysmeta@checksum) 61 | expect_match(sha_get_data, do@sysmeta@checksum) 62 | 63 | # Verify that the DataObject initialization prepares the sysmeta correctly, if it is not 64 | # included in the parameter list. 65 | 66 | sha_file <- digest(tf, algo="sha1", serialize=FALSE, file=TRUE) 67 | do <- new("DataObject", identifier, filename=tf, checksumAlgorith="SHA1") 68 | expect_equal(do@sysmeta@checksum, sha_file) 69 | expect_equal(do@sysmeta@checksumAlgorithm, "SHA1") 70 | 71 | sha_file <- digest(tf, algo="md5", serialize=FALSE, file=TRUE) 72 | do <- new("DataObject", identifier, filename=tf, checksumAlgorith="MD5") 73 | expect_equal(do@sysmeta@checksum, sha_file) 74 | expect_equal(do@sysmeta@checksumAlgorithm, "MD5") 75 | 76 | unlink(tf) 77 | 78 | # Test that the constructor works for a data path, with a few different forms 79 | targetPath="./data/rasters/test.csv" 80 | do <- new("DataObject", sm, data, filename="test.csv", targetPath=targetPath) 81 | expect_equal(do@targetPath, targetPath) 82 | 83 | targetPath="data/rasters/test.csv" 84 | do <- new("DataObject", sm, data, filename="test.csv", targetPath=targetPath) 85 | expect_equal(do@targetPath, targetPath) 86 | 87 | }) 88 | test_that("DataObject accessPolicy methods", { 89 | library(datapack) 90 | library(digest) 91 | identifier <- "id1" 92 | user <- "matt" 93 | data <- charToRaw("1,2,3\n4,5,6") 94 | format <- "text/csv" 95 | node <- "urn:node:KNB" 96 | 97 | do <- new("DataObject", identifier, data, format, user, node, filename="test.csv") 98 | expect_equal(class(do)[[1]], "DataObject") 99 | 100 | # Public access should not be present at first 101 | canRead <- canRead(do, "uid=anybody,DC=somedomain,DC=org") 102 | expect_false(canRead) 103 | 104 | # Test that setting public access works 105 | do <- setPublicAccess(do) 106 | isPublic <- hasAccessRule(do@sysmeta, "public", "read") 107 | expect_true(isPublic) 108 | 109 | # Test that custom access rules can be added to sysmeta of a DataObject 110 | accessRules <- data.frame(subject=c("uid=smith,ou=Account,dc=example,dc=com", 111 | "uid=wiggens,o=unaffiliated,dc=example,dc=org"), 112 | permission=c("write", "changePermission"), stringsAsFactors=FALSE) 113 | do <- addAccessRule(do, accessRules) 114 | expect_true(hasAccessRule(do@sysmeta, "uid=smith,ou=Account,dc=example,dc=com", "write")) 115 | expect_true(hasAccessRule(do@sysmeta, "uid=wiggens,o=unaffiliated,dc=example,dc=org", "changePermission")) 116 | expect_false(hasAccessRule(do@sysmeta, "uid=smith,ou=Account,dc=example,dc=com", "changePermission")) 117 | 118 | # Public access should now be possible 119 | canRead <- canRead(do, "uid=anybody,DC=somedomain,DC=org") 120 | expect_true(canRead) 121 | 122 | # Test that an access policy can be cleared, i.e. all access rules removed. 123 | do <- clearAccessPolicy(do) 124 | expect_true(nrow(do@sysmeta@accessPolicy) == 0) 125 | expect_false(hasAccessRule(do@sysmeta, "uid=smith,ou=Account,dc=example,dc=com", "write")) 126 | expect_false(hasAccessRule(do@sysmeta, "uid=wiggens,o=unaffiliated,dc=example,dc=org", "changePermission")) 127 | expect_false(hasAccessRule(do@sysmeta, "uid=smith,ou=Account,dc=example,dc=com", "changePermission")) 128 | 129 | # Chech using parameter "y" as a character string containing the subject of the access rule: 130 | do <- new("DataObject", identifier, data, format, user, node, filename="test.csv") 131 | do <- addAccessRule(do, "uid=smith,ou=Account,dc=example,dc=com", "write") 132 | do <- addAccessRule(do, "uid=smith,ou=Account,dc=example,dc=com", "changePermission") 133 | expect_true(hasAccessRule(do, "uid=smith,ou=Account,dc=example,dc=com", "write")) 134 | expect_true(hasAccessRule(do, "uid=smith,ou=Account,dc=example,dc=com", "changePermission")) 135 | do <- removeAccessRule(do, "uid=smith,ou=Account,dc=example,dc=com", "changePermission") 136 | expect_false(hasAccessRule(do, "uid=smith,ou=Account,dc=example,dc=com", "changePermission")) 137 | do <- removeAccessRule(do, "uid=smith,ou=Account,dc=example,dc=com", "write") 138 | expect_false(hasAccessRule(do, "uid=smith,ou=Account,dc=example,dc=com", "write")) 139 | 140 | # Check parameter "y" as a data.frame containing one or more access rules: 141 | # Add write, changePermission for uid=jones,... 142 | do <- addAccessRule(do, "uid=jones,ou=Account,dc=example,dc=com", "write") 143 | do <- addAccessRule(do, "uid=jones,ou=Account,dc=example,dc=com", "changePermission") 144 | expect_true(hasAccessRule(do, "uid=jones,ou=Account,dc=example,dc=com", "write")) 145 | expect_true(hasAccessRule(do, "uid=jones,ou=Account,dc=example,dc=com", "changePermission")) 146 | 147 | # Now take privs for uid=jones,... away 148 | accessRules <- data.frame(subject=c("uid=jones,ou=Account,dc=example,dc=com", 149 | "uid=jones,ou=Account,dc=example,dc=com"), 150 | permission=c("write", "changePermission")) 151 | do <- removeAccessRule(do, accessRules) 152 | expect_false(hasAccessRule(do, "uid=jones,ou=Account,dc=example,dc=com", "write")) 153 | expect_false(hasAccessRule(do, "uid=jones,ou=Account,dc=example,dc=com", "changePermission")) 154 | }) 155 | 156 | test_that("DataObject updateXML method", { 157 | library(datapack) 158 | library(XML) 159 | 160 | # Use a realistic value to update the XML of the metadata object 161 | resolveURL <- "https://cn.dataone.org/cn/v2/resolve" 162 | 163 | # Create the metadata object with a sample EML file 164 | sampleMeta <- system.file("./extdata/sample-eml.xml", package="datapack") 165 | metaObj <- new("DataObject", format="eml://ecoinformatics.org/eml-2.1.1", file=sampleMeta) 166 | 167 | # Create a sample data object 168 | sampleData <- system.file("./extdata/sample-data.csv", package="datapack") 169 | dataObj <- new("DataObject", format="text/csv", file=sampleData) 170 | 171 | # In the metadata object, insert the newly assigned data 172 | xp <- sprintf("//dataTable/physical/distribution[../objectName/text()=\"%s\"]/online/url", "sample-data.csv") 173 | newURL <- sprintf("%s/%s", resolveURL, getIdentifier(dataObj)) 174 | metaObj <- updateXML(metaObj, xpath=xp, replacement=newURL) 175 | 176 | # Now retrieve the new value from the metadata using an independent method (not using datapack) and see 177 | # if the metadata was actually updated. 178 | metadataDoc <- xmlInternalTreeParse(rawToChar(getData(metaObj))) 179 | nodeSet = xpathApply(metadataDoc,xp) 180 | URL <- xmlValue(nodeSet[[1]]) 181 | 182 | expect_match(newURL, URL) 183 | }) 184 | 185 | test_that("pathToPOSIX is correctly sanitizing file paths", { 186 | library(datapack) 187 | 188 | # This is a valid POSIX path; don't filter : 189 | drivePath <- "c:/test/myFile.csv" 190 | drivePathExpected <- "c:/test/myFile.csv" 191 | 192 | # The '..' characters should be removed 193 | traversalPath <- "data/../moreData/../../rasters/myFile.csv" 194 | traversalPathExpected <- "data/_/moreData/_/_/rasters/myFile.csv" 195 | 196 | # The The particular characters aren't allowed in POSIX 197 | specialCharacterPath <- "geo-data/?home/%APPDATA/myFile.csv" 198 | specialCharacterPathExpexted <- "geo-data/_home/%APPDATA/myFile.csv" 199 | 200 | windowsPath <- "c:\\Windows\\System32" 201 | windowsPathExpected <- "c:/Windows/System32" 202 | expect_equal(pathToPOSIX(drivePath) , drivePathExpected) 203 | expect_equal(pathToPOSIX(traversalPath),traversalPathExpected) 204 | expect_equal(pathToPOSIX(specialCharacterPath), specialCharacterPathExpexted) 205 | expect_equal(pathToPOSIX(windowsPath), windowsPathExpected) 206 | }) 207 | --------------------------------------------------------------------------------