Oracle Business Intelligence Beans Sample

Using Graph With Relational or XML Data

Overview

This sample demonstrates how to display a BI Beans Graph in a UIX page and to populate it with data from a relational data source or from an XML data source.

Setup Requirements

The code creates a JDBC connection to connect to your installation of the Common Schema Analytic Workspace. To change the sample to point to your database, change the following parameters in file GraphUIXSample.java:

String HOST_NAME = "localhost";
String PORT_NUMBER = "1521";
String SID = "ora9205";
String USER_NAME = "cs_olap";
String PASSWORD = "cs_olap";

To change the sample to load the data from the local XML file, set the boolean parameter to false in the sample:

boolean loadDataFromJDBC = false;

Code Highlights

The following section provides a walkthrough and explanations of the code highlights.

For more information about setting the data on the Graph, please consult the BI Beans Help Topics in the following section:

The following code fragment loads the data from the JDBC SQL query.

Establish the JDBC connection to the database:

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
OracleConnection connection = (OracleConnection)DriverManager.getConnection(connStr, USER_NAME, PASSWORD);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(sqlQuery);

ArrayList data = new ArrayList();

Walk the ResultSet and prepare the data for the Graph:

while (resultSet.next()) {

For each element in the result set create a 3-element Object array:

Object[] rowItems = new Object[3];

First element is the column label in the grid:

rowItems[0] = "Promo" + resultSet.getString("SHAWPROMOTIONS_ET");

Second element is the row label in the grid:

rowItems[1] = "Channel" + resultSet.getString("SHAWCHANNELS_ET");

Third element is the data:

rowItems[2] = new Double(resultSet.getDouble("AMOUNT_SOLD"));

Add this array to the ArrayList:

data.add(rowItems);
}

Close the result set and the connection:

resultSet.close();
statement.close();
connection.close();

Set the data on the Graph:

graph.setTabularData(data);

The following code fragment sets the XML that contains local data on the Graph:

graph.readXML(GraphUIXSample.class.getResourceAsStream(filename), Dataview.RESET_NONE);

How To Run

In JDeveloper, expand the bibeans workspace and the uix project. Expand the Web Content folder, right-click on graphRelationalXMLData.uix, and select Run from the popup menu.


Copyright © 2004 Oracle Corporation.
All Rights Reserved.