datapack
datapack copied to clipboard
Update `DataPackage::replaceMember()` to support existing DataONE objects
Update replaceMember() this use case is supported: update an existing DataONE package by replacing a package member with a newer file that has already been uploaded to DataONE, possibly in a different package. The workflow would be:
- Download a package from DataONE
- Download an object from DataONE that is not in that package
- Replace a member in the package with the separately downloaded one
- Upload the modified package to DataONE:
<some program lines not shown>
existingPid <- "doi:10.6085/AA/marine_ltm.11.1"
existingObj <- getDataObject(d1c, existingPid, lazyLoad=TRUE, quiet=FALSE)
pkg <- getDataPackage(d1c, identifier=resourceMapId, lazyLoad=TRUE, limit="0MB", quiet=FALSE)
<some program lines not shown>
oldId <- selectMember(pkg, name="sysmeta@identifier", value="doi:10.6085/AA/marine_ltm.1.1")
pkg <- removeMember(pkg, oldId, removeRelationships=TRUE)
pkg <- addMember(pkg, existingObj, metadataId)
<some program lines not shown>
updatePkg <- uploadDataPackage(d1c, pkg, public=TRUE, quiet=FALSE, as="DataPackage")
This use case could be used for DataONE objects that are common to multiple packages.
See https://github.com/DataONEorg/rdataone/issues/251