Skip to main content

Adding an Oracle Data Source

breaking changes

Currently, the Reveal SDK is in the process of decoupling the data sources from the Reveal SDK core package. In order to ensure the project's continued functionality, you might be required to install additional packages into your project. Please see the Supported Data Sources topic for more information.

On the Client

Step 1 - Add an event handler for the RevealView.onDataSourcesRequested event.

var revealView = new $.ig.RevealView("#revealView");
revealView.onDataSourcesRequested = (callback) => {
//add code here
callback(new $.ig.RevealDataSources([], [], false));
};

Step 2 - In the RevealView.onDataSourcesRequested event handler, create a new instance of the RVOracleSIDDataSource or RVOracleServiceDataSource object (depending on your setup). Set the Host, Database, Port, Title and SID or Service (depending on if you are using SID or Service Name) properties to values that correspond to your Oracle server. After you have created the RVOracleXXXXDataSource object, add it to the data sources collection.

revealView.onDataSourcesRequested = (callback) => {
//if you are using SID
const oracleSIDDataSource = new $.ig.RVOracleSIDDataSource();
oracleSIDDataSource.id = "MyOracleSIDDataSource";
oracleSIDDataSource.title = "My Oracle SID";
oracleSIDDataSource.host = "your-host";
oracleSIDDataSource.port = "your-port";
oracleSIDDataSource.database = "your-database";

//if you are using Service Name
const oracleServiceDataSource = new $.ig.RVOracleServiceDataSource();
oracleServiceDataSource.id = "MyOracleServiceDataSource";
oracleServiceDataSource.title = "My Oracle Service";
oracleServiceDataSource.host = "your-host";
oracleServiceDataSource.port = "your-port";
oracleServiceDataSource.database = "your-database";

callback(new $.ig.RevealDataSources([oracleSIDDataSource, oracleServiceDataSource], [], true));
};

When the application runs, create a new Visualization and you will see the newly created Oracle data source listed in the "Select a Data Source" dialog.

Step 3 - Add a new Data Source Item by creating a new instance of the RVOracleDataSourceItem object. Set the Id,Title, and Table properties that correspond to your database table. After you have created the RVOracleDataSourceItem object, add it to the data source items collection.

revealView.onDataSourcesRequested = (callback) => {
//if you are using SID
const oracleSIDDataSource = new $.ig.RVOracleSIDDataSource();
oracleSIDDataSource.id = "MyOracleSIDDataSource";
oracleSIDDataSource.title = "My Oracle SID";
oracleSIDDataSource.host = "your-host";
oracleSIDDataSource.port = "your-port";
oracleSIDDataSource.database = "your-database";

//if you are using Service Name
const oracleServiceDataSource = new $.ig.RVOracleServiceDataSource();
oracleServiceDataSource.id = "MyOracleServiceDataSource";
oracleServiceDataSource.title = "My Oracle Service";
oracleServiceDataSource.host = "your-host";
oracleServiceDataSource.port = "your-port";
oracleServiceDataSource.database = "your-database";

const oracleSIDDataSourceItem = new $.ig.RVOracleDataSourceItem(oracleSIDDataSource);
oracleSIDDataSourceItem.id = "MyOracleSIDDataSourceItem";
oracleSIDDataSourceItem.title = "My Oracle SID Item";

const oracleServiceDataSourceItem = new $.ig.RVOracleDataSourceItem(oracleServiceDataSource);
oracleServiceDataSourceItem.id = "MyOracleServiceDataSourceItem";
oracleServiceDataSourceItem.title = "My Oracle Service Item";

callback(new $.ig.RevealDataSources([oracleSIDDataSource, oracleServiceDataSource], [oracleSIDDataSourceItem, oracleServiceDataSourceItem], true));
};

When the application runs, create a new Visualization and you will see the newly created Oracle data source item listed in the "Select a Data Source" dialog.

On the Server

Step 1 - Create the data source and data source item on the client, but do not provide any connection information. Only provie an id, title, and/or subtitle.

revealView.onDataSourcesRequested = (callback) => {
//if you are using SID
const oracleSIDDataSource = new $.ig.RVOracleSIDDataSource();
oracleSIDDataSource.id = "MyOracleSIDDataSource";
oracleSIDDataSource.title = "My Oracle SID";

//if you are using Service Name
const oracleServiceDataSource = new $.ig.RVOracleServiceDataSource();
oracleServiceDataSource.id = "MyOracleServiceDataSource";
oracleServiceDataSource.title = "My Oracle Service";

const oracleSIDDataSourceItem = new $.ig.RVOracleDataSourceItem(oracleSIDDataSource);
oracleSIDDataSourceItem.id = "MyOracleSIDDataSourceItem";
oracleSIDDataSourceItem.title = "My Oracle SID Item";

const oracleServiceDataSourceItem = new $.ig.RVOracleDataSourceItem(oracleServiceDataSource);
oracleServiceDataSourceItem.id = "MyOracleServiceDataSourceItem";
oracleServiceDataSourceItem.title = "My Oracle Service Item";

callback(new $.ig.RevealDataSources([oracleSIDDataSource, oracleServiceDataSource], [oracleSIDDataSourceItem, oracleServiceDataSourceItem], true));
};

Step 2 - Create the data source provider. In this example, we are providing connection information to connect to our Oracle database that was defined on the client. To achieve this, we determine the type of the data source/item we are working with, and set the available properties on the object.

public class DataSourceProvider : IRVDataSourceProvider
{
public Task<RVDataSourceItem> ChangeDataSourceItemAsync(IRVUserContext userContext, string dashboardId,
RVDataSourceItem dataSourceItem)
{
if (dataSourceItem is RVOracleDataSourceItem oracleDataSourceItem)
{
//update underlying data source
ChangeDataSourceAsync(userContext, oracleDataSourceItem.DataSource);

//only change the table if we have selected our custom data source item
if (oracleDataSourceItem.Id == "MyOracleSIDDataSourceItem")
{
oracleDataSourceItem.Table = "your-table";
}

if (oracleDataSourceItem.Id == "MyOracleServiceDataSourceItem")
{
oracleDataSourceItem.Table = "your-table";
}
}

return Task.FromResult(dataSourceItem);
}

public Task<RVDashboardDataSource> ChangeDataSourceAsync(IRVUserContext userContext,
RVDashboardDataSource dataSource)
{
//using SID
if (dataSource is RVOracleSIDDataSource oracleSidDataSource)
{
oracleSidDataSource.Host = "your-host";
oracleSidDataSource.Database = "your-database";
oracleSidDataSource.SID = "your-service-sid";
}

//using service name
if (dataSource is RVOracleServiceDataSource oracleServiceDataSource)
{
oracleServiceDataSource.Host = "your-host";
oracleServiceDataSource.Database = "your-database";
oracleServiceDataSource.Service = "your-service-name";
}

return Task.FromResult(dataSource);
}
}
Get the Code

The source code to this sample can be found on GitHub