示例#1
0
  public boolean runtimeInit() throws KettleStepException {
    try {
      data.setOutputRowMeta(getInputRowMeta().clone());
      meta.setKeepInputFields(false);
      meta.getFields(data.getOutputRowMeta(), getStepname(), null, null, this);

      data.setRuleFilePath(meta.getRuleFile());
      data.setRuleString(meta.getRuleDefinition());

      data.initializeRules();
      data.initializeInput(getInputRowMeta());

      return true;
    } catch (Exception e) {
      throw new KettleStepException(e);
    }
  }
示例#2
0
  public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
    try {
      meta = (RulesAccumulatorMeta) smi;
      data = (RulesAccumulatorData) sdi;

      Object[] r = getRow(); // get row, set busy!

      if (r == null) // no more input to be expected...
      {
        data.execute();

        Object[] outputRow;

        String[] expectedResults = meta.getExpectedResultList();

        for (Row resultRow : data.getResultRows()) {
          outputRow = new Object[expectedResults.length];
          for (String columnName : expectedResults) {
            outputRow[data.getOutputRowMeta().indexOfValue(columnName)] =
                resultRow.getColumn().get(columnName);
          }
          putRow(data.getOutputRowMeta(), outputRow);
        }

        data.shutdown();
        setOutputDone();
        return false;
      }

      if (first) {
        if (!runtimeInit()) {
          return false;
        }

        first = false;
      }

      // Store the row for processing
      data.loadRow(r);

      return true;
    } catch (Exception e) {
      throw new KettleException(e);
    }
  }