Oracle Business Intelligence Beans Sample

Writeback to Analytic Workspace in a JSP Application

Overview

This sample demonstrates how to execute writeback to a variable in an Analytic Workspace.

Code Highlights

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

The AWCommands JSP tag is used to attach the Analytic Workspace Utils on initialization of the JSP page:

<orabi:AWCommands id="BIWriteback_awComm1" executeWhen="onInit">aw attach utils </orabi:AWCommands >

The code below is used to retrieve the Query from the Crosstab and register an OLAP DML program as a validator. This program will be called by the writeback engine and validate each overridden QDR. The OLAP DML program name used by this sample is CS_OLAP.UTILS!WBVALIDATOR and is installed with the common schema. The validator program expects one argument, in the format 'QDR=value'. If the value is valid, then the validator program returns the String '0'. If the value is not valid, the validator returns a text message that specifies the reason for validation failure.

Query query = (Query)crosstab.getDataSource();
query.setWritebackValidator(VALIDATOR_ID);

Register the WritebackHelper class as a QueryListener to handle errors upon unsuccessful writeback.

query.addQueryListener(writebackHelper);

Enable editing of the Crosstab cells. Note that the rules are used to specify which cells should be editable in the ThinCrosstab. The rules for cell editing are created in the following method in the WritebackHelper class:

public void createCellEditingRules(ThinCrosstab crosstab)

The following code fragment is executed when the user presses the Submit Changes button. The edited data cells will be passed to the writeback engine as a list of QDRoverride objects.

crosstab.getModel().getDataAccess().submitChanges();

The class WritebackHelper extends the QueryAdapter and is used to listen to events related to writeback, and to create formatting rules for the Crosstab. The CellsSubmittedEvent is received after the writeback has been executed in the Analytic Workspace. The following code examines the CellsSubmittedEvent for the results of writeback:

public void cellsSubmitted(CellsSubmittedEvent e)
{
   if (e.isSubmitSuccess() == false)
   {

If the writeback process fails, then the following code is used to retrieve the error message set by the writeback engine and the validator program for each failed QDR:

ArrayList qdrCollection = (ArrayList)e.getQDROverrides();
if (qdrCollection != null)
{
   int iSize = qdrCollection.size();
   for (int i =0; i < iSize; i++)
   {
     QDRoverride qdrOverride = (QDRoverride)qdrCollection.get(i);

Check if the particular QDR failed the writeback operation. Retrieve the error message from the validation program and save the QDR so that the UI can display the cells that failed using red font:

     if (qdrOverride.getWritebackStatus() != QDRoverride.WB_OK)
     {
       m_errorMessages += (qdrOverride.getWritebackError());
       if (qdrOverride.getWritebackStatus() ==
           QDRoverride.VALIDATION_FAILED)
      {
           ...
           m_invalidQDRList.add(qdrOverride);
      }

How To Run

In JDeveloper, expand the bibeans workspace and the jsp project. Right-click on BIWriteback.jsp and select Run from the popup menu.


Copyright © 2004 Oracle Corporation.
All Rights Reserved.