Ejemplo n.º 1
0
 private void showResult(final long time, final boolean hasErrors) {
   UIUtils.showMessageBox(
       null,
       "Data transfer",
       "Data transfer completed "
           + (hasErrors ? "with errors " : "")
           + "("
           + RuntimeUtils.formatExecutionTime(time)
           + ")",
       hasErrors ? SWT.ICON_ERROR : SWT.ICON_INFORMATION);
 }
Ejemplo n.º 2
0
  @Override
  protected String[] resolveAll(final TemplateContext context) {
    final DBCExecutionContext executionContext =
        ((DBPContextProvider) context).getExecutionContext();
    if (executionContext == null) {
      return super.resolveAll(context);
    }

    TemplateVariable tableVariable = ((SQLContext) context).getTemplateVariable("table");
    final String tableName = tableVariable == null ? null : tableVariable.getDefaultValue();
    if (!CommonUtils.isEmpty(tableName)) {
      final List<DBSEntityAttribute> attributes = new ArrayList<>();
      DBRRunnableWithProgress runnable =
          new DBRRunnableWithProgress() {
            @Override
            public void run(DBRProgressMonitor monitor)
                throws InvocationTargetException, InterruptedException {
              try {
                List<DBSEntity> entities = new ArrayList<>();
                SQLEntityResolver.resolveTables(monitor, executionContext, context, entities);
                if (!CommonUtils.isEmpty(entities)) {
                  DBSEntity table = DBUtils.findObject(entities, tableName);
                  if (table != null) {
                    attributes.addAll(CommonUtils.safeCollection(table.getAttributes(monitor)));
                  }
                }
              } catch (DBException e) {
                throw new InvocationTargetException(e);
              }
            }
          };
      RuntimeUtils.runTask(runnable, "Resolve attributes", 1000);
      if (!CommonUtils.isEmpty(attributes)) {
        String[] result = new String[attributes.size()];
        for (int i = 0; i < attributes.size(); i++) {
          DBSEntityAttribute entity = attributes.get(i);
          result[i] = entity.getName();
        }
        return result;
      }
    }
    return super.resolveAll(context);
  }
Ejemplo n.º 3
0
  @Override
  public void fillProcessParameters(List<String> cmd, MySQLDatabaseExportInfo arg)
      throws IOException {
    File dumpBinary =
        RuntimeUtils.getHomeBinary(
            getClientHome(), MySQLConstants.BIN_FOLDER, "mysqldump"); // $NON-NLS-1$
    String dumpPath = dumpBinary.getAbsolutePath();
    cmd.add(dumpPath);
    switch (method) {
      case LOCK_ALL_TABLES:
        cmd.add("--lock-all-tables"); // $NON-NLS-1$
        break;
      case ONLINE:
        cmd.add("--single-transaction"); // $NON-NLS-1$
        break;
    }

    if (noCreateStatements) {
      cmd.add("--no-create-info"); // $NON-NLS-1$
    } else {
      if (CommonUtils.isEmpty(arg.getTables())) {
        cmd.add("--routines"); // $NON-NLS-1$
      }
    }
    if (addDropStatements) cmd.add("--add-drop-table"); // $NON-NLS-1$
    if (disableKeys) cmd.add("--disable-keys"); // $NON-NLS-1$
    if (extendedInserts) {
      cmd.add("--extended-insert"); // $NON-NLS-1$
    } else {
      cmd.add("--skip-extended-insert"); // $NON-NLS-1$
    }
    if (binariesInHex) {
      cmd.add("--hex-blob"); // $NON-NLS-1$
    }
    if (dumpEvents) cmd.add("--events"); // $NON-NLS-1$
    if (comments) cmd.add("--comments"); // $NON-NLS-1$
  }