diff RemotedbConn.R @ 2:20d69a062da3 draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
author prog
date Thu, 02 Mar 2017 08:55:00 -0500
parents 253d531a0193
children
line wrap: on
line diff
--- a/RemotedbConn.R	Sat Sep 03 17:02:01 2016 -0400
+++ b/RemotedbConn.R	Thu Mar 02 08:55:00 2017 -0500
@@ -1,23 +1,23 @@
 if ( ! exists('RemotedbConn')) {
 
-	source('BiodbConn.R')
-	source(file.path('UrlRequestScheduler.R'), chdir = TRUE)
-
 	#####################
 	# CLASS DECLARATION #
 	#####################
 	
-	RemotedbConn <- setRefClass("RemotedbConn", contains = "BiodbConn", fields = list(.scheduler = "UrlRequestScheduler"))
+	RemotedbConn <- methods::setRefClass("RemotedbConn", contains = "BiodbConn", fields = list(.scheduler = "UrlRequestScheduler", .token = "character"))
 
 	###############
 	# CONSTRUCTOR #
 	###############
 
-	RemotedbConn$methods( initialize = function(useragent = NA_character_, scheduler = NULL, ...) {
+	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)
@@ -28,4 +28,21 @@
 		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
+	})
+
 }