1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#' @name SDMXRequestBuilder
#' @docType class
#' @aliases SDMXRequestBuilder-class
#'
#' @title Class "SDMXRequestBuilder"
#' @description A basic class to handle a SDMX service request builder
#'
#' @slot regUrl an object of class "character" giving the base Url of the SDMX service registry
#' @slot repoUrl an object of class "character" giving the base Url of the SDMX service repository
#' @slot accessKey an object of class "character" indicating the name of request parameter for which
#' an authentication or subscription user key/token has to be provided to perform requests
#' @slot formatter an object of class "list" giving a formatting function (for each resource) that
#' takes an object of class "SDMXRequestParams" as single argument. Such parameter allows
#' to customize eventual params (e.g. specific data provider rules)
#' @slot handler an object of class "list" that will be in charge of build a web request.
#' @slot compliant an object of class "logical" indicating if the request builder is somehow compliant with a service specification
#' @slot unsupportedResources an object of class "character" giving one or more resources not
#' supported by the Request builder for a given provider
#' @slot headers an object of class "list" that contains any additional headers for the request.
#'
#' @section Warning:
#' This class is not useful in itself, but all SDMX non-abstract classes will
#' encapsulate it as slot, when parsing an SDMX-ML document (Concepts, or
#' DataStructureDefinition)
#'
#' @author Emmanuel Blondel, \email{emmanuel.blondel1@@gmail.com}
#'
setClass("SDMXRequestBuilder",
representation(
regUrl = "character",
repoUrl = "character",
accessKey = "character_OR_NULL",
formatter = "list",
handler = "list",
compliant = "logical",
unsupportedResources = "list",
headers = "list"
),
prototype = list(
regUrl = "http://www.myorg.org/sdmx/registry",
repoUrl = "http://www.myorg.org/sdmx/repository",
accessKey = NULL,
formatter = list(
dataflow = function(obj){return(obj)},
datastructure = function(obj){ return(obj)},
data = function(obj){return(obj)}
),
handler = list(
"dataflow" = function(obj){return(obj@regUrl)},
"datastructure" = function(obj){return(obj@regUrl)},
"data" = function(obj){return(obj@repoUrl)}
),
compliant = TRUE,
unsupportedResources = list(),
headers = list()
),
validity = function(object){
#validation rules
if(.rsdmx.options$validate){
if(all(names(object@formatter) != names(object@handler))) return(FALSE)
}
return(TRUE);
}
)
|