ropensci / datapack

An R package to handle data packages
https://docs.ropensci.org/datapack
44 stars 9 forks source link

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

Open gothub opened 4 years ago

gothub commented 4 years ago

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)
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