Skip to content

Commit

Permalink
#2, #14 OpenAPI getTags, getCategories
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Sep 10, 2021
1 parent 9a2650f commit ff36a51
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
45 changes: 44 additions & 1 deletion R/GNOpenAPIManager.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@
#' \item{\code{getGroups()}}{
#' Retrieves the list of user groups available in Geonetwork
#' }
#' \item{\code{getTags()}}{
#' Retrieves the list of tags (categories) available in Geonetwork
#' }
#' \item{\code{getCategories()}}{
#' Same as \code{getTags()}
#' }
#' \item{\code{insertMetadata(xml, file, geometa, metadataType, uuidProcessing,
#' group, category, rejectIfInvalid, publishToAll,
#' transformWith, schema, extra,
Expand Down Expand Up @@ -187,7 +193,44 @@ GNOpenAPIManager <- R6Class("GNOpenAPIManager",
}
return(out)
},


#getTags
#---------------------------------------------------------------------------
getTags = function(){
out <- NULL
self$INFO("Getting tags (categories)...")
req <- GNUtils$GET(
url = self$getUrl(),
path = "/api/tags",
token = private$getToken(), cookies = private$cookies,
user = private$user,
pwd = private$getPwd(),
verbose = self$verbose.debug
)
if(status_code(req) == 200){
self$INFO("Successfully fetched tags (categories)!")
json <- content(req, encoding = "UTF-8")
out <- do.call("rbind", lapply(json, function(json.tag){
out.tag <- data.frame(
id = json.tag$id,
name = json.tag$name,
stringsAsFactors = FALSE
)
labels <- data.frame(json.tag$label)
out.tag <- cbind(out.tag, labels)
return(out.tag)
}))
}else{
self$ERROR("Error while fetching tags (categories)")
}
return(out)
},

#getCategories
#---------------------------------------------------------------------------
getCategories = function(){
return(self$getTags())
},

#insertMetadata
#---------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions man/GNOpenAPIManager.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ff36a51

Please sign in to comment.