Skip to main content

Creating and Using a Business Intelligence Data Controller

Creating and Using a Business Intelligence Data Controller

The data controller object enables you to interact with Business Intelligence data sources. The primary interaction is as follows:

  • In a suitable part of the page logic (such as when the page is loaded or when a button is pressed), create a Business Intelligence data controller and execute a query.

    When you create a data controller, you specify one or two callback functions to be run when data is available; finalCallback is required, but pendingCallback is optional.

  • When pending results are available, Business Intelligence calls the method specified by pendingCallback, if specified.

    This method, which you write, uses the results that are available in the data controller object. The method typically draws page contents.

  • When the query has completed, Business Intelligence calls the method specified by finalCallback.

    This method, which you write, uses the results that are available in the data controller object. The method typically draws page contents.

Any method that executes a query uses the system described here; see the subsections for details and examples. Other methods return data synchronously.

Creating a Business Intelligence Data Controller and Executing a Query

In a suitable part of the client code (such as within the page initialization logic), do the following:

  1. Create a configuration object that has the following properties:

    • connection — Specifies the name of a Business Intelligence data connector object; see the previous section.

    • widget — Specifies the id of the HTML element on the page that will use the data controller

    • type — Specifies the type of data source; use either 'MDX' or 'PIVOT'

    • initialMDX — Specifies an MDX SELECT query; use this if type is 'MDX'

    • pivotName — Specifies the logical name of a pivot table; use this if type is 'PIVOT'

    • showTotals — Specifies whether to display totals. Specify either true or false

  2. Create a data controller object with code like the following:

    var dc = new DeepSeeDataController(configuration,finalCallback,pendingCallback);
    

    Where configuration is the configuration object from the previous step, finalCallback is the name of a callback function on this page, and pendingCallback is the name of another callback function on this page. finalCallback is required, but pendingCallback is optional.

  3. Call the runQuery() method of the data controller. Or run some other method that executes a query, such as runDrillDown() or runListing().

For example:

function initializePage() {
  ...
  configuration.connection = new DeepSeeConnection(username,password,host,application,namespace);
  dc = new DeepSeeDataController(configuration,drawChart);
  dc.runQuery();
}

Using Data Returned by the Data Controller

The page must also implement the callback function or functions referred to in the previous step. These callbacks should update the page as needed, using data obtained from the data controller object.

In each case, the data controller object is passed to the function as the argument.

The following shows a partial example:

function drawChart(dataController) {

  var resultSet = dataController.getCurrentData();
  ...
  var chartDataPoint;
  var chartLabel;
  var chartData = [];

  for (var i = 1; i <= resultSet.getRowCount(); ++i) {
   for (var j = 1; j <= resultSet.getColumnCount(); ++j) {
     chartDataPoint = resultSet.getOrdinalValue(i,j);
     chartLabel = resultSet.getOrdinalLabel(2,i);
     chartData[chartData.length] = { "country":chartLabel[0],"revenue":chartDataPoint};
    }
  }
  ...
}

The getCurrentData() method of the data controller returns another object, the result set object. That object provides methods for examining the results of the query. The example here shows some of them.

FeedbackOpens in a new tab