Is an Ajax Database Connectivity (ADBC) layer. Provides data access support for various data sources (SQL, SPARQL, SOAP, etc.) and allows binding and execution of callbacks upon data arrival. Data are fetched on demand and cached.
Creates new DataSource object.typeis one of TYPE_constants.
Assigns an OAT.Connection object to this DataSource.
Object with various properties, dependent on DataSource TYPE_: * TYPE_SQL
List of wanted fields in fetched data.
Listens for new data records. When new record is available, recordCallback is executed with 2 arguments: record data and record index.
Listens for new data record pages. When new data page (record set) is available, pageCallback is executed with 2 arguments:page data and page index.
Listens for new data file. When new data file is available, fileCallback is executed with 1 argument: file contents.
Listens for empty dataset. When empty dataset arrives, emptyCallback is executed.
Listens for data header. When header arrives, headerCallback is executed with 1 argument: data header.
Advances through records.recordIndex must be an integer.
var conn = new OAT.Connection(OAT.ConnectionData.TYPE_REST, {url:"myfile.xml"}); var ds = new OAT.DataSource(OAT.DataSourceData.TYPE_REST); ds.connection = conn; ds.options.output = 0; /* fetch result as XML */ ds.options.xpath = 1; /* outputFields are specified as XPATH expressions */ ds.outputFields = ['//result/binding[@name="created"]/node()/text()', '//result/binding[@name="creator"]/node()/text()', '//result/binding[@name="item_title"]/node()/text()', '//result/binding[@name="url"]/node()/text()']; var recordCallback = function(data, index) { alert('Data at index ' + index + ':\n' + data ); } ds.bindRecord(recordCallback); ds.advanceRecord(0);
var conn = new OAT.Connection(OAT.ConnectionData.TYPE_XMLA, {dsn:"DSN=Local_Instance",endpoint:"/XMLA"}); var ds = new OAT.DataSource(OAT.DataSourceData.TYPE_SQL); ds.connection = conn; ds.options.query = "SELECT OrderID, CustomerID, EmployeeID FROM Demo.demo.Orders"; var recordCallback = function(data, index) { alert('Data at index ' + index + ':\n' + data ); } ds.bindRecord(recordCallback); ds.advanceRecord(0);
var connection = new OAT.Connection(OAT.ConnectionData.TYPE_REST,{url:"/sparql/"}); var q = "SELECT ?s, ?p, ?o FROM <http://www.flickr.com/search/?q=rdf+semanticweb&s=rec> WHERE { ?s ?p ?o . }"; var ds = new OAT.DataSource(OAT.DataSourceData.TYPE_SPARQL); ds.outputFields = ['//result/binding[@name="s"]/node()/text()', '//result/binding[@name="p"]/node()/text()', '//result/binding[@name="o"]/node()/text()']; ds.connection = connection; ds.options.query = "query="+encodeURIComponent(q)+"&format=xml"; ds.options.output = 0; /* fetch result as XML */ ds.options.xpath = 1; /* outputFields are specified as XPATH expressions */ var recordCallback = function(data, index) { alert('Data at index ' + index + ':\n' + data ); } ds.bindRecord(recordCallback); ds.advanceRecord(0);
var conn = new OAT.Connection(OAT.ConnectionData.TYPE_REST, {url:"gdata.xml"}); var ds = new OAT.DataSource(OAT.DataSourceData.TYPE_GDATA); ds.connection = conn; ds.options.output = 0; ds.options.xpath = 1; ds.outputFields = [ "//atom:feed/atom:entry/atom:title" ]; var recordCallback = function(data, index) { alert('Data at index ' + index + ':\n' + data ); } ds.bindRecord(recordCallback); ds.advanceRecord(0);