This sample demonstrates how to execute writeback to a variable in the Analytic Workspace.
The following section provides a walkthrough and explanation of the code highlights.
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, the validator program returns the String '0', otherwise it returns a text message specifing 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:
m_crosstab.setCellEditingAllowed(true);
The following code fragment is executed when the user chooses "Submit Changes" from the menu. The edited data cells will be passed to the writeback engine as a list of QDRoverride objects.
crosstab.getModel().getDataAccess().submitChanges();
The class WritebackListener 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 failed, 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.add(qdrOverride.getWritebackError());
if (qdrOverride.getWritebackStatus() ==
QDRoverride.VALIDATION_FAILED)
{
...
addToInvalidQDRList(qdrOverride);
}
Copyright © 2004 Oracle Corporation. All Rights Reserved. |