Data EndPoints Datasource
AIV has rich set of predefined list of database connections using which user can connect with their database easily by providing valid properties and credentials. Although, there are many different kinds of databases available in the world as technology keeps updating day by day. In AIV we keep adding new sources as soon as it comes in to consideration. Sometimes, user may find database he is using might not available readily in AIV. At this time, it takes some time to get in to specific database and adding it in AIV. As a workaround for this, AIV provides external datasource type knows as Data EndPoints.
Objective
Objective of this document is how to fetch data & mata data from any external projects using endpoints.
Usage
Using DataEndPoints datasource, user will be able to fetch the data from any datasource.
To achive this user can create any project in any language, it can be JAVA or Python or Asp. Net or any other language. User just need to send relevant data on the defined endpoints.
Getting Started
Here we are going to demonsrtate this feature using JAVA Spring-Boot application. For Database we have used Cassandra in docker. Please follow below steps;
- Please download Spring-Boot application from below link, https://sourceforge.net/projects/spring-boot.mirror/
Install Docker on your workstation. Make sure you're on the latest version of docker-compose. Download Docker using the following URL: https://www.docker.com/products/docker-desktop
Follow this URL : https://cassandra.apache.org/_/quickstart.html to setup Cassandra in docker environment.
In STEP 3: CREATE FILES step, we have modified table name and columns for demo purpose. User can
-- Create a keyspace
CREATE KEYSPACE IF NOT EXISTS store WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : '1' };
-- Create a table
CREATE TABLE IF NOT EXISTS store.shopping_cart1 (
userid text PRIMARY KEY,
country Text,
amt int
);
-- Insert some data
INSERT INTO store.shopping_cart
(userid, country, amt)
VALUES ('9876', 'USA', 2000);
INSERT INTO store.shopping_cart
(userid, country, amt)
VALUES ('1234', 'UK', 3000);
Endpoints
In your application you have to create 4 end-points as listed below and AIV will access this endpoints to get the information;
/connection
/getobjects
/metadata
/data
Domain and port number of Rest API will be of your project URL and port number.
User need create a project and write atleast 4 methods to get relevant data from their database for each endpoints. return this data from external project and you can see information in AIV by using DataEndPoints datasource.
How it will work?
Login to AIV application using user having admin rights.
Expand Master Data section and click on datasource option
Click on create datasource button from footer menu
search Data Endpoints datasource and click on it to open it's property.
Provide Datasource name in Display Name field
In Rest URL field, provide URL where project is hosted and port number. keep other things in URL as it is.
If you have any extra configuration to connect with database apart from this, you can pass extra properties inside Extra Configuration field in Key-Value pair.
When you click on Test Connection Button [/connection
Endpoint]
After Filling Required credentials in prevoius steps, when user click on Test Connection button, AIV will call /connection
endpoint on your provided project URL.
User will receive all the information provided in create datasource fields, into his project and user will get this request in the project and write his own code to validate connection with database.
Once user credential matches, it will return success message which will be passed to AIV.
Any Message user want to return should be in Map of Key-Value pair. AIV accepts return values only in Map.
When you create dataset from datasource
Once datasource is created and connection tested successfully, next step is to create dataset out of it.
Click on grid view to go to datasource grid view as shown in below image;
Select the datasource we have just created from the grid view and click on create dataset button from footer menu.
You will see create dataset window. select DATA ENDPOINTS option from Datasource dropdown as shown in below image,
From the source option, given just right side of Datasource, you will see datasource we have created is selected by default.
If you are creating dataset from dataset section, you have to select source from the list
/getobjects
Endpoint
you can see small refresh icon given at just right side of source dropdown, in order to get the list of tables available in database connected with project, click on this icon.
When you click on refresh icon, AIV will call /getobjects
endpoint to your project and you can get headers info where this enpoint is mapped in your project. User should write code to get tables data by connecting with database. Fetched information or data should be then returned ti AIV in form of Map of Key-Value pair
Any Data user want to return to AIV,should be in Map of Key-Value pair. AIV accepts return values only in Map.
This returned information is displayed as list of tables in tree view as shown in below image,
To get the data from tables, just drag and drop table from the left side tree view in to right side query window. When you drop table in to query window, you can see column selector window. select number of column you wish to fetch from the table and click on submit button.
/metadata
Endpoint
To check column details, click on Output Columns tab, you can see details of columns you have selected in previous step.
When you click on Output Columns tab, AIV will call /metadata
endpoint in to your project URL and you can get headers info where this enpoint is mapped in your project. User should write code to get selected column information or Metadata of table by connecting with database. Fetched information or data should be then returned ti AIV in form of Map of Key-Value pair.
Any Data user want to return to AIV,should be in Map of Key-Value pair. AIV accepts return values only in Map.
/data
Endpoint
Once you get column details in Output Columns tab, click on preview tab to view data present in the table with selected columns.
When you click on preview tab, AIV will call /data
endpoint in to your project URL and you can get headers info where this enpoint is mapped in your project. User should write code to get table data by connecting with database. Fetched information or data should be then returned ti AIV in form of Map of Key-Value pair.
Any Data user want to return to AIV,should be in Map of Key-Value pair. AIV accepts return values only in Map.