diff BiodbConn.R @ 1:253d531a0193 draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
author prog
date Sat, 03 Sep 2016 17:02:01 -0400
parents e66bb061af06
children 20d69a062da3
line wrap: on
line diff
--- a/BiodbConn.R	Tue Jul 12 12:02:37 2016 -0400
+++ b/BiodbConn.R	Sat Sep 03 17:02:01 2016 -0400
@@ -1,33 +1,30 @@
-if ( ! exists('BiodbConn')) { # Do not load again if already loaded
+if ( ! exists('BiodbConn')) {
 
-	source(file.path('UrlRequestScheduler.R'), chdir = TRUE)
 	source('biodb-common.R')
 
 	#####################
 	# CLASS DECLARATION #
 	#####################
 	
-	BiodbConn <- setRefClass("BiodbConn", fields = list(.scheduler = "UrlRequestScheduler"))
+	BiodbConn <- setRefClass("BiodbConn", fields = list( .debug = "logical" ))
 
 	###############
 	# CONSTRUCTOR #
 	###############
 
-	BiodbConn$methods( initialize = function(useragent = NA_character_, scheduler = NULL, ...) {
-
-		# Check useragent
-		! is.null(useragent) && ! is.na(useragent) || stop("You must specify a valid useragent.")
+	BiodbConn$methods( initialize = function(debug = FALSE, ...) {
+		.debug <<- debug
+	})
 
-		# 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
+	#######################
+	# PRINT DEBUG MESSAGE #
+	#######################
+
+	BiodbConn$methods( .print.debug.msg = function(msg) {
+		if (.self$.debug)
+			.print.msg(msg = msg, class = class(.self))
 	})
-	
+
 	######################
 	# HANDLES ENTRY TYPE #
 	######################
@@ -59,7 +56,7 @@
 	
 	# Download entry content from the public database.
 	# type      The entry type.
-	# id        The ID of the enttry to get.
+	# id        The ID of the entry to get.
 	# RETURN    An entry content downloaded from database.
 	BiodbConn$methods( getEntryContent = function(type, id) {
 		stop("Method getCompound() is not implemented in concrete class.")
@@ -75,4 +72,22 @@
 	BiodbConn$methods( createEntry = function(type, content, drop = TRUE) {
 		stop("Method createEntry() is not implemented in concrete class.")
 	})
+
+	#################
+	# GET ENTRY IDS #
+	#################
+	
+	# Get a list of IDs of all entries contained in this database.
+	BiodbConn$methods( getEntryIds = function(type) {
+		stop("Method getEntryIds() is not implemented in concrete class.")
+	})
+
+	##################
+	# GET NB ENTRIES #
+	##################
+	
+	# Get the number of entries contained in this database.
+	BiodbConn$methods( getNbEntries = function(type) {
+		stop("Method getNbEntries() is not implemented in concrete class.")
+	})
 }