Importing / Export Objects is a sample application that demonstrates how to
create multiple Catalog connections, and exchange objects between Catalogs.
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 import_export_objects.jpr
project under the javaclient.jws
workspace.
You must also perform the following tasks for this specific sample:
Change the following lines of code in the sample to specify your connection information accordingly
// information for the second connection
String _user = "BIBEANS"; //specify the catalog owner
String _pass = "BIBEANS"; // specify the catalog owner password
String _host = "bibbox1-sun"; //specify the hostname of the database
where the Catalog is installed
String _port = "5521"; // specify the port number of the database
String _sid = "bmrel"; // specify the SID of the database
The connect() method creates the primary catalog connection as well as a secondary catalog connection by specifying and creating the InitialPersistenceManager programatically as shown below
Hashtable persistenceEnvironment = new Hashtable();
persistenceEnvironment.put(PSRConstants.Login.USER_NAME, _user);
persistenceEnvironment.put(PSRConstants.Login.PASSWORD, _pass);
persistenceEnvironment.put(PSRConstants.Login.HOSTNAME, _host);
persistenceEnvironment.put(PSRConstants.Login.PORT, _port);
persistenceEnvironment.put(PSRConstants.Login.SID, _sid);
persistenceEnvironment.put(PSRConstants.Login.JDBC_DRIVERTYPE, _type);
persistenceEnvironment.put(javax.naming.Context.SECURITY_PRINCIPAL, _user);
persistenceEnvironment.put(PSRConstants.STORAGEMANAGER_DRIVER, "oracle.dss.persistence.storagemanager.bi.BIStorageManagerImpl");
persistenceEnvironment.put(PSRConstants.BISESSION, getBISession());
BIUser _biUser = new BIUser(_user);
persistenceEnvironment.put(BISecurityConstants.BIUSER, _biUser);
BISession _session = new BISession();
DefaultErrorHandler m_handler = new DefaultErrorHandler();
_session.addErrorHandler(m_handler);
_session.setBIUser(_biUser);
try
{
_session.connect();
persistenceEnvironment.put(PSRConstants.BISESSION, _session);
persistenceEnvironment.put(PSRConstants.SECURITY_DRIVER_MANAGER, new SecurityDriverManagerImpl(persistenceEnvironment,
null, m_handler, Locale.getDefault()));
}
catch (Exception e){e.printStackTrace();}
try{
//create initial context
m_persistenceManager = new InitialPersistenceManager(persistenceEnvironment);
}
catch (Exception ex) {
showExceptionDialog(this, ex);
}
The Open and Export to second Catalog menu item displays a list of the available
objects in the primary catalog so that a user can select an object to open in
the application and to be exported to the seconday catalog. The Open and Import
from second Catalog menu item displays a list of the available objects in the
secondary catalog so that a user can select an object to open in the application
and to be imported to the primary catalog. This sample takes advantage of the
importSubcontext
and exportSubcontext
methods on the
PersistenceManager
.
For example, in the mnuExport_ActionPerformed
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(strName, syntax);
v.add(name);
control.setTransferList(v);
getPersistenceManager().exportSubcontext("/"+strName+".xml",
control); // export object from the primary catalog to a temporary file
m_persistenceManager.importSubcontext("/"+strName+".xml",
control); // import object from the temporary file to the second catalog
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.
To run the BIImportExport example within JDeveloper, simply right click on the file BIImportExport.java and choose Run BIImportExport.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).
![]() |
|
---|---|
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. |