# BI Beans Java Client Samples

| Sample | Description
--- | --- | ---
Query | Using QueryBuilder | Demonstrates how QueryBuilder functionality can be used in different contexts. This sample explores the QueryBuilder methods that enable simplified access to QueryBuilder functionality.
| Formatting Crosstabs | Explores the use of rules to specify custom formatting for a crosstab. This sample introduces different types of formatting, including the cell level formatting, currency format, header formats and data-driven stoplight formatting.
| Using Dimension List | Demonstrates how to use the Dimension List bean components to alter the dimension values used in a query and how to apply the query to a presentation.
| Creating Calculations | Shows how to use the CalcBuilder to define a new calculation and insert it into a crosstab. Also shows how to insert a predefined calculation type into a crosstab using popup menus.
| Linking Presentations | Demonstrates how to link queries and selections between views (for example, crosstab, table, and graph).
Presentation | Modifying Graphs | Demonstrates how to generate a graph using the QueryBuilder and Graph format panels.
| Custom Presentation Wizard | Demonstrates how to create a custom wizard for end users to define new, data-aware crosstabs and graphs.
| Printing Crosstabs | Shows how an application can incorporate the BI Beans Print, Page Setup, and Preview dialogs to print crosstabs.
Catalog | Using the BI Beans Catalog | Introduces a number of BI Beans Catalog features in an application, including the following: Creating directories and providing user access to them Using the Explorer to navigate the catalog Opening components that have been saved in the catalog Displaying the XML definitions of a saved BI Beans object
| Exporting Objects | Shows how to open and export an object from one BI Beans Catalog to another
| Browsing Metadata | Demonstrates how a BI Beans application can retrieve metadata from a MetadataManager that is connected to Oracle 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).

## Code Highlights for the main application (BIFrame)

The main class of this application, BIFrame, is responsible for creating the default connection to OLAP and BI Beans Catalog.

The connect method in the sample shows how connections to the Oracle9i OLAP and the Oracle BI Beans Catalog are created. The following section provides a walk-through and explains significant code fragments:

Before setting up the connections, an application must first create a new user session. This is accomplished by creating a new BISession object. A BISession can take the name of a BI Configuration file as an argument. A BI Configuration file is an XML file that contains the definition of the connections.

`m_session = new BISession(m_configFile);`

In addition, an application must specify the name of the application user.

`m_session.setBIUser(new BIUser(userName));`

Note that this information could also be specified within the BI Configuration file.

After an application creates a session, it can retrieve the MetadataManager that is associated with the specified connections through the ManagerFactory (since the connection definitions are already defined in the BI Configuration file).

`m_metadataManager = (MetadataManager)m_session.getManagerFactory().lookupManager(ManagerFactory.METADATA_MANAGER, null, true);`

An application can also use the ManagerFactory to retrieve the QueryManager that is associated with the MetadataManager.

`m_queryManager = (QueryManager)m_session.getManagerFactory().lookupManager(ManagerFactory.QUERY_MANAGER, null, true);`

Finally, if a connection to the BI Beans Catalog is defined in the BI Configuration file, then an application can also retrieve the PersistenceManager through the ManagerFactory.

`m_persistenceManager = (PersistenceManager)m_session.getManagerFactory().lookupManager(ManagerFactory.PERSISTENCE_MANAGER, null, true);`

The disconnect method in the sample shows how to disconnect from Oracle9i OLAP and the BI Beans Catalog.

All that the application has to do is to disconnect the current user session by calling the disconnect method on the BISession object

`m_session.disconnect();`

The connections that are associated with the MetadataManager are automatically disconnected when the user session is disconnected.

Copyright © 2004 Oracle Corporation. All Rights Reserved.