Java Code Examples for org.pentaho.di.core.Result#setSafeStop()

The following examples show how to use org.pentaho.di.core.Result#setSafeStop() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseStreamStepTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testStop() throws KettleException {
  Result result = new Result();
  result.setSafeStop( false );
  result.setRows( Collections.emptyList() );
  when( streamWindow.buffer( any() ) ).thenReturn( Collections.singletonList( result ) );

  baseStreamStep.processRow( meta, stepData );
  assertFalse( baseStreamStep.isSafeStopped() );
  verify( streamSource ).close();
}
 
Example 2
Source File: BaseStreamStepTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testSafeStop() throws KettleException {
  Result result = new Result();
  result.setSafeStop( true );
  when( streamWindow.buffer( any() ) ).thenReturn( Collections.singletonList( result ) );

  baseStreamStep.processRow( meta, stepData );
  assertTrue( baseStreamStep.isSafeStopped() );
  verify( streamSource, times( 2 ) ).close();
}
 
Example 3
Source File: Trans.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * Gets the result of the transformation. The Result object contains such measures as the number of errors, number of
 * lines read/written/input/output/updated/rejected, etc.
 *
 * @return the Result object containing resulting measures from execution of the transformation
 */
public Result getResult() {
  if ( steps == null ) {
    return null;
  }

  Result result = new Result();
  result.setNrErrors( errors.longValue() );
  result.setResult( errors.longValue() == 0 );
  TransLogTable transLogTable = transMeta.getTransLogTable();

  for ( int i = 0; i < steps.size(); i++ ) {
    StepMetaDataCombi sid = steps.get( i );
    StepInterface step = sid.step;

    result.setNrErrors( result.getNrErrors() + sid.step.getErrors() );
    result.getResultFiles().putAll( step.getResultFiles() );

    if ( step.isSafeStopped() ) {
      result.setSafeStop( step.isSafeStopped() );
    }

    if ( step.getStepname().equals( transLogTable.getSubjectString( TransLogTable.ID.LINES_READ ) ) ) {
      result.setNrLinesRead( result.getNrLinesRead() + step.getLinesRead() );
    }
    if ( step.getStepname().equals( transLogTable.getSubjectString( TransLogTable.ID.LINES_INPUT ) ) ) {
      result.setNrLinesInput( result.getNrLinesInput() + step.getLinesInput() );
    }
    if ( step.getStepname().equals( transLogTable.getSubjectString( TransLogTable.ID.LINES_WRITTEN ) ) ) {
      result.setNrLinesWritten( result.getNrLinesWritten() + step.getLinesWritten() );
    }
    if ( step.getStepname().equals( transLogTable.getSubjectString( TransLogTable.ID.LINES_OUTPUT ) ) ) {
      result.setNrLinesOutput( result.getNrLinesOutput() + step.getLinesOutput() );
    }
    if ( step.getStepname().equals( transLogTable.getSubjectString( TransLogTable.ID.LINES_UPDATED ) ) ) {
      result.setNrLinesUpdated( result.getNrLinesUpdated() + step.getLinesUpdated() );
    }
    if ( step.getStepname().equals( transLogTable.getSubjectString( TransLogTable.ID.LINES_REJECTED ) ) ) {
      result.setNrLinesRejected( result.getNrLinesRejected() + step.getLinesRejected() );
    }
  }

  result.setRows( resultRows );
  if ( !Utils.isEmpty( resultFiles ) ) {
    result.setResultFiles( new HashMap<String, ResultFile>() );
    for ( ResultFile resultFile : resultFiles ) {
      result.getResultFiles().put( resultFile.toString(), resultFile );
    }
  }
  result.setStopped( isStopped() );
  result.setLogChannelId( log.getLogChannelId() );

  return result;
}