eblondel/zen4R

How to reserve a DOI?

rkrug opened this issue · 4 comments

rkrug commented

Thanks for a nice looking package - I was looking for something like that.

My question:

I would like to reserve a DOI when depositing a record, but it does not seem to work (I am checking via the Zenodo web interface). I use the following code:

library(zen4R)

zenodo <- ZenodoManager$new(
  url = "https://sandbox.zenodo.org/api",
  token = "MyToken", 
  logger = "INFO"
)

# Get depositions
zenodo$getDepositions()


# New Deposition
myrec <- zenodo$createEmptyRecord()

# Add details
myrec$setTitle("LEEF Test")
myrec$setDescription("Just to see if it works")
myrec$setUploadType("dataset")
myrec$addCreator(firstname = "Rainer", lastname = "Krug", affiliation = "UZH", orcid = "0000-0002-7490-0066")
myrec$setLicense("mit")
myrec$setAccessRight("open")
# myrec$setDOI("mydoi") #use this method if your DOI has been assigned elsewhere, outside Zenodo
myrec$addCommunity("ecfunded")

# reserve DOI
myrec$prereserveDOI(TRUE)


# Deposit on Zenodo
myrec <- zenodo$depositRecord(myrec)

# doi is still empty:
myrec$doi
## [1] ""

I think I am missing something here?

Thanks,

Rainer

Hi Rainer thanks for your message.

To answer your question: when you call rec <- zenodo$createEmptyRecord() you create an empty deposit on the Zenodo infra (here the sandbox), a shortcut of "depositRecord" with empty metadata. The pre-reservation of DOI is done by default when deposited the first time. To get the pre-reserved DOI, you should call this property:

rec$metadata$prereserve_doi$doi
rkrug commented

Thanks Emmanuel - that wasn't clear to me. Saw it and it is working.

What is than the use of the myrec$prereserveDOI() function? Only to dis-able the pre-reservation?

Yes, indeed this is set as public method, but more used internally in setDOI which is used to set an external DOI. In that case we need to disable the pre-reservation. Code of setDOI function:

function(doi){
      self$metadata$doi <- doi
      self$prereserveDOI(FALSE)
}
rkrug commented

Thanks a a lot, Emmanuel.