private Map<Byte, DbJVPrimitiveType> getJavaTypes() throws DbException {

    // if first call, build the map
    if (m_javaTypes == null) {
      m_javaTypes = new HashMap<Byte, DbJVPrimitiveType>();
      DbRelationN relN = m_project.getComponents();
      DbEnumeration enu = relN.elements(DbSMSBuiltInTypeNode.metaClass);
      while (enu.hasMoreElements()) {
        DbSMSBuiltInTypeNode typeNode = (DbSMSBuiltInTypeNode) enu.nextElement();
        DbRelationN relN2 = typeNode.getComponents();
        DbEnumeration enu2 = relN2.elements(DbSMSBuiltInTypePackage.metaClass);
        while (enu2.hasMoreElements()) {
          DbSMSBuiltInTypePackage pack = (DbSMSBuiltInTypePackage) enu2.nextElement();
          DbSMSTargetSystem ts = pack.getTargetSystem();
          if ("Java".equals(ts.getName())) {
            DbRelationN relN3 = pack.getComponents();
            DbEnumeration enu3 = relN3.elements(DbJVPrimitiveType.metaClass);
            while (enu3.hasMoreElements()) {
              DbJVPrimitiveType type = (DbJVPrimitiveType) enu3.nextElement();
              String name = type.getName();
              if ("boolean".equals(name)) {
                m_javaTypes.put(Constants.T_BOOLEAN, type);
              } else if ("byte".equals(name)) {
                m_javaTypes.put(Constants.T_BYTE, type);
              } else if ("short".equals(name)) {
                m_javaTypes.put(Constants.T_SHORT, type);
              } else if ("char".equals(name)) {
                m_javaTypes.put(Constants.T_CHAR, type);
              } else if ("int".equals(name)) {
                m_javaTypes.put(Constants.T_INT, type);
              } else if ("long".equals(name)) {
                m_javaTypes.put(Constants.T_LONG, type);
              } else if ("double".equals(name)) {
                m_javaTypes.put(Constants.T_DOUBLE, type);
              } else if ("float".equals(name)) {
                m_javaTypes.put(Constants.T_FLOAT, type);
              } // end if
            } // end while
            enu3.close();
          } // end if
          pack.getAlias();
        } // end while
        enu2.close();
      } // end while
      enu.close();
    } // end if

    return m_javaTypes;
  }
  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);
    }
  }