Skip to content

Commit

Permalink
refactoring Ows Http requests adding capabilities + #10 support wps
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Jul 9, 2021
1 parent 3d5d32b commit 2e78fa8
Show file tree
Hide file tree
Showing 57 changed files with 555 additions and 99 deletions.
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,19 @@ export(WMSGetFeatureInfo)
export(WMSLayer)
export(WPSCapabilities)
export(WPSClient)
export(WPSComplexData)
export(WPSComplexInputDescription)
export(WPSComplexOutputDescription)
export(WPSDescribeProcess)
export(WPSDescriptionParameter)
export(WPSExecute)
export(WPSExecuteResponse)
export(WPSFormat)
export(WPSInput)
export(WPSInputDescription)
export(WPSLiteralData)
export(WPSLiteralInputDescription)
export(WPSOutput)
export(WPSOutputDescription)
export(WPSParameter)
export(WPSProcess)
Expand Down
4 changes: 2 additions & 2 deletions R/CSWCapabilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#'
#' @section Methods:
#' \describe{
#' \item{\code{new(url, version, logger)}}{
#' This method is used to instantiate a WFSGetCapabilities object
#' \item{\code{new(url, version, client logger)}}{
#' This method is used to instantiate a \code{CSWCapabilities} object
#' }
#' }
#'
Expand Down
49 changes: 41 additions & 8 deletions R/CSWClient.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
#'
#' @section Methods:
#' \describe{
#' \item{\code{new(url, serviceVersion, user, pwd, token, logger)}}{
#' \item{\code{new(url, serviceVersion, user, pwd, token, headers, logger, ...)}}{
#' This method is used to instantiate a CSWClient with the \code{url} of the
#' OGC service. Authentication is supported using basic auth (using \code{user}/\code{pwd} arguments),
#' bearer token (using \code{token} argument), or custom (using \code{headers} argument). By default, the \code{logger}
#' argument will be set to \code{NULL} (no logger). This argument accepts two possible
#' values: \code{INFO}: to print only \pkg{ows4R} logs, \code{DEBUG}: to print more verbose logs
#' }
#' \item{\code{getCapabilities()}}{
#' Get service capabilities. Inherited from OWS Client
#' Get service capabilities.
#' }
#' \item{\code{reloadCapabilities()}}{
#' Reload service capabilities
Expand All @@ -52,6 +52,39 @@
#' "full" corresponds to the full metadata sheet returned. "brief" and "summary" will contain only
#' a subset of the metadata content.
#' }
#' \item{\code{getRecords(query, maxRecords, maxRecordsPerRequest)}}{
#' Get records based on a query, object of class \code{CSWQuery}. The maximum number of records can be
#' set either for the full query (\code{maxRecords}) or per request (\code{maxRecordsPerRequest}, default set to 10 records)
#' considering this operation is paginated. By default, the record will be returned following the CSW schema
#' (http://www.opengis.net/cat/csw/2.0.2). For other schemas, specify the \code{outputSchema}
#' required, e.g. http://www.isotc211.org/2005/gmd for ISO 19115/19139 records.
#' }
#' \item{\code{transaction(type, record, recordProperty, constraint)}}{
#' Generic transaction method. Used for inserting, updating or deleting metadata using the transactional CSW service.
#' The \code{type} gives the type of transaction (Insert, Update, or Delete). The record
#' }
#' \item{\code{insertRecord(record, ...)}}{
#' Inserts a new record
#' }
#' \item{\code{updateRecord(record, recordProperty, constraint, ...)}}{
#' Updates an existing \code{record}. It can be a partial update by specifying a \code{recordProperty}.
#' A constraint (object of class \code{CSWConstraint}) can be specified.
#' }
#' \item{\code(deleteRecord(record, constraint, ...))}{
#' Deletes an existing \code{record}. A constraint (object of class \code{CSWConstraint}) can be specified to limit
#' the deletion to some records.
#' }
#' \item{\code{deleteRecordById(record, ...)}}{
#' Deletes an existing record by identifier (constraint used to identify the record based on its identifier).
#' }
#' \item{\code{harvestRecord(sourceUrl, resourceType)}}{
#' Harvests a single record from a \code{sourceUrl}, given a \code{resourceType} (by default "http://www.isotc211.org/2005/gmd").
#' }
#' \item{\code{harvestNode(url, query, resourceType, sourceBaseUrl)}}{
#' Harvests a CSW node (having its endpoint defined by an \code{url}). A \code{query} (object of class \code{CSWQuery}) can be
#' specificed if needed to restrain the harvesting to a subset. The \code{resourceType} defines the type of resources to be harvested
#' (by default "http://www.isotc211.org/2005/gmd")
#' }
#' }
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
Expand Down Expand Up @@ -99,7 +132,7 @@ CSWClient <- R6Class("CSWClient",
self$ERROR(errorMsg)
stop(errorMsg)
}
request <- CSWDescribeRecord$new(op, self$getUrl(), self$getVersion(),
request <- CSWDescribeRecord$new(self$capabilities, op, self$getUrl(), self$getVersion(),
user = self$getUser(), pwd = self$getPwd(), token = self$getToken(), headers = self$getHeaders(),
namespace = namespace, logger = self$loggerType, ...)
return(request$getResponse())
Expand All @@ -117,7 +150,7 @@ CSWClient <- R6Class("CSWClient",
self$ERROR(errorMsg)
stop(errorMsg)
}
request <- CSWGetRecordById$new(op, self$getUrl(), self$getVersion(),
request <- CSWGetRecordById$new(self$capabilities, op, self$getUrl(), self$getVersion(),
user = self$getUser(), pwd = self$getPwd(), token = self$getToken(), headers = self$getHeaders(),
id = id, elementSetName = elementSetName,
logger = self$loggerType, ...)
Expand All @@ -141,7 +174,7 @@ CSWClient <- R6Class("CSWClient",
hasMaxRecords <- !is.null(maxRecords)
if(hasMaxRecords) if(maxRecords < maxRecordsPerRequest) maxRecordsPerRequest <- maxRecords

firstRequest <- CSWGetRecords$new(op, self$getUrl(), self$getVersion(),
firstRequest <- CSWGetRecords$new(self$capabilities, op, self$getUrl(), self$getVersion(),
user = self$getUser(), pwd = self$getPwd(), token = self$getToken(), headers = self$getHeaders(),
query = query, logger = self$loggerType,
maxRecords = maxRecordsPerRequest, ...)
Expand All @@ -168,7 +201,7 @@ CSWClient <- R6Class("CSWClient",
maxRecordsPerRequest <- numberOfRecordsMatched - length(records)
}
}
nextRequest <- CSWGetRecords$new(op, self$getUrl(), self$getVersion(),
nextRequest <- CSWGetRecords$new(self$capabilities, op, self$getUrl(), self$getVersion(),
user = self$getUser(), pwd = self$getPwd(), token = self$getToken(), headers = self$getHeaders(),
query = query, logger = self$loggerType,
startPosition = nextRecord,
Expand Down Expand Up @@ -203,7 +236,7 @@ CSWClient <- R6Class("CSWClient",
}
}
#transation
transaction <- CSWTransaction$new(op, cswt_url, self$getVersion(), type = type,
transaction <- CSWTransaction$new(self$capabilities, op, cswt_url, self$getVersion(), type = type,
user = self$getUser(), pwd = self$getPwd(), token = self$getToken(), headers = self$getHeaders(),
record = record, recordProperty = recordProperty, constraint = constraint,
logger = self$loggerType, ...)
Expand Down Expand Up @@ -275,7 +308,7 @@ CSWClient <- R6Class("CSWClient",
stop(errorMsg)
}
self$INFO(sprintf("Harvesting '%s' ...", sourceUrl))
harvest <- CSWHarvest$new(op, self$getUrl(), self$getVersion(),
harvest <- CSWHarvest$new(self$capabilities, op, self$getUrl(), self$getVersion(),
source = sourceUrl, resourceType = resourceType, resourceFormat = "application/xml",
logger = self$loggerType)

Expand Down
4 changes: 2 additions & 2 deletions R/CSWDescribeRecord.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#'
#' @section Methods:
#' \describe{
#' \item{\code{new(url, version, namespace, ...)}}{
#' \item{\code{new(capabilities, op, url, version, namespace, logger, ...)}}{
#' This method is used to instantiate a CSWDescribeRecord object
#' }
#' }
Expand All @@ -24,7 +24,7 @@ CSWDescribeRecord <- R6Class("CSWDescribeRecord",
defaultNamespace = "csw:http://www.opengis.net/cat/csw/2.0.2"
),
public = list(
initialize = function(op, url, version, namespace = NULL, logger = NULL, ...) {
initialize = function(capabilities, op, url, version, namespace = NULL, logger = NULL, ...) {
namedParams <- list(service = "CSW", version = version)

#default output schema
Expand Down
8 changes: 4 additions & 4 deletions R/CSWGetRecordById.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#'
#' @section Methods:
#' \describe{
#' \item{\code{new(op, url, serviceVersion, user, pwd, token, id, elementSetName, logger, ...)}}{
#' \item{\code{new(capabilities, op, url, serviceVersion, user, pwd, token, headers, id, elementSetName, logger, ...)}}{
#' This method is used to instantiate a CSWGetRecordById object
#' }
#' }
Expand All @@ -31,8 +31,8 @@ CSWGetRecordById <- R6Class("CSWGetRecordById",
public = list(
Id = NA,
ElementSetName = "full",
initialize = function(op, url, serviceVersion = "2.0.2",
user = NULL, pwd = NULL, token = NULL,
initialize = function(capabilities, op, url, serviceVersion = "2.0.2",
user = NULL, pwd = NULL, token = NULL, headers = headers,
id, elementSetName = "full", logger = NULL, ...) {
self$Id = id
allowedElementSetNames <- c("full", "brief", "summary")
Expand All @@ -42,7 +42,7 @@ CSWGetRecordById <- R6Class("CSWGetRecordById",
}
self$ElementSetName = elementSetName
super$initialize(op, "POST", url, request = private$xmlElement,
user = user, pwd = pwd, token = token,
user = user, pwd = pwd, token = token, headers = headers,
contentType = "text/xml", mimeType = "text/xml",
logger = logger, ...)

Expand Down
8 changes: 4 additions & 4 deletions R/CSWGetRecords.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#'
#' @section Methods:
#' \describe{
#' \item{\code{new(op, url, serviceVersion, user, pwd, token, query, logger, ...)}}{
#' \item{\code{new(capabilities, op, url, serviceVersion, user, pwd, token, headers, query, logger, ...)}}{
#' This method is used to instantiate a CSWGetRecords object
#' }
#' }
Expand All @@ -34,11 +34,11 @@ CSWGetRecords <- R6Class("CSWGetRecords",
),
public = list(
Query = NULL,
initialize = function(op, url, serviceVersion = "2.0.2",
user = NULL, pwd = NULL, token = NULL,
initialize = function(capabilities, op, url, serviceVersion = "2.0.2",
user = NULL, pwd = NULL, token = NULL, headers = list(),
query = NULL, logger = NULL, ...) {
super$initialize(op, "POST", url, request = private$xmlElement,
user = user, pwd = pwd, token = token,
user = user, pwd = pwd, token = token, headers = headers,
contentType = "text/xml", mimeType = "text/xml",
logger = logger, ...)
nsVersion <- ifelse(serviceVersion=="3.0.0", "3.0", serviceVersion)
Expand Down
8 changes: 4 additions & 4 deletions R/CSWHarvest.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#'
#' @section Methods:
#' \describe{
#' \item{\code{new(op, url, serviceVersion, user, pwd, source, resourceType, resourceFormat, logger, ...)}}{
#' \item{\code{new(capabilities, op, url, serviceVersion, user, pwd, source, resourceType, resourceFormat, logger, ...)}}{
#' This method is used to instantiate a CSWHarvest object
#' }
#' }
Expand All @@ -31,14 +31,14 @@ CSWHarvest <- R6Class("CSWHarvest",
Source = NULL,
ResourceType = "http://www.isotc211.org/2005/gmd",
ResourceFormat = "application/xml",
initialize = function(op, url, serviceVersion = "2.0.2",
user = NULL, pwd = NULL, token = NULL,
initialize = function(capabilities, op, url, serviceVersion = "2.0.2",
user = NULL, pwd = NULL, token = NULL, headers = list(),
source = NULL,
resourceType = "http://www.isotc211.org/schemas/2005/gmd/",
resourceFormat = "application/xml",
logger = NULL, ...) {
super$initialize(op, "POST", url, request = private$xmlElement,
user = user, pwd = pwd, token = token,
user = user, pwd = pwd, token = token, headers = headers,
contentType = "text/xml", mimeType = "text/xml",
logger = logger, ...)
nsVersion <- ifelse(serviceVersion=="3.0.0", "3.0", serviceVersion)
Expand Down
7 changes: 5 additions & 2 deletions R/CSWQuery.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
#' @format \code{\link{R6Class}} object.
#' @section Methods:
#' \describe{
#' \item{\code{new(filter, serviceVersion)}}{
#' This method is used to instantiate an CSWQUery object.
#' \item{\code{new(elementSetName, constraint, typeNames, serviceVersion)}}{
#' This method is used to instantiate an CSWQUery object. The \code{elementSetName} can be
#' either "full" (default), "brief" or "summary". A constraint \code{CSWConstraint} can be
#' defined for the query. The \code{typeNames} indicates to query (default "csw:Record").
#' The \code{serviceVersion} gives the CSW service version (default "2.0.2")
#' }
#' }
#'
Expand Down
2 changes: 1 addition & 1 deletion R/CSWRecordProperty.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @format \code{\link{R6Class}} object.
#' @section Methods:
#' \describe{
#' \item{\code{new(name, value)}}{
#' \item{\code{new(name, value, cswVersion)}}{
#' This method is used to instantiate an CSWRecordProperty object.
#' }
#' }
Expand Down
4 changes: 2 additions & 2 deletions R/CSWTransaction.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#'
#' @section Methods:
#' \describe{
#' \item{\code{new(op, url, serviceVersion, type, user, pwd, token, headers,
#' \item{\code{new(capabilities, op, url, serviceVersion, type, user, pwd, token, headers,
#' record, recordProperty, constraint, logger, ...)}}{
#' This method is used to instantiate a CSWTransaction object
#' }
Expand All @@ -26,7 +26,7 @@ CSWTransaction <- R6Class("CSWTransaction",
xmlNamespace = c(csw = "http://www.opengis.net/cat/csw")
),
public = list(
initialize = function(op, url, serviceVersion, type,
initialize = function(capabilities, op, url, serviceVersion, type,
user = NULL, pwd = NULL, token = NULL, headers = list(),
record = NULL, recordProperty = NULL, constraint = NULL,
logger = NULL, ...) {
Expand Down
11 changes: 10 additions & 1 deletion R/OGCAbstractObject.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@
#' @format \code{\link{R6Class}} object.
#' @section Methods:
#' \describe{
#' \item{\code{new()}}{
#' \item{\code{new(attrs, defaults = list(), wrap, logger)}}{
#' This method is used to instantiate an OGCAbstractObject
#' }
#' \item{\code{getClassName()}}{
#' Get class name
#' }
#' \item{\code{getClass()}}{
#' Get class
#' }
#' \item{\code{encode(addNS, geometa_validate, geometa_inspire)}}{
#' Encode as XML
#' }
#' }
#' @note abstract class used by \pkg{ows4R}
#'
Expand Down
10 changes: 8 additions & 2 deletions R/OGCExpression.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@
#' @format \code{\link{R6Class}} object.
#' @section Methods:
#' \describe{
#' \item{\code{new()}}{
#' This method is used to instantiate an OGCExpression object
#' \item{\code{new(attrs, defaults, exprVersion)}}{
#' This method is used to instantiate an \code{OGCExpression} object
#' }
#' \item{\code{setExprVersion(exprVersion)}}{
#' Set expression version
#' }
#' \item{\code{getExprVersion()}}{
#' Get expression version
#' }
#' }
#'
Expand Down
5 changes: 4 additions & 1 deletion R/OGCFilter.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
#' @format \code{\link{R6Class}} object.
#' @section Methods:
#' \describe{
#' \item{\code{new(expr)}}{
#' \item{\code{new(exprn filterVersion)}}{
#' This method is used to instantiate an OGCFilter object. The unique
#' argument should be an object of class \code{\link{OGCExpression}}
#' }
#' \item{\code{setFilterVersion(filterVersion)}}{
#' Set filter version
#' }
#' }
#'
#' @examples
Expand Down
3 changes: 1 addition & 2 deletions R/OWSCapabilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ OWSCapabilities <- R6Class("OWSCapabilities",
private$owsVersion <- owsVersion
private$serviceVersion <- serviceVersion
namedParams <- list(service = service, version = serviceVersion)
private$request <- OWSGetCapabilities$new(op = NULL, url, service, serviceVersion,
logger = logger, ...)
private$request <- OWSGetCapabilities$new(url, service, serviceVersion, logger = logger, ...)
xmlObj <- private$request$getResponse()
private$serviceIdentification <- OWSServiceIdentification$new(xmlObj, owsVersion, serviceVersion)
private$serviceProvider <- OWSServiceProvider$new(xmlObj, owsVersion, serviceVersion)
Expand Down
6 changes: 3 additions & 3 deletions R/OWSGetCapabilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#'
#' @section Methods:
#' \describe{
#' \item{\code{new(op, url, service, version, ...)}}{
#' \item{\code{new(capabilities, op, url, service, version, ...)}}{
#' This method is used to instantiate a OWSGetCapabilities object
#' }
#' }
Expand All @@ -23,9 +23,9 @@ OWSGetCapabilities <- R6Class("OWSGetCapabilities",
name = "GetCapabilities"
),
public = list(
initialize = function(op, url, service, version, ...) {
initialize = function(url, service, version, ...) {
namedParams <- list(service = service, version = version)
super$initialize(op, "GET", url, request = private$name,
super$initialize(capabilities = NULL, op = NULL, "GET", url, request = private$name,
namedParams = namedParams, mimeType = "text/xml", ...)
self$execute()
}
Expand Down
Loading

0 comments on commit 2e78fa8

Please sign in to comment.