Skip to content

Commit

Permalink
fix csw + zenodo handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed May 19, 2024
1 parent b6cb572 commit 7eb2402
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 18 deletions.
45 changes: 33 additions & 12 deletions inst/metadata/entity/entity_handler_csw.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
}
Expand Down
16 changes: 10 additions & 6 deletions inst/metadata/entity/entity_handler_zenodo.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down

0 comments on commit 7eb2402

Please sign in to comment.