Page History
...
Communicator Subsystem (v1.4 and up)
...
Overview
Starting with version 1.4 of the web client, AJAX communication routines have been abstracted into a standardized subsystem. The communication subsystem consists of 2 primary object classes:
...
2a | A communications method call is made to the i2b2.CELLCODE.ajax.METHODNAME. |
2b | The generic communicator code performs a synchronous or asynchronous call to the i2b2 hive back-end and retrieves the results. |
2c | The cell communicator returns a standardized Communications Message Object containing the resultant XML as well as an optional method called parse (). |
2d | Calling the parse () method of the Communications Message Object will cause a JavaScript array called data to be added to the object which contains information extracted by the default associated parser routine. If an error is encountered data === false. |
...
...
Creating a Communicator Object
...
Object Instantiation and Definition of Data Namespaces
Create an instance of the generic communicator object using a call to i2b2.hive.communicatorFactory() function and save it to the ajax namespace of your cell or plug-in. You will also need to define a namespace to hold the XML message templates used to send requests to the i2b2 Hive.
You may optionally define a namespace to hold any functions you plan on using to process the returned XML document into a more easily worked with native-JavaScript format. Best practice is to call these namespaces msgs and parsers respectively and to add them to your cell / plug-in's cfg namespace.
i2b2.ONT.ajax = i2b2.hive.communicatorFactory ("ONT"); // create namespaces to store the communicator's msg templates and parsers i2b2.ONT.cfg.msgs = {}; i2b2.ONT.cfg.parsers = {}; |
...
...
Definition of XML Message
Now the individual XML message templates need to be created. These templates are simply strings saved into the msgs namespace. Best practice is to save them using a name that is the same as the i2b2 Hive RPC call.
i2b2.ONT.cfg.msgs.GetSchemes = '<?xml version="1.0" encouding="UTF-8" |
|
Placeholder tags starting, and ending, with three curly brackets ( "{" and "
}" ) are contained throughout this message string. Between the tag's curly brackets is its non-space containing name used to identify the tag. These tags are replaced with values passed in the call parameters when the communication method is invoked.
...
Tag Name | Example Value | Description |
{ | <proxy> | Information used by the Web Client's proxy server |
{ | HarvardDemo | Domain of current project |
{ | Demo | Code of current project |
{ | demo | User currently logged in |
{ | <password token_ms_timeout='1800000' is_token='true'> | See Documentation on Hive Project Management Cell |
{ | mQgJaD4z12dd2vLWWzY64 | Runtime generated GUID |
{ | 2010-05-19T13:24:35-04:00 | Current datetime in ISO8601 |
{ | 180 | Max query time in seconds |
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="2109d52ab7061479-0a8d6f7b-4d8249e9-aef78d57-f8e33cf3396439c914d5d8f8"><ac:plain-text-body><![CDATA[ | i2b2.ONT.cfg.parsers.GetSchemes = function(){ if (!this.error) { this.model = []; // extract records from XML msg var c = this.refXML.getElementsByTagName('concept'); for (var i=0; i < 1 * c.length; i++) { var o = new Object; o.xmlOrig = c[i]; o.level = i2b2.h.getXNodeVal(c[i],'level'); o.key = i2b2.h.getXNodeVal(c[i],'key'); o.name = i2b2.h.getXNodeVal(c[i],'name'); o.total_num = i2b2.h.getXNodeVal(c[i],'totalnum'); // save extracted info this.model.push(o); } } else { this.model = false; console.error( | ]]></ac:plain-text-body></ac:structured-macro> |
...
<div id="ExampTabs-mainDiv"> |
...
i2b2.CRC.ajax._addFunctionCall("runQueryInstance_fromQueryDefinition", "{ |
The optional fifth parameter is a reference to a special parser function that is used to extract information from the XML message returned from the i2b2 Hive back-end. If you are not using a parser then you can omit it from the function parameter list. The parser function that is passed to create a communication method via the _addFunctionCall function is said to be the "default message parser".
...