IQSS / dataverse-client-r

R Client for Dataverse Repositories
https://iqss.github.io/dataverse-client-r
61 stars 24 forks source link

`list_datasets()` & printing is failing #54

Closed wibeasley closed 4 years ago

wibeasley commented 4 years ago
Sys.setenv("DATAVERSE_SERVER" = "demo.dataverse.org")
Sys.setenv("DATAVERSE_KEY"    = "c7208dd2-6ec5-469a-bec5-f57e164888d4")
dv <- get_dataverse("dataverse-client-r")
list_datasets(dv)

The error is

Error in if (x$dataverseHasBeenReleased[[1]] == "true") "Yes" else "No" : 
  argument is of length zero 

The nested structure of the objected has changed, so this function is failing: https://github.com/IQSS/dataverse-client-r/blob/697180e5b9bc0f6d7bc16068d45cd06cf25e2646/R/print.R#L3-L8

The feed level needs to be added. So x$feed$dataverseHasBeenReleased[[1]] becomes x$dataverseHasBeenReleased[[1]]? But there's something with dispatching isn't going as I expect. The full structure of x from list_datasets() isn't being recognized by `print.dataverse_dataset_list().


Edit: I think print() is fine. It's a problem with the tail end of list_datasets(). These objects are nested in x$feed, not just x.

https://github.com/IQSS/dataverse-client-r/blob/697180e5b9bc0f6d7bc16068d45cd06cf25e2646/R/SWORD.R#L82-L85

pdurbin commented 4 years ago

Yeah, it's under "feed". I don't know if this helps or not, but here's a related test in the main Dataverse code base:

https://github.com/IQSS/dataverse/blob/v4.19/src/test/java/edu/harvard/iq/dataverse/api/SwordIT.java#L210