datapack icon indicating copy to clipboard operation
datapack copied to clipboard

Update `DataPackage::replaceMember()` to support existing DataONE objects

Open gothub opened this issue 5 years ago • 0 comments

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:

  1. Download a package from DataONE
  2. Download an object from DataONE that is not in that package
  3. Replace a member in the package with the separately downloaded one
  4. 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

gothub avatar Jun 07 '20 21:06 gothub