BiodbRequestScheduler | R Documentation |
Class for handling requests.
Class for handling requests.
This class handles GET and POST requests, as well as file downloading. Each
remote database connection instance creates an instance of
BiodbRequestScheduler
for handling database connection. A timer is
used to schedule connections, and avoid sending too much requests to the
database. This class is not meant to be used directly by the library user.
See section Fields for a list of the constructor's parameters.
new()
New instance initializer. BiodbRequestScheduler class must not be instantiated direrctly. Instead, use the getRequestScheduler() method from BiodbMain.
BiodbRequestScheduler$new(bdb)
bdb
The BiodbMain instance.
Nothing.
sendSoapRequest()
Sends a SOAP request to a URL. Returns the string result.
BiodbRequestScheduler$sendSoapRequest( url, soap.request, soap.action = NA_character_, encoding = integer() )
url
The URL to access, as a character string.
soap.request
The XML SOAP request to send, as a character string.
soap.action
The SOAP action to contact, as a character string.
encoding
The encoding to use.
The results returned by the contacted server, as a single string value.
sendRequest()
Sends a request, and returns content result.
BiodbRequestScheduler$sendRequest(request, cache.read = TRUE)
request
A BiodbRequest instance.
cache.read
If set to TRUE, the cache system will be used. In case the same request has already been run and its results saved into the cache, then the request is not run again, the targeted server not contacted, and the results are directly loaded from the cache system.
The results returned by the contacted server, as a single string value.
downloadFile()
Downloads the content of a URL and save it into the specified destination file.
BiodbRequestScheduler$downloadFile(url, dest.file)
url
The URL to access, as a BiodbUrl object.
dest.file
A path to a destination file.
Nothing.
notifyConnUrlsUpdated()
Call back function called when connector URLs are changed.
BiodbRequestScheduler$notifyConnUrlsUpdated(conn)
conn
The connector instance for which the URLs were changed.
Nothing.
notifyConnSchedulerFrequencyUpdated()
Call back function called when connector T and N parameters (frequency) are changed.
BiodbRequestScheduler$notifyConnSchedulerFrequencyUpdated(conn)
conn
The connector instance for which the frequency were changed.
Nothing.
getUrlString()
Builds a URL object, using a base URL and parameters to be passed.
BiodbRequestScheduler$getUrlString(url, params = list())
url
A URL string.
params
A list of URL parameters.
A BiodUrl object.
getUrl()
Sends a request and get the result.
BiodbRequestScheduler$getUrl( url, params = list(), method = c("get", "post"), header = character(), body = character(), encoding = integer() )
url
A URL string.
params
A list of URL parameters.
method
The method to use. Either 'get' or 'post'.
header
The header to send.
body
The body to send.
encoding
The encoding to use.
The results of the request.
findRule()
Searches for a rule by host name.
BiodbRequestScheduler$findRule(url, create = TRUE)
url
The host URL.
create
Sets to TRUE to create a rule when none exists.
A BiodbRequestSchedulerRule object.
getConnectorRules()
Gets the rules associates with a connector.
BiodbRequestScheduler$getConnectorRules(conn)
conn
A valid connector object.
A list of rules.
registerConnector()
Registers a new connector with the scheduler.
BiodbRequestScheduler$registerConnector(conn)
conn
A valid connector object.
Nothing.
unregisterConnector()
Unregisters a connector from this scheduler.
BiodbRequestScheduler$unregisterConnector(conn)
conn
A valid connector object.
Nothing.
getAllRules()
Gets all defined rules.
BiodbRequestScheduler$getAllRules()
The list of all rules.
clone()
The objects of this class are cloneable with this method.
BiodbRequestScheduler$clone(deep = FALSE)
deep
Whether to make a deep clone.
BiodbRequestSchedulerRule
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get the scheduler sched <- mybiodb$getRequestScheduler() # Create a request object u <- 'https://www.ebi.ac.uk/webservices/chebi/2.0/test/getCompleteEntity' url <- BiodbUrl$new(url=u) url$setParam('chebiId', 15440) request <- BiodbRequest$new(method='get', url=url) # Send request sched$sendRequest(request) # Terminate instance. mybiodb$terminate() mybiodb <- NULL
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.