protected final void doActionPerformed() { DbObject[] selObjs = ORActionFactory.getActiveObjects(); if (selObjs == null || selObjs.length > 1 || selObjs.length == 0) { throw new RuntimeException("Expecting selection of one database"); } boolean userHasCancelled = false; DbORDatabase database = null; try { selObjs[0].getDb().beginTrans(Db.READ_TRANS); DbORModel model = null; if (selObjs[0] instanceof DbORDatabase) { database = (DbORDatabase) selObjs[0]; } else { model = (selObjs[0] instanceof DbORModel) ? (DbORModel) selObjs[0] : (DbORModel) selObjs[0].getCompositeOfType(DbORModel.metaClass); if (model != null) { if (model instanceof DbORDataModel) { database = ((DbORDataModel) model).getDeploymentDatabase(); } else if (model instanceof DbORDomainModel) { database = ((DbORDomainModel) model).getDeploymentDatabase(); } else if (model instanceof DbOROperationLibrary) { database = ((DbOROperationLibrary) model).getDeploymentDatabase(); } // end if } // end if } // end if selObjs[0].getDb().commitTrans(); if ((model != null) && (database == null)) { String transName = MessageFormat.format( kCreation, new Object[] {DbORDataModel.fDeploymentDatabase.getGUIName()}); selObjs[0].getDb().beginWriteTrans(transName); int option = JOptionPane.showConfirmDialog( ApplicationContext.getDefaultMainFrame(), kNoActiveDatabase, ApplicationContext.getApplicationName(), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); if (option == 0) { DbObject composite = model.getProject(); DbSMSTargetSystem ts = model.getTargetSystem(); database = AnyORObject.createDatabase(composite, ts); if (model instanceof DbORDataModel) { DbORDataModel dm = (DbORDataModel) model; dm.setDeploymentDatabase(database); } else if (model instanceof DbOROperationLibrary) { DbOROperationLibrary ol = (DbOROperationLibrary) model; ol.setDeploymentDatabase(database); } else if (model instanceof DbORDomainModel) { DbORDomainModel dm = (DbORDomainModel) model; dm.setDeploymentDatabase(database); } // end if } else if (option == 1) { userHasCancelled = true; } // end if selObjs[0].getDb().commitTrans(); } // end if } catch (DbException e) { ExceptionHandler.processUncatchedException(ApplicationContext.getDefaultMainFrame(), e); } // end try if (userHasCancelled) { return; } DbSMSTargetSystem target = null; try { Db db = database.getDb(); db.beginTrans(Db.READ_TRANS); target = database.getTargetSystem(); DBMSDefaultForwardWizardModel model = new DBMSDefaultForwardWizardModel(target.getID().intValue()); model.setAbstractPackage(database); model.setDatabaseName(database.getName()); db.commitTrans(); Wizard wizard = new Wizard(model); wizard.setVisible(true); } catch (InstantiationException e) { Component parent = ApplicationContext.getDefaultMainFrame(); Db.abortAllTrans(); ExceptionHandler.showErrorMessage(parent, e.getMessage()); } catch (DbException e) { ExceptionHandler.processUncatchedException(ApplicationContext.getDefaultMainFrame(), e); } catch (RuntimeException e) { Component parent = ApplicationContext.getDefaultMainFrame(); String pattern = kPattern; String targetName = kUnknown; try { Db db = target.getDb(); db.beginReadTrans(); targetName = target.getName() + " " + target.getVersion(); db.commitTrans(); } catch (DbException ex) { // leave targetName's value to unknown } String msg = MessageFormat.format(pattern, new Object[] {targetName}); Db.abortAllTrans(); ExceptionHandler.showErrorMessage(parent, msg); } }
// // PRIVATE METHODS // private void propagateCommonItems() { g_options = getOptions(); m_changesmade = false; try { m_semObjs[0].getDb().beginWriteTrans(m_title); int nb = m_semObjs.length; for (int i = 0; i < nb; i++) { DbObject semObj = m_semObjs[i]; if (semObj instanceof DbORCommonItemModel) { DbORCommonItemModel model = (DbORCommonItemModel) semObj; propagateCommonItemValues(model, g_options); } else if (semObj instanceof DbORCommonItem) { DbORCommonItem item = (DbORCommonItem) semObj; propagateCommonItemValues(item, g_options); } // end if else if (semObj instanceof DbORDataModel) { DbObject tableOrView = null; DbEnumeration orTableEnum = semObj.getComponents().elements(DbORAbsTable.metaClass); while (orTableEnum.hasMoreElements()) { tableOrView = orTableEnum.nextElement(); DbEnumeration orColumnEnum = tableOrView.getComponents().elements(DbORColumn.metaClass); DbORCommonItem item = null; while (orColumnEnum.hasMoreElements()) { DbORColumn parm = (DbORColumn) orColumnEnum.nextElement(); item = (DbORCommonItem) parm.get(DbORColumn.fCommonItem); if (item != null) propagateCommonItemValues(item, parm, false, g_options); } orColumnEnum.close(); } orTableEnum.close(); } else if (semObj instanceof DbORColumn) { DbORCommonItem item = (DbORCommonItem) semObj.get(DbORColumn.fCommonItem); if (item != null) propagateCommonItemValues(item, semObj, false, g_options); } else if (semObj instanceof DbORAbsTable) { DbEnumeration orColumnEnum = semObj.getComponents().elements(DbORColumn.metaClass); DbORCommonItem item = null; while (orColumnEnum.hasMoreElements()) { DbORColumn parm = (DbORColumn) orColumnEnum.nextElement(); item = (DbORCommonItem) parm.get(DbORColumn.fCommonItem); if (item != null) propagateCommonItemValues(item, parm, false, g_options); } orColumnEnum.close(); } else if (semObj instanceof DbOOClassModel) { DbObject tableOrView = null; DbEnumeration orTableEnum = semObj.getComponents().elements(DbOOClass.metaClass); while (orTableEnum.hasMoreElements()) { tableOrView = orTableEnum.nextElement(); DbEnumeration orColumnEnum = tableOrView.getComponents().elements(DbJVDataMember.metaClass); DbORCommonItem item = null; while (orColumnEnum.hasMoreElements()) { DbJVDataMember parm = (DbJVDataMember) orColumnEnum.nextElement(); item = (DbORCommonItem) parm.get(DbJVDataMember.fCommonItem); if (item != null) propagateCommonItemValues(item, parm, true, g_options); } orColumnEnum.close(); } orTableEnum.close(); } else if (semObj instanceof DbOOClass) { DbEnumeration orColumnEnum = semObj.getComponents().elements(DbJVDataMember.metaClass); DbORCommonItem item = null; while (orColumnEnum.hasMoreElements()) { DbJVDataMember parm = (DbJVDataMember) orColumnEnum.nextElement(); item = (DbORCommonItem) parm.get(DbJVDataMember.fCommonItem); if (item != null) propagateCommonItemValues(item, parm, true, g_options); } orColumnEnum.close(); } else if (semObj instanceof DbJVDataMember) { DbORCommonItem item = (DbORCommonItem) semObj.get(DbJVDataMember.fCommonItem); if (item != null) propagateCommonItemValues(item, semObj, true, g_options); } } // end for m_semObjs[0].getDb().commitTrans(); if (m_changesmade == false) JOptionPane.showMessageDialog( this, LocaleMgr.screen.getString("NoCommonItemToPropagate"), ApplicationContext.getApplicationName(), JOptionPane.INFORMATION_MESSAGE); } catch (Exception e) { org.modelsphere.jack.util.ExceptionHandler.processUncatchedException( ApplicationContext.getDefaultMainFrame(), e); } } // end propagateCommonItems()