# Oracle Business Intelligence Beans Sample

## Exporting Objects

### Overview

Export Objects is a sample application that demonstrates how to export objects from one Catalog to another.

### Code Highlights

The `connect` method creates a second catalog connection by specifying and creating the `InitialPersistenceManager` programatically, as shown below.

`HHashtable persistenceEnvironment = new Hashtable();
persistenceEnvironment.put(PSRConstants.Login.USER_NAME, userName);
persistenceEnvironment.put(PSRConstants.Login.PASSWORD, password);
persistenceEnvironment.put(PSRConstants.Login.HOSTNAME, host);
persistenceEnvironment.put(PSRConstants.Login.PORT, port);
persistenceEnvironment.put(PSRConstants.Login.SID, sid);
persistenceEnvironment.put(PSRConstants.Login.JDBC_DRIVERTYPE, "thin");
persistenceEnvironment.put(javax.naming.Context.SECURITY_PRINCIPAL, userName);
persistenceEnvironment.put(PSRConstants.STORAGEMANAGER_DRIVER,
"oracle.dss.persistence.storagemanager.bi.BIStorageManagerImpl");
persistenceEnvironment.put(PSRConstants.BISESSION, m_frame.getBISession());
BIUser biUser = new BIUser(connectAs);
m_session = new BISession();
DefaultErrorHandler m_handler = new DefaultErrorHandler();
m_session.addErrorHandler(m_handler);
m_session.setBIUser(biUser);
try
{
m_session.connect();
persistenceEnvironment.put(PSRConstants.BISESSION, m_session);
//create initial context
m_persistenceManager = new InitialPersistenceManager(persistenceEnvironment);
}
catch (BISessionException bse) {
m_frame.showExceptionDialog(this, bse);
}
catch (Exception ex) {
m_frame.showExceptionDialog(this, ex);
}
`

The Open menu item displays a list of the available objects in the main Catalog so that a user can select an object to open in the application. Then, the Export menu item prompts the user for connection information to the Catalog where the object will be exported to, and exports the object to that Catalog. This sample takes advantage of the `importSubcontext` and `exportSubcontext` methods on the `PersistenceManager`.

For example, in the `exportPresentation` method, the following code copies an object from one catalog to the other:

`TransferControl control = new TransferControl();
Vector v = new Vector();
Properties syntax = new Properties();
syntax.put("jndi.syntax.direction", "left_to_right");
syntax.put("jndi.syntax.separator", "/");
Name name = new CompoundName(m_strName, syntax);
v.add(name);
control.setTransferList(v);
// export object from the primary catalog to a temporary file
m_frame.getPersistenceManager().exportSubcontext("/"+m_strName+".xml", control);
// import object from the temporary file to the export catalog
m_persistenceManager.importSubcontext("/"+m_strName+".xml", control);`

To use the `importSubcontext` and `exportSubcontext` methods, it is necessary to construct the list of objects to copy using a `TransferControl` object. The `TransferControl` object contains a vector of `Name` objects that are derived from the full paths to the objects to be copied. In this case, a temporary file is created under the / directory for the copy process between the catalogs.

Copyright © 2004 Oracle Corporation. All Rights Reserved.