Extensible Data Source Framework

Blog Post created by banty01 Employee on Sep 6, 2018

CA Live API Creator 5.0 introduced a new service that allows developers to extend their connectivity to outside data sources using a new framework.  This framework is a collection of JavaScript code which can access Java JAR files and execute the basic operations of configuring, connecting, retrieval, update, and manipulation of external datasets.  The 5.0 release ships with 2 examples, MongoDB (a NoSQL database) and JDBCExample (an Apache/Derby sample).  


The Extensible Data Source Framework is accessed using the 'Data Sources' Add button on a new or existing API.  To add a new Data Source Provider (you will need to logon to the 'sa' account to see the wizard) you can start the process of cloning an existing example or creating one from scratch.  Depending on the datasource, you will need to add one or more JAR files to your container classpath and restart your server.  The examples show how to reference the Java classes using the Java.type('') syntax.  Once you have created a test connection, configuration, and configuration info (the parameters used and passed to your connection).  You will need to retrieve a minimal set of metadata to describe the objects (enitites), attributes (if available), and datatypes (e.g. string, number, boolean, etc). Some datasources do not have this information which is okay (see the MongoDB getMetadata example). 


If your needs are limited to read-only (e.g. GET) then you will need to implement the getQuery and getOne code. The query code will have access to the rest sysfilter and sysorder variables.  The getOne code is used to retrieve an object by primary key(s).  The getInsert, getUpdate, and getDelete code sections can be skipped if this will be a read-only provider.  If the database does not support transactions, then the commit and rollback sections can also be skipped.  Finally, the close connection is only needed if you are passing a shared connection between calls (e.g. poolable connection). For more details, see the documentation page.