samples.javaclient.analyzer
Class AnalyzerConnection

java.lang.Object
  extended bysamples.javaclient.analyzer.AnalyzerConnection

public class AnalyzerConnection
extends java.lang.Object

Connection to the OLAP Catalog and to the BI Beans Catalog. This class performs all the tasks related to connecting to OLAP and the BI Beans Catalog, including auto-connecting from a configuration template, presenting a dialog to get connection information from the user, connecting to the catalogs, and saving connection information in the configuration file.

As part of the connection, this class makes the following assumptions:

This class uses several helper objects to access information in the configuration file: a BIConfigReader, a PersistenceConnection, an OLAPConnection, and a DADFile.

The main Analyzer class constructs an AnalyzerConnection in its Analyzer.jbInit() method. If the user is automatically connecting, then the Analyzer constructor calls the autoConnect() method of this class. If the user is not automatically connecting to the database, then the Analyzer constructor calls the showConnectDialog(javax.swing.JFrame) method of this class to display the dialog that collects connection information from the user.

This connection is also where other objects get the MetadataManager and the QueryManager for the application. For example, Analyzer.initializeUI() calls the getMetadataManager() method of the AnalyzerConnection, and then sets the MetadataManager on the different Explorers.


Field Summary
private static java.lang.String CANCEL
          Text for the Cancel button: "Cancel".
private static java.lang.String CATALOG_DETAILS
          Text for the catalog details panel: "Catalog Details:".
private static java.lang.String CATALOG_PASSWORD
          Text for the BI Beans Catalog password label in the catalog details panel: "Password:"
private static java.lang.String CATALOG_ROOT
          Text for the BI Beans Catalog root folder label in the catalog details panel: "Root Folder:".
private static java.lang.String CATALOG_TYPE
          Text for the catalog type drop-down label:"Catalog Type:".
private static java.lang.String CATALOG_USER
          Text for the BI Beans Catalog user name label in the catalog details panel: "User Name:"
private static java.lang.String CONNECT
          Text for the Connect button: "Connect".
private static java.lang.String DATABASE
          Text for the database Catalog option in the catalog type box: "Database".
private static java.lang.String FILE_SYSTEM
          Text for the file-based Catalog option in the catalog type box: "File System".
private static java.lang.String HOST
          Text for the host name label: "Host Name:".
(package private)  Analyzer m_analyzer
          The Analyzer application that this Connection connects to the database.
(package private)  javax.swing.JPanel m_catalogPanel
          Panel that the "I" button displays or hides.
(package private)  javax.swing.JPasswordField m_catalogPassword
          Field for the password for connecting to the BI Beans Catalog.
(package private)  javax.swing.JTextField m_catalogRootFolder
          Field for the root folder in a file-based BI Beans Catalog.
(package private)  javax.swing.JComboBox m_catalogType
          Drop-down for selecting a file-based or database BI Beans Catlog.
(package private)  javax.swing.JTextField m_catalogUserName
          Field for the user name for connecting to the BI Beans Catalog.
(package private)  java.lang.String m_configFile
          The configuration file to read.
(package private)  boolean m_connected
          Whether the application is connected to the database.
(package private)  java.lang.String m_defaultCatalogFile
          Default name of the DAD file: "analyzerCatalog.dad".
(package private)  java.lang.String m_defaultConfigFile
          Default name of the configuration file:"AnalyzerConfig.xml".
(package private)  javax.swing.JDialog m_dialog
          The Connection dialog.
(package private)  javax.swing.JLabel m_directoryLabel
          Label for the Root folder name in a file-based BI Beans Catalog.
private  java.lang.String m_homeDirectory
          The directory where the user's start-up configuration file is found
(package private)  javax.swing.JTextField m_host
          Field for the host name.
(package private)  oracle.dss.metadataManager.client.MetadataManager m_metadataManager
          The MetadataManager for the application.
(package private)  javax.swing.JToggleButton m_moreButton
          "I" button for displaying more or less information.
(package private)  OLAPConnection m_olap
          The OLAP Connection for the application.
(package private)  javax.swing.JPasswordField m_OLAPPassword
          Field for the password.
(package private)  javax.swing.JTextField m_OLAPUserName
          Field for the user name.
(package private)  javax.swing.JLabel m_passwordLabel
          Label for the Catalog User password in m_catalogPanel.
(package private)  javax.swing.JTextField m_port
          Field for the port name.
(package private)  oracle.dss.dataSource.client.QueryManager m_queryManager
          The QueryManager for the application.
(package private)  BIConfigReader m_reader
          The configuration file reader.
(package private)  oracle.dss.appmodule.client.BISession m_session
          The BISession for the application.
(package private)  javax.swing.JTextField m_sid
          Field for the SID.
private static java.lang.String m_title
          Text for the dialog box title: "Database Connection Information".
(package private)  boolean m_useDatabaseCatalog
          Whether the BI Beans Catalog is database (true) or file-based (false).
(package private)  javax.swing.JLabel m_userLabel
          Label for the Catalog UserName in m_catalogPanel.
private static java.lang.String OLAP_PASSWORD
          Text for the password label: "Password:".
private static java.lang.String OLAP_USER
          Text for the user name label: "User Name:"
private static java.lang.String PORT
          Text for the port label: "Port:".
private static java.lang.String SID
          Text for the SID label: "SID:".
 
Constructor Summary
AnalyzerConnection(Analyzer analyzer)
          Constructor.
 
Method Summary
 boolean autoConnect()
          Auto-connects to the database.
protected  void connect()
          Connects to the OLAP service and to the BI Beans Catalog, using connection information from the BI Configuration file and from the BIConnectionDialog.
protected  void disconnect()
          Disconnects the application from the MetadataManager and its associated connections.
 void disposeConnectDialog()
          Disposes of the connect dialog.
 oracle.dss.appmodule.client.BISession getBISession()
          Gets the BISession for this connection.
private  oracle.dss.connection.client.Connection getCatalogConnection()
          Creates and returns a Connection to the BI Beans Catalog in the database.
private  oracle.dss.connection.client.Connection getCatalogConnection(oracle.dss.connection.client.Connection OLAPConnection)
          Creates and returns a Connection to the BI Beans Catalog.
private  oracle.dss.connection.client.Connection getLocalCatalogConnection()
          Creates and returns a Connection to the BI Beans Catalog.
 oracle.dss.metadataManager.client.MetadataManager getMetadataManager()
          Returns the MetadataManager that the application uses.
private  oracle.dss.connection.client.Connection getOLAPConnection()
          Creates and returns a Connection to the OLAP Catalog.
protected  oracle.dss.dataSource.client.QueryManager getQueryManager()
          Returns the QueryManager that the application uses.
 oracle.dss.metadataManager.common.MDRoot getRootFolder()
          Gets the root folder name for the application.
protected  boolean isConnected()
          Indicates whether the application is connected to the database.
private  boolean recoverUser()
          Attempts to recover from an invalid application user.
private  void saveConnectionSettings()
          Saves the connection settings.
 void showConnectDialog(javax.swing.JFrame parentFrame)
          Displays the connection dialog box, which asks the user for connection information.
private  void showConnectionError(java.lang.Exception e)
          Displays error connection information.
 void showDisconnectDialog(javax.swing.JFrame parentFrame)
          Displays a confirmation dialog that asks if the user wants to disconnect.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_moreButton

javax.swing.JToggleButton m_moreButton
"I" button for displaying more or less information.


m_catalogPanel

javax.swing.JPanel m_catalogPanel
Panel that the "I" button displays or hides.


m_userLabel

javax.swing.JLabel m_userLabel
Label for the Catalog UserName in m_catalogPanel. Does not appear if the user connects to a file-based BI Beans Catalog.


m_passwordLabel

javax.swing.JLabel m_passwordLabel
Label for the Catalog User password in m_catalogPanel. Does not appear if the user connects to a file-based BI Beans Catalog.


m_directoryLabel

javax.swing.JLabel m_directoryLabel
Label for the Root folder name in a file-based BI Beans Catalog.


m_OLAPUserName

javax.swing.JTextField m_OLAPUserName
Field for the user name.


m_OLAPPassword

javax.swing.JPasswordField m_OLAPPassword
Field for the password.


m_host

javax.swing.JTextField m_host
Field for the host name.


m_port

javax.swing.JTextField m_port
Field for the port name.


m_sid

javax.swing.JTextField m_sid
Field for the SID.


m_catalogUserName

javax.swing.JTextField m_catalogUserName
Field for the user name for connecting to the BI Beans Catalog. Not used if the user connects to file-based BI Beans Catalog.


m_catalogPassword

javax.swing.JPasswordField m_catalogPassword
Field for the password for connecting to the BI Beans Catalog. Not used if the user connects to file-based BI Beans Catalog.


m_catalogType

javax.swing.JComboBox m_catalogType
Drop-down for selecting a file-based or database BI Beans Catlog.


m_catalogRootFolder

javax.swing.JTextField m_catalogRootFolder
Field for the root folder in a file-based BI Beans Catalog.


m_configFile

java.lang.String m_configFile
The configuration file to read.


m_defaultConfigFile

java.lang.String m_defaultConfigFile
Default name of the configuration file:"AnalyzerConfig.xml".


m_defaultCatalogFile

java.lang.String m_defaultCatalogFile
Default name of the DAD file: "analyzerCatalog.dad".


m_session

oracle.dss.appmodule.client.BISession m_session
The BISession for the application.


m_metadataManager

oracle.dss.metadataManager.client.MetadataManager m_metadataManager
The MetadataManager for the application.


m_queryManager

oracle.dss.dataSource.client.QueryManager m_queryManager
The QueryManager for the application.


m_useDatabaseCatalog

boolean m_useDatabaseCatalog
Whether the BI Beans Catalog is database (true) or file-based (false).


m_connected

boolean m_connected
Whether the application is connected to the database.


m_homeDirectory

private java.lang.String m_homeDirectory
The directory where the user's start-up configuration file is found


OLAP_USER

private static final java.lang.String OLAP_USER
Text for the user name label: "User Name:"

See Also:
Constant Field Values

OLAP_PASSWORD

private static final java.lang.String OLAP_PASSWORD
Text for the password label: "Password:".

See Also:
Constant Field Values

m_title

private static final java.lang.String m_title
Text for the dialog box title: "Database Connection Information".

See Also:
Constant Field Values

FILE_SYSTEM

private static final java.lang.String FILE_SYSTEM
Text for the file-based Catalog option in the catalog type box: "File System".

See Also:
Constant Field Values

DATABASE

private static final java.lang.String DATABASE
Text for the database Catalog option in the catalog type box: "Database".

See Also:
Constant Field Values

CATALOG_DETAILS

private static final java.lang.String CATALOG_DETAILS
Text for the catalog details panel: "Catalog Details:".

See Also:
Constant Field Values

CATALOG_USER

private static final java.lang.String CATALOG_USER
Text for the BI Beans Catalog user name label in the catalog details panel: "User Name:"

See Also:
Constant Field Values

CATALOG_PASSWORD

private static final java.lang.String CATALOG_PASSWORD
Text for the BI Beans Catalog password label in the catalog details panel: "Password:"

See Also:
Constant Field Values

CATALOG_ROOT

private static final java.lang.String CATALOG_ROOT
Text for the BI Beans Catalog root folder label in the catalog details panel: "Root Folder:".

See Also:
Constant Field Values

CATALOG_TYPE

private static final java.lang.String CATALOG_TYPE
Text for the catalog type drop-down label:"Catalog Type:".

See Also:
Constant Field Values

HOST

private static final java.lang.String HOST
Text for the host name label: "Host Name:".

See Also:
Constant Field Values

PORT

private static final java.lang.String PORT
Text for the port label: "Port:".

See Also:
Constant Field Values

SID

private static final java.lang.String SID
Text for the SID label: "SID:".

See Also:
Constant Field Values

CONNECT

private static final java.lang.String CONNECT
Text for the Connect button: "Connect".

See Also:
Constant Field Values

CANCEL

private static final java.lang.String CANCEL
Text for the Cancel button: "Cancel".

See Also:
Constant Field Values

m_dialog

javax.swing.JDialog m_dialog
The Connection dialog.


m_analyzer

Analyzer m_analyzer
The Analyzer application that this Connection connects to the database.


m_reader

BIConfigReader m_reader
The configuration file reader.


m_olap

OLAPConnection m_olap
The OLAP Connection for the application.

Constructor Detail

AnalyzerConnection

public AnalyzerConnection(Analyzer analyzer)
Constructor. The constructor reads the BIConfig file for the application (Analyzer.xml) if one exists. The Analyzer.jbInit method constructs an instance of this class.

Parameters:
analyzer - The Analyzer main application class.
Method Detail

autoConnect

public boolean autoConnect()
Auto-connects to the database. This uses the configuration details that are specified in the analyzerTemplate.xml file.

Returns:
true if the connection is successful, false if it is not.

showConnectDialog

public void showConnectDialog(javax.swing.JFrame parentFrame)
Displays the connection dialog box, which asks the user for connection information. This method uses the collected information to connect both to the OLAP Catalog and to the BI Beans Catalog.

Parameters:
parentFrame - The Analyzer main application class.

disposeConnectDialog

public void disposeConnectDialog()
Disposes of the connect dialog.


showDisconnectDialog

public void showDisconnectDialog(javax.swing.JFrame parentFrame)
Displays a confirmation dialog that asks if the user wants to disconnect.

Parameters:
parentFrame - The Analyzer main application class.

getBISession

public oracle.dss.appmodule.client.BISession getBISession()
Gets the BISession for this connection.

Returns:
The BISession for this connection.

getMetadataManager

public oracle.dss.metadataManager.client.MetadataManager getMetadataManager()
Returns the MetadataManager that the application uses. The connect method instantiates the MetadataManager that this method returns.

2 The Analyzer.initializeUI method calls this method to set the MetadataManager on the Explorers.

Returns:
The MetadataManager for the application.
See Also:
connect(), Analyzer.initializeUI(), AnalyzerUtilities#construct

getQueryManager

protected oracle.dss.dataSource.client.QueryManager getQueryManager()
Returns the QueryManager that the application uses. The Analyzer.newPresentation method calls this method to set the QueryManager on the NewPresentationWizard. The AnalyzerUtilities.construct method calls this method to provide the QueryManager to the presentation that it is loading.

Returns:
QueryManager used by the application
See Also:
Analyzer.newPresentation(), AnalyzerUtilities#construct

isConnected

protected boolean isConnected()
Indicates whether the application is connected to the database.

Returns:
true is connected to the database, false if it is not.

connect

protected void connect()
Connects to the OLAP service and to the BI Beans Catalog, using connection information from the BI Configuration file and from the BIConnectionDialog.


getOLAPConnection

private oracle.dss.connection.client.Connection getOLAPConnection()
                                                           throws oracle.dss.connection.common.ConnectionException
Creates and returns a Connection to the OLAP Catalog. This method sets user and connection information, which was collected in the dialog box or in the reading of the config file, on the connection object. Then it calls the connect method of the Connection.

Returns:
A connection to the OLAP Catalog.
Throws:
oracle.dss.connection.common.ConnectionException - If the connection fails.

getCatalogConnection

private oracle.dss.connection.client.Connection getCatalogConnection(oracle.dss.connection.client.Connection OLAPConnection)
Creates and returns a Connection to the BI Beans Catalog. This method will share the JDBC connection with the OLAP Connection

Parameters:
OLAPConnection - The Catalog will reuse the OLAP's JDBC connection
Returns:
A Connection to the BI Beans Catalog.

getCatalogConnection

private oracle.dss.connection.client.Connection getCatalogConnection()
Creates and returns a Connection to the BI Beans Catalog in the database. This method will create a separate JDBC Connection. This method sets user and connection information, which was collected in the dialog box or in the reading of the config file, on the connection object. Then it calls the connect method of the Connection.

Returns:
A Connection to the BI Beans Catalog.

getLocalCatalogConnection

private oracle.dss.connection.client.Connection getLocalCatalogConnection()
Creates and returns a Connection to the BI Beans Catalog. The Catalog here is a File-based Catalog. This method will share the JDBC connection with the OLAP Connection

Returns:
A Connection to the BI Beans Catalog.

showConnectionError

private void showConnectionError(java.lang.Exception e)
Displays error connection information. This method uses an AnalyzerUtilities object to display an error message.

Parameters:
e - The exception that contains error text.

recoverUser

private boolean recoverUser()
Attempts to recover from an invalid application user. This method is only called if the OLAP User was authenticated. The assumption is that if the user is successfully authenticated by the database, then the user should have rights to the catalog.

This method uses a JDBC connection to execute SQL statements in the database.

Returns:
true if the user is recovered, false if the user cannot be recovered.

saveConnectionSettings

private void saveConnectionSettings()
Saves the connection settings. This method saves settings in the user's home directory. That way, the user will not have to continually re-enter the fields when reconnecting.


disconnect

protected void disconnect()
Disconnects the application from the MetadataManager and its associated connections. Disconnects the current user session. Subclasses should override this method to add additional cleanup code.


getRootFolder

public oracle.dss.metadataManager.common.MDRoot getRootFolder()
                                                       throws java.lang.Throwable
Gets the root folder name for the application.

Returns:
Root folder in the BI Beans Catalog to which the application is connected.
Throws:
java.lang.Throwable - If an error occurs.