@@ -683,3 +683,52 @@ eml_categorize_dataset <- function(doc, discipline){
683683
684684 return (doc )
685685}
686+
687+
688+ # ' Add distribution information to EML
689+ # '
690+ # ' Adds a landing page URL to the dataset, and corrects the metadata identifier
691+ # ' by replacing the existing identifier with that which is passed. Note that this
692+ # ' function constructs landing page URLs for the Arctic Data Center only and will not work
693+ # ' correctly on other repositories.
694+ # '
695+ # '
696+ # '
697+ # ' @param doc (emld) An EML document
698+ # ' @param identifier (character) A pre-issued, unassigned identifier (as from `dataone::generateIdentifier()`)
699+ # '
700+ # ' @return doc (emld) An EML document with distribution added
701+ # ' @export
702+ # ' @examples
703+ # ' \dontrun{
704+ # ' library(EML)
705+ # ' d1c <- dataone::D1Client("STAGING", "mnTestARCTIC")
706+ # ' # read in any EML document
707+ # ' doc <- read_eml(system.file("extdata/strix-pacific-northwest.xml", package="dataone"))
708+ # ' # generate a doi
709+ # ' id <- generateIdentifier(d1c@mn, "doi")
710+ # ' doc <- eml_add_distribution(doc, id)
711+ # ' }
712+ # '
713+ eml_add_distribution <- function (doc , identifier ){
714+
715+ stopifnot(" emld" %in% class(doc ))
716+
717+ doc $ packageId <- identifier
718+
719+ use_doi <- grepl(" doi" , identifier )
720+
721+ # Add landing page
722+ if (use_doi == T ){
723+ doc $ dataset $ distribution $ offline <- NULL
724+ doc $ dataset $ distribution $ online $ url <- list (url = paste0(" http://doi.org/" , identifier ),
725+ `function` = " information" )
726+ }
727+ else if (use_doi == F ){
728+ doc $ dataset $ distribution $ offline <- NULL
729+ doc $ dataset $ distribution $ online $ url <- list (url = paste0(" http://arcticdata.io/catalog/view/" , identifier ),
730+ `function` = " information" )
731+ }
732+
733+ return (doc )
734+ }
0 commit comments