Ejemplo n.º 1
0
  /**
   * {@inheritDoc}
   *
   * @see org.eclipse.jface.action.Action#run()
   */
  @Override
  public void run() {
    // Make sure default teiid instance is connected
    if (!checkForConnectedServer()) return;

    ITeiidServer teiidServer = getServerManager().getDefaultServer();

    for (IFile nextVDB : this.selectedVDBs) {
      boolean doDeploy = VdbRequiresSaveChecker.insureOpenVdbSaved(nextVDB);
      if (doDeploy) {
        boolean deploySuccess = deployVdb(teiidServer, nextVDB);

        String vdbName = nextVDB.getFullPath().removeFileExtension().lastSegment();
        try {
          // make sure deployment worked before going on to the next one
          if (!teiidServer.hasVdb(vdbName)) {
            deploySuccess = false;
            break;
          }
        } catch (Exception ex) {
          DqpPlugin.Util.log(ex);
          Shell shell = UiUtil.getWorkbenchShellOnlyIfUiThread();
          String title =
              UTIL.getString(
                  I18N_PREFIX + "problemDeployingVdbDataSource.title",
                  vdbName,
                  teiidServer); //$NON-NLS-1$
          String message =
              UTIL.getString(
                  I18N_PREFIX + "problemDeployingVdbDataSource.msg",
                  vdbName,
                  teiidServer); //$NON-NLS-1$
          ErrorDialog.openError(
              shell, title, null, new Status(IStatus.ERROR, PLUGIN_ID, message, ex));
        }

        if (deploySuccess) {
          try {
            CreateVdbDataSourceAction.doCreateDataSource(vdbName, teiidServer);
          } catch (Exception ex) {
            Shell shell = UiUtil.getWorkbenchShellOnlyIfUiThread();
            MessageDialog.openError(
                shell,
                UTIL.getString("CreateVdbDataSourceAction.errorCreatingDataSourceForVDB", vdbName),
                ex.getMessage()); // $NON-NLS-1$
            DqpUiConstants.UTIL.log(
                IStatus.ERROR,
                ex,
                UTIL.getString(
                    "CreateVdbDataSourceAction.errorCreatingDataSourceForVDB",
                    vdbName)); //$NON-NLS-1$
          }
        }
      }
    }
  }
Ejemplo n.º 2
0
  /** Ask the user to select the vdb and deploy it */
  public void queryUserAndRun() {
    // Make sure default teiid instance is connected
    if (!checkForConnectedServer()) return;

    ITeiidServer teiidServer = getServerManager().getDefaultServer();

    DeployVdbDialog dialog =
        new DeployVdbDialog(
            DqpUiPlugin.getDefault().getCurrentWorkbenchWindow().getShell(), designerProperties);

    dialog.open();

    if (dialog.getReturnCode() == Window.OK) {
      IFile vdb = dialog.getSelectedVdb();
      boolean doCreateDS = dialog.doCreateVdbDataSource();
      String jndiName = dialog.getVdbDataSourceJndiName();
      if (vdb != null) {
        boolean doDeploy = VdbRequiresSaveChecker.insureOpenVdbSaved(vdb);
        if (doDeploy) {
          deployVdb(teiidServer, vdb, true);
        }

        String vdbName = vdb.getFullPath().removeFileExtension().lastSegment();
        try {
          if (teiidServer.hasVdb(vdbName) && doCreateDS) {
            createVdbDataSource(vdb, jndiName, jndiName);
          }
        } catch (Exception ex) {
          DqpPlugin.Util.log(ex);
          Shell shell = UiUtil.getWorkbenchShellOnlyIfUiThread();
          String title =
              UTIL.getString(
                  I18N_PREFIX + "problemDeployingVdbDataSource.title",
                  vdbName,
                  teiidServer); //$NON-NLS-1$
          String message =
              UTIL.getString(
                  I18N_PREFIX + "problemDeployingVdbDataSource.msg",
                  vdbName,
                  teiidServer); //$NON-NLS-1$
          ErrorDialog.openError(
              shell, title, null, new Status(IStatus.ERROR, PLUGIN_ID, message, ex));
        }
      }
    }
  }