예제 #1
0
  public void analyseImpact(
      List<DatabaseImpact> impact,
      TransMeta transMeta,
      StepMeta stepMeta,
      RowMetaInterface prev,
      String[] input,
      String[] output,
      RowMetaInterface info,
      Repository repository,
      IMetaStore metaStore)
      throws KettleStepException {
    if (prev != null) {
      // Lookup: we do a lookup on the natural keys
      for (int i = 0; i < keyLookup.length; i++) {
        ValueMetaInterface v = prev.searchValueMeta(keyStream[i]);

        DatabaseImpact ii =
            new DatabaseImpact(
                DatabaseImpact.TYPE_IMPACT_READ,
                transMeta.getName(),
                stepMeta.getName(),
                databaseMeta.getDatabaseName(),
                tableName,
                keyLookup[i],
                keyStream[i],
                v != null ? v.getOrigin() : "?",
                "",
                "Type = " + v.toStringMeta());
        impact.add(ii);
      }

      // Insert update fields : read/write
      for (int i = 0; i < updateLookup.length; i++) {
        ValueMetaInterface v = prev.searchValueMeta(updateStream[i]);

        DatabaseImpact ii =
            new DatabaseImpact(
                DatabaseImpact.TYPE_IMPACT_READ_WRITE,
                transMeta.getName(),
                stepMeta.getName(),
                databaseMeta.getDatabaseName(),
                tableName,
                updateLookup[i],
                updateStream[i],
                v != null ? v.getOrigin() : "?",
                "",
                "Type = " + v.toStringMeta());
        impact.add(ii);
      }
    }
  }
  public void analyseImpact(
      List<DatabaseImpact> impact,
      TransMeta transMeta,
      StepMeta stepMeta,
      RowMetaInterface prev,
      String input[],
      String output[],
      RowMetaInterface info)
      throws KettleStepException {
    if (prev != null) {
      /* DEBUG CHECK THIS */
      // Insert dateMask fields : read/write
      for (int i = 0; i < fieldTable.length; i++) {
        ValueMetaInterface v = prev.searchValueMeta(fieldStream[i]);

        DatabaseImpact ii =
            new DatabaseImpact(
                DatabaseImpact.TYPE_IMPACT_READ_WRITE,
                transMeta.getName(),
                stepMeta.getName(),
                databaseMeta.getDatabaseName(),
                transMeta.environmentSubstitute(tableName),
                fieldTable[i],
                fieldStream[i],
                v != null ? v.getOrigin() : "?",
                "",
                "Type = " + v.toStringMeta()); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        impact.add(ii);
      }
    }
  }
예제 #3
0
  public void analyseImpact(
      List<DatabaseImpact> impact,
      TransMeta transMeta,
      StepMeta stepMeta,
      RowMetaInterface prev,
      String[] input,
      String[] output,
      RowMetaInterface info)
      throws KettleStepException {
    if (prev != null) {
      // Lookup: we do a lookup on the natural keys
      for (int i = 0; i < keyLookup.length; i++) {
        ValueMetaInterface v = prev.searchValueMeta(keyStream[i]);

        DatabaseImpact ii =
            new DatabaseImpact(
                DatabaseImpact.TYPE_IMPACT_DELETE,
                transMeta.getName(),
                stepMeta.getName(),
                databaseMeta.getDatabaseName(),
                tableName,
                keyLookup[i],
                keyStream[i],
                v != null ? v.getOrigin() : "?",
                "",
                "Type = " + v.toStringMeta()); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        impact.add(ii);
      }
    }
  }
  private boolean addFields() {
    // int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    if (wlFields == null) {
      wlFields = new Label(shell, SWT.LEFT);
      wlFields.setText(message);
      props.setLook(wlFields);
      fdlFields = new FormData();
      fdlFields.left = new FormAttachment(0, 0);
      fdlFields.right = new FormAttachment(100, 0);
      fdlFields.top = new FormAttachment(0, margin);
      wlFields.setLayoutData(fdlFields);
    } else {
      wFields.dispose();
    }

    if (dynamic && rowMeta == null) {
      rowMeta = new RowMeta();
      rowMeta.addValueMeta(new ValueMeta("<waiting for rows>", ValueMetaInterface.TYPE_STRING));
      waitingForRows = true;
    }
    if (!dynamic) {
      // Mmm, if we don't get any rows in the buffer: show a dialog box.
      if (buffer == null || buffer.size() == 0) {
        ShowMessageDialog dialog =
            new ShowMessageDialog(
                shell,
                SWT.OK | SWT.ICON_WARNING,
                BaseMessages.getString(PKG, "PreviewRowsDialog.NoRows.Text"),
                BaseMessages.getString(PKG, "PreviewRowsDialog.NoRows.Message"));
        dialog.open();
        shell.dispose();
        return true;
      }
    }

    // ColumnInfo[] colinf = new ColumnInfo[rowMeta==null ? 0 : rowMeta.size()];
    ColumnInfo[] colinf = new ColumnInfo[rowMeta.size()];
    for (int i = 0; i < rowMeta.size(); i++) {
      ValueMetaInterface v = rowMeta.getValueMeta(i);
      colinf[i] = new ColumnInfo(v.getName(), ColumnInfo.COLUMN_TYPE_TEXT, v.isNumeric());
      colinf[i].setToolTip(v.toStringMeta());
      colinf[i].setValueMeta(v);
    }

    wFields =
        new TableView(
            variables, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, 0, null, props);

    fdFields = new FormData();
    fdFields.left = new FormAttachment(0, 0);
    fdFields.top = new FormAttachment(wlFields, margin);
    fdFields.right = new FormAttachment(100, 0);
    fdFields.bottom = new FormAttachment(100, -50);
    wFields.setLayoutData(fdFields);

    if (dynamic) {
      shell.layout(true, true);
    }

    return false;
  }
예제 #5
0
  public void check(
      List<CheckResultInterface> remarks,
      TransMeta transMeta,
      StepMeta stepMeta,
      RowMetaInterface prev,
      String[] input,
      String[] output,
      RowMetaInterface info) {

    CheckResult cr;
    String message = ""; // $NON-NLS-1$

    if (fieldName.length > 0) {
      boolean error_found = false;
      // See if all fields are available in the input stream...
      message =
          BaseMessages.getString(PKG, "AggregateRowsMeta.CheckResult.FieldsNotFound.DialogMessage")
              + Const.CR; // $NON-NLS-1$
      for (int i = 0; i < fieldName.length; i++) {
        if (prev.indexOfValue(fieldName[i]) < 0) {
          message += "  " + fieldName[i] + Const.CR; // $NON-NLS-1$
          error_found = true;
        }
      }
      if (error_found) {
        cr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, message, stepMeta);
      } else {
        message =
            BaseMessages.getString(
                PKG, "AggregateRowsMeta.CheckResult.AllFieldsOK.DialogMessage"); // $NON-NLS-1$
        cr = new CheckResult(CheckResult.TYPE_RESULT_OK, message, stepMeta);
      }
      remarks.add(cr);

      // See which fields are dropped: comment on it!
      message =
          BaseMessages.getString(PKG, "AggregateRowsMeta.CheckResult.IgnoredFields.DialogMessage")
              + Const.CR; // $NON-NLS-1$
      error_found = false;

      for (int i = 0; i < prev.size(); i++) {
        ValueMetaInterface v = prev.getValueMeta(i);
        boolean value_found = false;
        for (int j = 0; j < fieldName.length && !value_found; j++) {
          if (v.getName().equalsIgnoreCase(fieldName[j])) {
            value_found = true;
          }
        }
        if (!value_found) {
          message +=
              "  "
                  + v.getName()
                  + " ("
                  + v.toStringMeta()
                  + ")"
                  + Const.CR; // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
          error_found = true;
        }
      }
      if (error_found) {
        cr = new CheckResult(CheckResult.TYPE_RESULT_COMMENT, message, stepMeta);
      } else {
        message =
            BaseMessages.getString(
                PKG, "AggregateRowsMeta.CheckResult.AllFieldsUsed.DialogMessage"); // $NON-NLS-1$
        cr = new CheckResult(CheckResult.TYPE_RESULT_OK, message, stepMeta);
      }
      remarks.add(cr);
    } else {
      message =
          BaseMessages.getString(
              PKG, "AggregateRowsMeta.CheckResult.NothingSpecified.DialogMessage"); // $NON-NLS-1$
      cr = new CheckResult(CheckResult.TYPE_RESULT_WARNING, message, stepMeta);
      remarks.add(cr);
    }

    if (input.length > 0) {
      cr =
          new CheckResult(
              CheckResult.TYPE_RESULT_OK,
              BaseMessages.getString(
                  PKG, "AggregateRowsMeta.CheckResult.StepReceiveInfo.DialogMessage"),
              stepMeta); //$NON-NLS-1$
      remarks.add(cr);
    } else {
      cr =
          new CheckResult(
              CheckResult.TYPE_RESULT_ERROR,
              BaseMessages.getString(
                  PKG, "AggregateRowsMeta.CheckResult.NoInputReceived.DialogMessage"),
              stepMeta); //$NON-NLS-1$
      remarks.add(cr);
    }
  }