コード例 #1
0
ファイル: XMLOutput.java プロジェクト: hoverzheng/kettle
  public boolean init(StepMetaInterface smi, StepDataInterface sdi) {
    meta = (XMLOutputMeta) smi;
    data = (XMLOutputData) sdi;

    if (super.init(smi, sdi)) {
      data.splitnr = 0;
      if (!meta.isDoNotOpenNewFileInit()) {
        if (openNewFile()) {
          data.OpenedNewFile = true;
          return true;
        } else {
          logError("Couldn't open file " + meta.getFileName()); // $NON-NLS-1$
          setErrors(1L);
          stopAll();
        }
      } else return true;
    }
    return false;
  }
コード例 #2
0
ファイル: XMLOutput.java プロジェクト: hoverzheng/kettle
  public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
    meta = (XMLOutputMeta) smi;
    data = (XMLOutputData) sdi;

    Object[] r;
    boolean result = true;

    r = getRow(); // This also waits for a row to be finished.

    if (first && meta.isDoNotOpenNewFileInit()) {
      // no more input to be expected...
      // In this case, no file was opened.
      if (r == null) {
        setOutputDone();
        return false;
      }

      if (openNewFile()) {
        data.OpenedNewFile = true;
      } else {
        logError("Couldn't open file " + meta.getFileName()); // $NON-NLS-1$
        setErrors(1L);
        return false;
      }
    }

    if ((r != null
        && getLinesOutput() > 0
        && meta.getSplitEvery() > 0
        && (getLinesOutput() % meta.getSplitEvery()) == 0)) {
      // Done with this part or with everything.
      closeFile();

      // Not finished: open another file...
      if (r != null) {
        if (!openNewFile()) {
          logError(
              "Unable to open new file (split #"
                  + data.splitnr
                  + "..."); //$NON-NLS-1$ //$NON-NLS-2$
          setErrors(1);
          return false;
        }
      }
    }

    if (r == null) // no more input to be expected...
    {
      setOutputDone();
      return false;
    }

    writeRowToFile(getInputRowMeta(), r);

    data.outputRowMeta = getInputRowMeta().clone();
    meta.getFields(data.outputRowMeta, getStepname(), null, null, this);
    putRow(data.outputRowMeta, r); // in case we want it to go further...

    if (checkFeedback(getLinesOutput())) logBasic("linenr " + getLinesOutput()); // $NON-NLS-1$

    return result;
  }