Creating a Custom Data Source for a Presentation Bean

The diagram in this topic provides the following information about the interactions between a presentation bean (that is, a crosstab, table, or graph from BI Beans) and its data source:

Understanding this information is essential in order to build a custom data source that accesses the presentation beans.

The following steps are shown in the diagram to describe how a presentation bean should interact with its data source in an application:

  1. Create a DataSource instance -- From your application, create an instance of the DataSource interface. The exact code depends on the implementing class. In BI Beans, the code can appear as follows:

    ds = new Query();

  2. Invoke setDataSource  -- From your application, invoke the setDataSource method of the presentation bean to identify the data source that the bean should use.

  3. createXXXDataDirector is invoked -- In response to the call of the setDataSource method, the presentation bean invokes either the createCubeDataDirector method or the createRelationalDataDirector method depending on whether it wants to manipulate the data source in a cube (that is, multidimensional) manner or in a relational manner.

  4. addDataDirectorListener is invoked -- After a DataDirector object is returned from the createXXXDataDirector call, the presentation bean calls the addDataDirectorListener method of the DataDirector to register a listener for data changes in the data source.

  5. Prepare for data access -- Before a presentation bean can render data, it must receive an instance of an object that implements the DataAccess interface. To accomplish this, you write code in the data source to call the viewDataAvailable method of the DataDirectorListener and pass the DataAvailableEvent as the only parameter of this method. The DataAvailableEvent is an object that contains a reference to an instance of a DataAccess object.

  6. Retrieve data parameters -- After a BI presentation bean receives an instance of an object that implements the DataAccess interface, it determines the overall size of the data before taking any other action. To accomplish this, the presentation bean calls the getEdgeExtent method for each edge of the data cursor. This method returns the maximum number of columns, rows, or pages that are contained in the cursor depending on the parameter (COLUMN_EDGE, ROW_EDGE, or PAGE_EDGE) that is used in the getEdgeExtent method.

  7. Get the value of a specific cell -- The presentation bean calls the getValue method of the DataAccess object to retrieve a data value for a cell. A cell is defined by the intersection of a specified row and column on the current page.

  8. Get the value of a specified position in the data cursor -- As needed, the presentation bean calls the getValueQDR method of the DataAccess object to retrieve a QDR object that matches a specified position in the data cursor. This is a specialized form of data retrieval that works in conjunction with rules and associates row and column locations to OLAP data locations in a cube.

  9. Invoking data manipulation methods -- A presentation bean invokes data manipulation methods of the DataDirector in response to specific requests that the presentation bean receives.

  10. Notify the presentation bean when data changes -- Whenever data changes occur, then the presentation bean must receive an instance of an object that implements the DataAccess interface before the revised data can be displayed. To accomplish this, you write code in the data source to call the viewDataChanged method of the DataDirectorListener and pass the DataChangedEvent as the only parameter of this method. The DataChangedEvent is an object that contains a reference to an instance of a DataAccess object.

A visual representation of these steps is contained in the following diagram.

Visual display: relationship of presentation & data source