Oracle Business Intelligence Beans Sample

Using Rules to Format Crosstabs

Overview

The Using Rules to Format Crosstabs sample application explores the use of rules to specify custom formatting for a Crosstab. BIRules can setup a connection to Oracle9i OLAP (the source of the business data for the application) and to the BI Beans Catalog (where object definitions, like crosstabs and graphs, are saved).

The BIRules class extends BIFrame. BIRules provides a menu with access to a simple connection dialog which prompts a user for security credentials. It then makes the two connections described above. After the connection is established a new crosstab can be created using the "New Crosstab" file menu option or toolbar button. After a new Crosstab is created, the rules menu options and toolbar buttons are enabled. When the Crosstab is closed, these options are disabled.

The rules menu options and toolbar buttons can each be toggled on and off, so that the underlying rules can be added and removed from the Crosstab. The rules provided in the sample enable a user to:

  1. format values in the Sales measure as currency

  2. format a single databody cell with a border and font style

  3. format a metadata member with particular colors and font style

  4. format databody cells belonging to divisions in the Product layer with bold and italic font styles

  5. stoplight format Sales values greater than ten million in green

  6. stoplight format Sales values less than or equal to ten million in yellow

  7. stoplight format Sales values less than or equal to two million in red

These examples demonstrate:

  1. how to create rules based on QDRs, values, and combinations of multiple criteria

  2. how to create number formatting rules for the databody

  3. how to create style rules for the databody and the headers

  4. the relationship between the order of rules in a manager and rule precedence

Setup Requirements

If you have not already done so, you must perform several installation and configuration tasks, then open the workspace javaclient\javaclient.jws under the samples directory within JDeveloper. All the necessary files for this sample can be found in the using_format_rules.jpr project under the javaclient.jws workspace.

Code Highlights

The bulk of the code to manipulate the Crosstab's rules can be found in the following methods. These are the methods that are called when the user adds or removes a rule using the rules menu or toolbar buttons.

  protected void applyCurrencyFormatting(boolean bApply);
  protected void applySingleCellFormatting(boolean bApply);
  protected void applyHeaderFormatting(boolean bApply);
  protected void applyDivisionFormatting(boolean bApply);
  protected void applyGreenStoplightFormatting(boolean bApply);
  protected void applyYellowStoplightFormatting(boolean bApply);
  protected void applyRedStoplightFormatting(boolean bApply);
  protected void applyStoplightFormatting(boolean bApply, int ruleID, ViewStyle viewStyle, NumberValueDiscriminator nvDisc);

In addition to the above methods, there are a few helper methods that the above methods call. These helper methods facilitate maintaining order among Rules within RuleBundles and among RuleBundles within Vectors.

  protected void setDatabodyStyleRuleBundle(int id, RuleBundle bundle, Vector bundles);
  protected RuleBundle getDatabodyStyleRuleBundle(String name, Vector bundles);
  protected void removeDatabodyStyleRuleBundle(int id, String name, Vector bundles);
  protected void addDatabodyStyleRule(int ruleID, Rule rule, int ruleBundleID, RuleBundle bundle);
  protected boolean removeDatabodyStyleRule(int ruleID, int ruleBundleID, RuleBundle bundle);

How To Run

To run the BIRules sample within JDeveloper, simply right-click on the file BIRules.java and choose Run BIRules.java. From the File Menu in the application, choose Connect and enter the username and password of the user that owns the BI Beans Catalog (e.g. BIBCAT).

oracle logo  
Copyright © 2002, 2003 Oracle. All Rights Reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.