diff --git a/inst/metadata/entity/entity_handler_csw.R b/inst/metadata/entity/entity_handler_csw.R index de8f187..aa8e6e4 100644 --- a/inst/metadata/entity/entity_handler_csw.R +++ b/inst/metadata/entity/entity_handler_csw.R @@ -223,21 +223,42 @@ handle_entities_csw <- function(handler, source, config, handle = TRUE){ if(is(constraint, "ISOLegalConstraints")){ #use constraints use_values = lapply(constraint$useConstraints, function(x){x$attrs$codeListValue}) - use_right = geoflow_right$new() - use_right$setKey("useConstraint") - use_right$setValues(use_values) - entity$addRight(use_right) + if(length(use_values)>0){ + for(use_value in use_values){ + use_right = geoflow_right$new() + use_right$setKey("useConstraint") + use_right$setValues(use_value) + entity$addRight(use_right) + } + } #access constraints access_values = lapply(constraint$accessConstraints, function(x){x$attrs$codeListValue}) - access_right = geoflow_right$new() - access_right$setKey("accessConstraint") - access_right$setValues(access_values) - entity$addRight(access_right) + if(length(access_values)>0){ + for(access_value in access_values){ + access_right = geoflow_right$new() + access_right$setKey("accessConstraint") + access_right$setValues(access_value) + entity$addRight(access_right) + } + } #other constraints - other_right = geoflow_right$new() - other_right$setKey("otherConstraint") - other_right$setValues(constraint$otherConstraints) - entity$addRight(other_right) + if(length(constraint$otherConstraints)>0){ + for(otherConstraint in constraint$otherConstraints){ + other_right = geoflow_right$new() + other_right$setKey("otherConstraint") + other_right$setValues(otherConstraint) + entity$addRight(other_right) + } + } + #use limitations + if(length(constraint$useLimitation)>0){ + for(useLimitation in constraint$useLimitation){ + use_right = geoflow_right$new() + use_right$setKey("useLimitation") + use_right$setValues(useLimitation) + entity$addRight(use_right) + } + } } } } diff --git a/inst/metadata/entity/entity_handler_zenodo.R b/inst/metadata/entity/entity_handler_zenodo.R index c67a18d..926682b 100644 --- a/inst/metadata/entity/entity_handler_zenodo.R +++ b/inst/metadata/entity/entity_handler_zenodo.R @@ -113,9 +113,11 @@ handle_entities_zenodo <- function(handler, source, config, handle = TRUE){ creator_c$setLastName(creatorNames[1]) if(!is.null(creator_poo$affiliations)) creator_c$setOrganizationName(creator_poo$affiliations[[1]]$id) ids = creator_poo$identifiers - names(ids) = sapply(ids, function(x){x$scheme}) - if(!is.null(ids$orcid)) creator_c$setIdentifier("orcid", ids$orcid$identifier) - if(!is.null(ids$gnd)) creator_c$setIdentifier("gnd", ids$gnd$identifier) + if(!is.null(ids)){ + names(ids) = sapply(ids, function(x){x$scheme}) + if(!is.null(ids$orcid)) creator_c$setIdentifier("orcid", ids$orcid$identifier) + if(!is.null(ids$gnd)) creator_c$setIdentifier("gnd", ids$gnd$identifier) + } creator_c$setRole("creator") entity$addContact(creator_c) } @@ -129,9 +131,11 @@ handle_entities_zenodo <- function(handler, source, config, handle = TRUE){ contrib_c$setLastName(contribNames[1]) if(!is.null(contrib_poo$affiliations)) contrib_c$setOrganizationName(contrib_poo$affiliations[[1]]$id) ids = contrib_poo$identifiers - names(ids) = sapply(ids, function(x){x$scheme}) - if(!is.null(ids$orcid)) contrib_c$setIdentifier("orcid", ids$orcid$identifier) - if(!is.null(ids$gnd)) contrib_c$setIdentifier("gnd", ids$gnd$identifier) + if(!is.null(ids)){ + names(ids) = sapply(ids, function(x){x$scheme}) + if(!is.null(ids$orcid)) contrib_c$setIdentifier("orcid", ids$orcid$identifier) + if(!is.null(ids$gnd)) contrib_c$setIdentifier("gnd", ids$gnd$identifier) + } contrib_c$setRole("contributor") entity$addContact(contrib_c) }