diff --git a/R/geoflow_right.R b/R/geoflow_right.R index f55faa3f..6f6b1460 100644 --- a/R/geoflow_right.R +++ b/R/geoflow_right.R @@ -15,7 +15,7 @@ #' \dontrun{ #' right <- geoflow_right$new() #' right$setKey("use") -#' right$setValue("No restrictions") +#' right$setValues("No restrictions") #' } #' #' @author Emmanuel Blondel @@ -24,8 +24,8 @@ geoflow_right <- R6Class("geoflow_right", public = list( #'@field key right key key = NULL, - #'@field value right value - value = NULL, + #'@field values right values + values = list(), #'@description Initializes an object of class \link{geoflow_right} #'@param str character string to initialize from using key-based syntax @@ -34,10 +34,21 @@ geoflow_right <- R6Class("geoflow_right", if(!is.null(str)){ right <- extract_kvp(str) self$setKey(right$key) - self$setValue(paste(right$values, collapse=",")) + self$setValues(right$values) }else if(!is.null(kvp)){ self$setKey(kvp$key) - self$setValue(kvp$values) + values = lapply(1:length(kvp$values), function(i){ + right = kvp$values[[i]] + attributes(right) <- NULL + val_locale_attrs <- attributes(kvp$values) + for(attr_name in names(val_locale_attrs)){ + locale_value <- val_locale_attrs[[attr_name]][[i]] + attributes(locale_value) <- NULL + attr(right, attr_name) <- locale_value + } + return(right) + }) + self$setValues(values) } }, @@ -47,10 +58,10 @@ geoflow_right <- R6Class("geoflow_right", self$key <- key }, - #'@description Sets value - #'@param value value - setValue = function(value){ - self$value <- value + #'@description Sets values + #'@param values values + setValues = function(values){ + self$values <- c(self$values, values) } ) ) \ No newline at end of file diff --git a/inst/actions/geometa_create_iso_19115.R b/inst/actions/geometa_create_iso_19115.R index 8d162af3..167a12d8 100644 --- a/inst/actions/geometa_create_iso_19115.R +++ b/inst/actions/geometa_create_iso_19115.R @@ -377,13 +377,19 @@ function(action, entity, config){ if(length(licenses)>0){ legal_constraints$addUseConstraint("license") for(license in licenses){ - legal_constraints$addUseLimitation(license$value, locales = geoflow::get_locales_from(license$value)) + for(value in license$values){ + legal_constraints$addUseLimitation(value, locales = geoflow::get_locales_from(value)) + } } } #use limitation 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, locales = geoflow::get_locales_from(use$value)) + for(use in uses){ + for(value in use$values){ + legal_constraints$addUseLimitation(value, locales = geoflow::get_locales_from(value)) + } + } } #use constraints useConstraints <- entity$rights[sapply(entity$rights, function(x){tolower(x$key) == "useconstraint"})] @@ -398,7 +404,11 @@ 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, locales = geoflow::get_locales_from(otherConstraint$value)) + for(otherConstraint in otherConstraints){ + for(value in otherConstraint$values){ + legal_constraints$addOtherConstraint(value, locales = geoflow::get_locales_from(value)) + } + } } ident$addResourceConstraints(legal_constraints) }