コード例 #1
0
  protected void sql() {
    LoadSatMeta metaH = new LoadSatMeta();
    getInfo(metaH);

    try {
      SQLStatement sql = metaH.getSQLStatements(transMeta, stepMeta, null, repository, metaStore);
      if (!sql.hasError()) {
        if (sql.hasSQL()) {
          SQLEditor sqledit =
              new SQLEditor(
                  transMeta,
                  shell,
                  SWT.NONE,
                  metaH.getDatabaseMeta(),
                  transMeta.getDbCache(),
                  sql.getSQL());
          sqledit.open();
        } else {
          MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
          mb.setMessage(BaseMessages.getString(PKG, "LoadMeta.NoSQL.DialogMessage"));
          mb.setText(BaseMessages.getString(PKG, "LoadMeta.NoSQL.DialogTitle"));
          mb.open();
        }
      } else {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        mb.setMessage(sql.getError());
        mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
        mb.open();
      }
    } catch (KettleException ke) {
      new ErrorDialog(
          shell,
          BaseMessages.getString(PKG, "LoadDialog.BuildSQLError.DialogTitle"),
          BaseMessages.getString(PKG, "LoadDialog.BuildSQLError.DialogMessage"),
          ke);
    }
  }
コード例 #2
0
  /*
   * Update the Meta object according to UI widgets
   */
  protected void getInfo(BaseLoadMeta inMeta) {
    super.getInfo(inMeta);

    int nrkeys = wKey.nrNonEmpty();
    inMeta.allocateKeyArray(nrkeys);

    logDebug("Found nb of Keys=", String.valueOf(nrkeys));

    // in case temporal not set, then null is used as flag
    ((LoadSatMeta) inMeta).setFromDateColumn(null);

    for (int i = 0; i < nrkeys; i++) {
      TableItem item = wKey.getNonEmpty(i);
      inMeta.getCols()[i] = item.getText(1);
      inMeta.getFields()[i] = item.getText(2);
      String t = item.getText(3);

      // Unknown category is default to Normal
      if (!(t.equals(LoadSatMeta.ATTRIBUTE_NORMAL))
          && !(t.equals(LoadSatMeta.ATTRIBUTE_FK))
          && !(t.equals(LoadSatMeta.ATTRIBUTE_TEMPORAL))
          && !(t.equals(LoadSatMeta.ATTRIBUTE_META))) {
        t = LoadSatMeta.ATTRIBUTE_NORMAL;
      }
      inMeta.getTypes()[i] = t;

      // first temporal found is the one we keep
      if (item.getText(3).equals(LoadSatMeta.ATTRIBUTE_TEMPORAL)) {
        ((LoadSatMeta) inMeta).setFromDateColumn(LoadSatMeta.ATTRIBUTE_TEMPORAL);
      }
    }

    ((LoadSatMeta) inMeta).setToDateColumn(wcbToDateCol.getText());
    ((LoadSatMeta) inMeta).setToDateMaxFlag(wToDateMax.getText());
    ((LoadSatMeta) inMeta).setIdempotent(wbIsIdempotentSat.getSelection());
  }