Skip to content

Commit

Permalink
#298 i18n support for Rights
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Jan 2, 2023
1 parent 167297d commit 866ddf8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
6 changes: 5 additions & 1 deletion R/geoflow_right.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ geoflow_right <- R6Class("geoflow_right",

#'@description Initializes an object of class \link{geoflow_right}
#'@param str character string to initialize from using key-based syntax
initialize = function(str = NULL){
#'@param kvp an object of class \link{geoflow_kvp}
initialize = function(str = NULL, kvp = NULL){
if(!is.null(str)){
right <- extract_kvp(str)
self$setKey(right$key)
self$setValue(paste(right$values, collapse=","))
}else if(!is.null(kvp)){
self$setKey(kvp$key)
self$setValue(kvp$values)
}
},

Expand Down
8 changes: 4 additions & 4 deletions inst/actions/geometa_create_iso_19115.R
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,13 @@ function(action, entity, config){
if(length(licenses)>0){
legal_constraints$addUseConstraint("license")
for(license in licenses){
legal_constraints$addUseLimitation(license)
legal_constraints$addUseLimitation(license$value, locales = geoflow::get_locales_from(license$value))
}
}
#use limitation
uses <- entity$rights[sapply(entity$rights, function(x){tolower(x$key) == "use"})]
uses <- entity$rights[sapply(entity$rights, function(x){tolower(x$key) %in% c("use","uselimitation")})]
if(length(uses)>0){
for(use in uses) legal_constraints$addUseLimitation(use$value)
for(use in uses) legal_constraints$addUseLimitation(use$value, locales = geoflow::get_locales_from(use$value))
}
#use constraints
useConstraints <- entity$rights[sapply(entity$rights, function(x){tolower(x$key) == "useconstraint"})]
Expand All @@ -398,7 +398,7 @@ function(action, entity, config){
#other constraints
otherConstraints <- entity$rights[sapply(entity$rights, function(x){tolower(x$key) == "otherconstraint"})]
if(length(otherConstraints)>0){
for(otherConstraint in otherConstraints) legal_constraints$addOtherConstraint(otherConstraint$value)
for(otherConstraint in otherConstraints) legal_constraints$addOtherConstraint(otherConstraint$value, locales = geoflow::get_locales_from(otherConstraint$value))
}
ident$addResourceConstraints(legal_constraints)
}
Expand Down
7 changes: 4 additions & 3 deletions inst/metadata/entity/entity_handler_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,11 @@ handle_entities_df <- function(config, source){
src_rights <- sanitize_str(source_entity[,"Rights"])
rights <- if(!is.na(src_rights)) extract_cell_components(src_rights) else list()
if(length(rights)>0){
invisible(lapply(rights, function(right){
right_obj <- geoflow_right$new(str = right)
kvps <- extract_kvps(rights)
for(kvp in kvps){
right_obj <- geoflow_right$new(kvp = kvp)
entity$addRight(right_obj)
}))
}
}

#Provenance
Expand Down

0 comments on commit 866ddf8

Please sign in to comment.