Adding a CalcBuilder to an Application

In order to use the CalcBuilder, you must add it to an application and run the application. During design, you can run an application to create calculations that you save in the BI Beans Catalog. At runtime, you can allow users to create a new calculation or to edit an existing one.

To add a CalcBuilder to an application:

  1. Prepare an application for a CalcBuilder by creating the required objects for the communication and management of data.

  2. Create a CalcBuilder object and specify its parent component.

  3. Set the MetadataManager property of the CalcBuilder object to specify the object that will manage its connections to data stores and allow retrieval of metadata.

  4. Set the QueryContext property of the CalcBuilder object, which allows the CalcBuilder to evaluate queries to retrieve data such as dimension members.

  5. If you want to set up the CalcBuilder to edit a previously created calculation, then specify tabbed mode for the Mode property and invoke the setBuilderContent method to specify the CalcStep object that defines the previously created calculation. Otherwise, the CalcBuilder creates a new CalcStep object based on the type of calculation that a user chooses.

  6. If you want to persist a calculation through the BI Beans Catalog, then use the CalcBuilderStepStorage object instead of the CalcBuilder object.

    See the "Creating Calculations" sample in the BICalc.java file for additional information on how to create, save, and edit calculations.

Example: Creating and running a CalcBuilder

The code in this example assumes that the following variables exist:

The following code sets up a CalcBuilder in wizard mode, which is the default:


 /**    * Demonstrate the minimal code needed to run the CalcBuilder.    *    * @param componentParent The Component object that represents    * the parent of the CalcBuilder.    * @param metadataManager The MetadataManager object that is used to retrieve metadata.    * @param queryContext The QueryContext object that is used for evaluation.    *    * @throws CalcBuilderException if the CalcBuilder cannot be run.    */   public void runCalcBuilder (Component componentParent, MetadataManager     metadataManager, QueryContext queryContext) throws CalcBuilderException {     // Initialize the CalcBuilder     CalcBuilder calcBuilder = null;     // Check whether the parent is a frame     if (componentParent instanceof Frame) {       calcBuilder = new CalcBuilder ((Frame)componentParent);     }     // Check whether the parent is a dialog     else if (componentParent instanceof Dialog) {       calcBuilder = new CalcBuilder ((Dialog)componentParent);     }     else {       // Default to no parent       calcBuilder = new CalcBuilder ((Frame)null);     }     // Specify the MetadataManager that the CalcBuilder     // uses to retrieve metadata.     calcBuilder.setMetadataManager (metadataManager);     // Specify the QueryContext to use for evaluation     calcBuilder.setQueryContext (queryContext);     // Run the CalcBuilder     boolean bSuccess = calcBuilder.run();   }

Applying a Calculation to a Query
Defining and Referencing Calculations