Importing ODP Data using R

Omni Data Platform (ODP), an enterprise data management platform by CAPIOT, is a cornerstone in the digital enterprise. It provides users with  unprecedented simplicity to design and distribute data in real-time. The platform gives developers and analysts a shot-in-the-arm during their implementation phase as it takes care of all service layer and data layer build and deployments. 

Fig1. ODP Business Author Services

Why do we need to pull from ODP?

In today’s world, data is leveraged to derive actionable insights which  provides the company with data points that will help forge its business strategy and long-term plans. . Here ODP acts as a datawarehouse  that stores information important for  the company.

Use Case :

ODP being used as a Data Management System which holds Employee data.

In this blog, we will pull a data entity (Employee Details) from ODP  into R studio and Spotfire for performing analysis.

The intended audience of this data set will be data analysts who can create actionable insights from the data set.

Step 1: Schema Creation  in ODP Author

Fig2. ODP Business Author Schema Creation for EmployeeDetails Service

Create three attributes in Employee Details.  Name, Age, City.

On save, ODP creates the CRUD APIs for these entities and the services are deployed as docker containers..

Step 2 : Adding Records into Employee Details

Login to ODP Client and add the records for the Employee Details

Fig3. Addition of Records in ODP Business Center

Once records have been inserted, users can use the CRUD APIs that were generated at schema creation to act on these data records.  intantly provides .  In our case, we are going to pull data from ODP and use that data in R and Spotfire..

Step 3 : Importing ODP Data in R studio

Using the below R script we managed to pull data from ODP to R Studio.

                                                   R script :

#Import the Libraries

library(httr)

library(jsonlite)

library(purrr)

library(data.table)

## 1.Create a Token

#Framing JSON Request to create a token

loginreq = ‘{ “username” : “jack @xyz.com”, “password” : “jack@123”}’

#Fetch the Token using HTTP POST API

req=httr::POST(“https://xyzabc123456.com/api/a/rbac/login”,httr::add_headers( “Content-Type” = “application/json;charset=UTF-8” ),body = loginreq  );

#Parse the HTTP JSON response to R object

odptoken = content(req , as=”parse”)

#Creating the token by Concat JWT with a token value

oktoken = paste( “JWT” , odptoken$token, sep=” “)

## 2. GET  records count from Employee Details

# Get the total count of records for the Employee Details service

resp<-GET(“https:// xyzabc123456.com/api/c/CapiotInternalDemo/dddd/count”,add_headers(accept = “application/json”,authorization = oktoken))

# Set the total count value to variable

totalcount =content(resp,as=”text”)

##  3. Pull all the Employee Details data from ODP

odpGet<-GET(“https://xyzabc123456.com/api/c/CapiotInternalDemo/dddd/”,query=list(count=totalcount ,expand=”false”,sort=”_id”,select=”name,age,city”),add_headers(accept=”application/json” ,authorization = oktoken))

odpGet1 = content(odpGet , as=”text”)

# Convert each line from json to a list

json_list <- map(odpGet1, fromJSON)

# Convert each list to a data.table

dt_list <- map(json_list, as.data.table)

#Harness the power of rbind list

dt <- rbindlist(dt_list, fill = TRUE)

Fig4. Imported ODP Records in R studio

Step 4 : Importing ODP Data in SpotFire  

Create a Register Data Function by including  the above R script.

Fig5. Creating Data Function in SpotFire

Create a the output parameter as table Data Type

Fig6. Data Functions Output parameter in Spotfire

Click OK and visualize the created table in spotfire design layer

Fig7. ODP Data Table visualization in SpotFire

Leave a comment

Design a site like this with WordPress.com
Get started