-
Notifications
You must be signed in to change notification settings - Fork 20
Add EML object as an alternative option for metadata_path #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a938752
c8287fb
5781284
2710025
ac32bf3
ccdfa20
431593e
9e0ea67
77ef74f
82bc8bc
0554abe
24b3c20
f33cf75
8346ada
96ae41f
5201e95
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -233,7 +233,7 @@ update_object <- function(mn, pid, path, format_id=NULL, new_pid=NULL, sid=NULL) | |
| #' @param parent_data_pids (character) Optional. Identifier for the data objects of the parent package. Not optional if the parent package contains data objects. | ||
| #' @param parent_child_pids (character) Optional. Resource map identifier(s) of child packages in the parent package. \code{resource_map_pid} should not be included. Not optional if the parent package contains other child packages. | ||
| #' @param child_pids (character) Optional. Child packages resource map PIDs. | ||
| #' @param metadata_path (character) Optional. Path to a metadata file to update with. If this is not set, the existing metadata document will be used. | ||
| #' @param metadata_path (character or eml) Optional. An eml class object or a path to a metadata file to update with. If this is not set, the existing metadata document will be used. | ||
| #' @param public (logical) Optional. Make the update public. If FALSE, will set the metadata and resource map to private (but not the data objects). | ||
| #' This applies to the new metadata PID and its resource map and data object. | ||
| #' access policies are not affected. | ||
|
|
@@ -367,6 +367,15 @@ publish_update <- function(mn, | |
| # Get the metadata doc | ||
| message("Getting metadata from the MN.") | ||
| eml <- EML::read_eml(rawToChar(dataone::getObject(mn, metadata_pid)), asText = TRUE) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to close this if statement correct? or better use else if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking into it. |
||
|
|
||
| } else if(class(metadata_path) == "eml") { | ||
| # If an eml object is provided, use it directly after validating | ||
| if(!eml_validate(metadata_path)){ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @isteves Maybe move this out of the call here so that eml always gets validated wether or not is an R object or from disk. Also maybe add a message so users know that eml is being validated in case it takes a non-trivial amount of time. |
||
| stop("The EML object is not valid.") | ||
| } | ||
|
|
||
| eml <- metadata_path | ||
|
|
||
| } else { | ||
| # Alternatively, read an edited metadata file from disk if provided | ||
| if (!file.exists(metadata_path)) { | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can/should this arg name get changed now that it's not just a path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to change the name so that it could remain backwards-compatible. But if our preference is to make it friendlier for new users, then a name change makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's probably more important.