Mercurial > repos > prog > lcmsmatching
view RemotedbConn.R @ 4:b34c14151f25 draft
planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 494194bb501d1d7033613131865f7bd68976041c
author | prog |
---|---|
date | Tue, 14 Mar 2017 12:40:22 -0400 |
parents | 20d69a062da3 |
children |
line wrap: on
line source
if ( ! exists('RemotedbConn')) { ##################### # CLASS DECLARATION # ##################### RemotedbConn <- methods::setRefClass("RemotedbConn", contains = "BiodbConn", fields = list(.scheduler = "UrlRequestScheduler", .token = "character")) ############### # CONSTRUCTOR # ############### RemotedbConn$methods( initialize = function(useragent = NA_character_, scheduler = NULL, token = NA_character_, ...) { # Check useragent ( ! is.null(useragent) && ! is.na(useragent)) || stop("You must specify a valid useragent string (e.g.: \"myapp ; my.email@address\").") # Set token .token <<- token # Set scheduler if (is.null(scheduler)) scheduler <- UrlRequestScheduler$new(n = 3) inherits(scheduler, "UrlRequestScheduler") || stop("The scheduler instance must inherit from UrlRequestScheduler class.") scheduler$setUserAgent(useragent) # set agent .scheduler <<- scheduler callSuper(...) # calls super-class initializer with remaining parameters }) ########### # GET URL # ########### RemotedbConn$methods( .get.url = function(url) { .self$.print.debug.msg(paste0("Sending URL request '", url, "'...")) return(.self$.scheduler$getUrl(url)) }) ########### # GET URL # ########### RemotedbConn$methods( .set.useragent = function(useragent) { .scheduler$setUserAgent(useragent) # set agent }) }