org.pentaho.di.core.Result Java Examples

The following examples show how to use org.pentaho.di.core.Result. 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: TransExecutorUnitTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
  executor = StepMockUtil.getStep( TransExecutor.class, TransExecutorMeta.class, "TransExecutorUnitTest" );
  executor = spy( executor );

  TransMeta internalTransMeta = mock( TransMeta.class );
  doReturn( internalTransMeta ).when( executor ).loadExecutorTransMeta();

  internalTrans = spy( new Trans() );
  internalTrans.setLog( mock( LogChannelInterface.class ) );
  doNothing().when( internalTrans ).prepareExecution( any( String[].class ) );
  doNothing().when( internalTrans ).startThreads();
  doNothing().when( internalTrans ).waitUntilFinished();
  doNothing().when( executor ).discardLogLines( any( TransExecutorData.class ) );

  doReturn( internalTrans ).when( executor ).createInternalTrans();
  internalResult = new Result();
  doReturn( internalResult ).when( internalTrans ).getResult();

  meta = new TransExecutorMeta();
  data = new TransExecutorData();
}
 
Example #2
Source File: MasterSlaveIT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * This test check passing rows to sub-transformation executed on cluster
 * See PDI-10704 for details
 * @throws Exception
 */
public void runSubtransformationClustered() throws Exception {
  TransMeta transMeta =
    loadTransMetaReplaceSlavesInCluster(
      clusterGenerator, "test/org/pentaho/di/cluster/test-subtrans-clustered.ktr" );
  TransExecutionConfiguration config = createClusteredTransExecutionConfiguration();
  Result prevResult = new Result();
  prevResult.setRows( getSampleRows() );
  config.setPreviousResult( prevResult );

  TransSplitter transSplitter = Trans.executeClustered( transMeta, config );
  LogChannel logChannel = createLogChannel( "cluster unit test <runSubtransformationClustered>" );
  long nrErrors = Trans.monitorClusteredTransformation( logChannel, transSplitter, null, 1 );
  assertEquals( 0L, nrErrors );

  String result = loadFileContent( transMeta, "${java.io.tmpdir}/test-subtrans-clustered.txt" );
  assertEqualsIgnoreWhitespacesAndCase( "10", result );
}
 
Example #3
Source File: JobEntryEvalTableContentTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testNrErrorsNoCustomSql() {
  entry.setLimit( "5" );
  entry.setSuccessCondition( JobEntryEvalTableContent.SUCCESS_CONDITION_ROWS_COUNT_EQUAL );
  entry.setUseCustomSQL( true );
  entry.setCustomSQL( null );

  Result res = entry.execute( new Result(), 0 );

  assertFalse( "Eval number of rows should fail", res.getResult() );
  assertEquals( "Apparently there should be an error", 1, res.getNrErrors() );

  // that should work regardless of old/new behavior flag
  entry.setVariable( Const.KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES, "Y" );

  res = entry.execute( new Result(), 0 );

  assertFalse( "Eval number of rows should fail", res.getResult() );
  assertEquals( "Apparently there should be an error", 1, res.getNrErrors() );
}
 
Example #4
Source File: JobEntryJobRunnerTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testRun() throws Exception {
  // Call all the NO-OP paths
  when( mockJob.isStopped() ).thenReturn( true );
  jobRunner.run();
  when( mockJob.isStopped() ).thenReturn( false );
  when( mockJob.getParentJob() ).thenReturn( null );
  when( mockJob.getJobMeta() ).thenReturn( mockJobMeta );
  jobRunner.run();
  when( parentJob.isStopped() ).thenReturn( true );
  when( mockJob.getParentJob() ).thenReturn( parentJob );
  jobRunner.run();
  when( parentJob.isStopped() ).thenReturn( false );
  when( mockJob.execute( Mockito.anyInt(), Mockito.any( Result.class ) ) ).thenReturn( mockResult );
  jobRunner.run();

}
 
Example #5
Source File: JobEntryWaitForSQLIT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testBadResult() throws KettleException {
  JobEntryWaitForSQL entry = spy( new JobEntryWaitForSQL() );
  doReturn( false ).when( entry ).SQLDataOK( any( Result.class ), anyLong(), anyString(), anyString(), anyString() );
  doNothing().when( entry ).checkConnection();

  entry.setDatabase( mockDbMeta );
  entry.successCondition = JobEntryWaitForSQL.SUCCESS_CONDITION_ROWS_COUNT_GREATER;
  entry.rowsCountValue = "0";
  entry.setMaximumTimeout( "1" ); // Seconds
  entry.setCheckCycleTime( "1" ); // Seconds
  entry.tablename = UUID.randomUUID().toString();
  entry.setParentJob( parentJob );

  Result result = entry.execute( new Result(), 0 );
  assertNotNull( result );
  assertFalse( result.getResult() );
  assertEquals( 1, result.getNrErrors() );
}
 
Example #6
Source File: JobEntryFTPSGetIT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void downloadFile_WhenDestinationIsSetViaVariable() throws Exception {
  final String myVar = "my-var";
  final String expectedDownloadedFilePath = ramDir + "/" + FtpsServer.SAMPLE_FILE;

  JobEntryFTPSGet job = createCommonJob();
  job.setVariable( myVar, ramDir );
  job.setTargetDirectory( String.format( "${%s}", myVar ) );

  FileObject downloaded = KettleVFS.getFileObject( expectedDownloadedFilePath );
  assertFalse( downloaded.exists() );
  try {
    job.execute( new Result(), 1 );
    downloaded = KettleVFS.getFileObject( expectedDownloadedFilePath );
    assertTrue( downloaded.exists() );
  } finally {
    downloaded.delete();
  }
}
 
Example #7
Source File: JobEntryTalendJobExec.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public Result execute( Result previousResult, int nr ) {
  Result result = previousResult;
  result.setResult( false );

  if ( filename != null ) {
    String realFilename = getRealFilename();
    try {
      FileObject file = KettleVFS.getFileObject( realFilename, this );
      if ( file.exists() && file.isReadable() ) {
        result = executeTalenJob( file, result, nr );
      } else {
        logDetailed( BaseMessages.getString( PKG, "JobEntryTalendJobExec.File_Does_Not_Exist", realFilename ) );
      }
    } catch ( Exception e ) {
      result.setNrErrors( 1 );
      logError(
        BaseMessages.getString( PKG, "JobEntryTalendJobExec.ERROR_0004_IO_Exception", e.getMessage() ), e );
    }
  } else {
    result.setNrErrors( 1 );
    logError( BaseMessages.getString( PKG, "JobEntryTalendJobExec.ERROR_0005_No_Filename_Defined" ) );
  }

  return result;
}
 
Example #8
Source File: JobEntryCheckDbConnectionsIT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test( timeout = 5000 )
public void testWaitingtime() {
  int waitTimes = 3;
  Job mockedJob = Mockito.mock( Job.class );
  Mockito.when( mockedJob.isStopped() ).thenReturn( false );

  JobEntryCheckDbConnections meta = new JobEntryCheckDbConnections();
  meta.setParentJob( mockedJob );
  meta.setLogLevel( LogLevel.DETAILED );

  DatabaseMeta db = new DatabaseMeta( "InMemory H2", "H2", null, null, H2_DATABASE, "-1", null, null );
  meta.setConnections( new DatabaseMeta[]{ db } );
  meta.setWaittimes( new int[]{ JobEntryCheckDbConnections.UNIT_TIME_SECOND } );
  meta.setWaitfors( new String[]{ String.valueOf( waitTimes ) } );

  Result result = meta.execute( new Result(), 0 );

  Assert.assertTrue( meta.getNow() - meta.getTimeStart() >= waitTimes * 1000 );
  Assert.assertTrue( result.getResult() );
}
 
Example #9
Source File: JobEntryPGPDecryptFiles.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addFileToResultFilenames( String fileaddentry, Result result, Job parentJob ) {
  try {
    ResultFile resultFile =
      new ResultFile( ResultFile.FILE_TYPE_GENERAL, KettleVFS.getFileObject( fileaddentry ), parentJob
        .getJobname(), toString() );
    result.getResultFiles().put( resultFile.getFile().toString(), resultFile );

    if ( isDebug() ) {
      logDebug( " ------ " );
      logDebug( BaseMessages.getString( PKG, "JobPGPDecryptFiles.Log.FileAddedToResultFilesName", fileaddentry ) );
    }

  } catch ( Exception e ) {
    logError( BaseMessages.getString( PKG, "JobPGPDecryptFiles.Error.AddingToFilenameResult" ), fileaddentry
      + "" + e.getMessage() );
  }
}
 
Example #10
Source File: PanCommandExecutorTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testExecuteWithInvalidRepository() {
  // Create Mock Objects
  Params params = mock( Params.class );
  PanCommandExecutor panCommandExecutor = new PanCommandExecutor( Kitchen.class );
  PowerMockito.mockStatic( BaseMessages.class );

  // Mock returns
  when( params.getRepoName() ).thenReturn( "NoExistingRepository" );
  when( BaseMessages.getString( any( Class.class ), anyString(), anyVararg() ) ).thenReturn( "" );

  try {
    Result result = panCommandExecutor.execute( params, null );
    Assert.assertEquals( CommandExecutorCodes.Pan.COULD_NOT_LOAD_TRANS.getCode(), result.getExitStatus() );
  } catch ( Throwable throwable ) {
    Assert.fail();
  }

}
 
Example #11
Source File: TransExecutorUnitTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testCollectExecutionResultsDisabledHop() throws KettleException {
  StepMeta executionResultTargetStepMeta = mock( StepMeta.class );
  meta.setExecutionResultTargetStepMeta( executionResultTargetStepMeta );

  RowMetaInterface executionResultsOutputRowMeta = mock( RowMetaInterface.class );
  data.setExecutionResultsOutputRowMeta( executionResultsOutputRowMeta );

  doNothing().when( executor ).putRowTo( any(), any(), any() );

  executor.init( meta, data );
  Result result = mock( Result.class );
  executor.collectExecutionResults( result );

  verify( executor, never() ).putRowTo( any(), any(), any() );
}
 
Example #12
Source File: JobEntryMoveFiles.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addFileToResultFilenames( String fileaddentry, Result result, Job parentJob ) {
  try {
    ResultFile resultFile =
      new ResultFile( ResultFile.FILE_TYPE_GENERAL, KettleVFS.getFileObject( fileaddentry, this ), parentJob
        .getJobname(), toString() );
    result.getResultFiles().put( resultFile.getFile().toString(), resultFile );

    if ( log.isDebug() ) {
      logDebug( " ------ " );
      logDebug( BaseMessages.getString( PKG, "JobMoveFiles.Log.FileAddedToResultFilesName", fileaddentry ) );
    }

  } catch ( Exception e ) {
    log.logError( BaseMessages.getString( PKG, "JobMoveFiles.Error.AddingToFilenameResult" ), fileaddentry
      + "" + e.getMessage() );
  }

}
 
Example #13
Source File: JobEntryMSAccessBulkLoad.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addFileToResultFilenames( String fileaddentry, Result result, Job parentJob ) {
  try {
    ResultFile resultFile =
      new ResultFile( ResultFile.FILE_TYPE_GENERAL, KettleVFS.getFileObject( fileaddentry, this ), parentJob
        .getJobname(), toString() );
    result.getResultFiles().put( resultFile.getFile().toString(), resultFile );

    if ( log.isDebug() ) {
      logDebug( " ------ " );
      logDebug( BaseMessages.getString(
        PKG, "JobEntryMSAccessBulkLoad.Log.FileAddedToResultFilesName", fileaddentry ) );
    }
  } catch ( Exception e ) {
    log.logError(
      BaseMessages.getString( PKG, "JobEntryMSAccessBulkLoad.Error.AddingToFilenameResult" ), fileaddentry
        + "" + e.getMessage() );
  }
}
 
Example #14
Source File: JobEntryFilesExistTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetNrErrorsNewBehaviorFalseResult() throws Exception {
  // this tests fix for PDI-10270
  entry.setArguments( new String[] { "nonExistingFile.ext" } );

  Result res = entry.execute( new Result(), 0 );

  assertFalse( "Entry should fail", res.getResult() );
  assertEquals( "Files not found. Result is false. But... No of errors should be zero", 0, res.getNrErrors() );
}
 
Example #15
Source File: JobEntryJobRunner.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 *
 */
public JobEntryJobRunner( Job job, Result result, int entryNr, LogChannelInterface log ) {
  this.job = job;
  this.result = result;
  this.log = log;
  this.entryNr = entryNr;
  finished = false;
}
 
Example #16
Source File: FixedTimeStreamWindowTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void emptyResultsNotPostProcessed() throws KettleException {
  RowMetaInterface rowMeta = new RowMeta();
  rowMeta.addValueMeta( new ValueMetaString( "field" ) );
  Result mockResult = new Result();
  mockResult.setRows( Arrays.asList( new RowMetaAndData( rowMeta, "queen" ), new RowMetaAndData( rowMeta, "king" ) ) );
  when( subtransExecutor.execute( any()  ) ).thenReturn( Optional.empty() );
  when( subtransExecutor.getPrefetchCount() ).thenReturn( 10 );
  AtomicInteger count = new AtomicInteger();
  FixedTimeStreamWindow<List> window =
    new FixedTimeStreamWindow<>( subtransExecutor, rowMeta, 0, 2, 1, ( p ) -> count.set( p.getKey().get( 0 ).size() ) );
  window.buffer( Flowable.fromIterable( singletonList( asList( "v1", "v2" ) ) ) )
    .forEach( result -> assertEquals( mockResult, result ) );
  assertEquals( 0, count.get() );
}
 
Example #17
Source File: KitchenIT.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testFileJobExpectedExecutionWithSuccess() throws Exception {

  for ( String testKJB : KTRS_EXPECTED_COMPLETE_WITH_SUCCESS ) {

    long now = System.currentTimeMillis();

    String testKJBRelativePath = EXPECTED_COMPLETE_WITH_SUCCESS_PATH + File.separator + testKJB;
    String testKJBFullPath = this.getClass().getResource( testKJBRelativePath ).getFile();
    String logFileRelativePath = testKJBRelativePath + "." + now + ".log";
    String logFileFullPath = testKJBFullPath + "." + now + ".log";

    try {

      Kitchen.main( new String[]{ "/file:" + testKJBFullPath, "/level:Basic", "/logfile:" + logFileFullPath } );

    } catch ( SecurityException e ) {
      // All OK / expected: SecurityException is purposely thrown when Kitchen triggers System.exitJVM()

      // get log file contents
      String logFileContent = getFileContentAsString( logFileRelativePath );

      assertTrue( logFileContent.contains( JOB_EXEC_RESULT_TRUE ) );
      assertFalse( logFileContent.contains( FAILED_JOB_EXEC_PATTERN ) );

      Result result = Kitchen.getCommandExecutor().getResult();
      assertNotNull( result );
      assertEquals( result.getExitStatus(), CommandExecutorCodes.Kitchen.SUCCESS.getCode() );

    } finally {
      // sanitize
      File f = new File( logFileFullPath );
      if ( f != null && f.exists() ) {
        f.deleteOnExit();
      }
    }
  }
}
 
Example #18
Source File: FixedTimeStreamWindowTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void supportsPostProcessing() throws KettleException {
  RowMetaInterface rowMeta = new RowMeta();
  rowMeta.addValueMeta( new ValueMetaString( "field" ) );
  Result mockResult = new Result();
  mockResult.setRows( Arrays.asList( new RowMetaAndData( rowMeta, "queen" ), new RowMetaAndData( rowMeta, "king" ) ) );
  when( subtransExecutor.execute( any()  ) ).thenReturn( Optional.of( mockResult ) );
  when( subtransExecutor.getPrefetchCount() ).thenReturn( 10 );
  AtomicInteger count = new AtomicInteger();
  FixedTimeStreamWindow<List> window =
    new FixedTimeStreamWindow<>( subtransExecutor, rowMeta, 0, 2, 1, ( p ) -> count.set( p.getKey().get( 0 ).size() ) );
  window.buffer( Flowable.fromIterable( singletonList( asList( "v1", "v2" ) ) ) )
    .forEach( result -> assertEquals( mockResult, result ) );
  assertEquals( 2, count.get() );
}
 
Example #19
Source File: JobEntryTelnet.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public Result execute( Result previousResult, int nr ) {

    Result result = previousResult;

    result.setNrErrors( 1 );
    result.setResult( false );

    String hostname = getRealHostname();
    int port = Const.toInt( getRealPort(), DEFAULT_PORT );
    int timeoutInt = Const.toInt( getRealTimeOut(), -1 );

    if ( Utils.isEmpty( hostname ) ) {
      // No Host was specified
      logError( BaseMessages.getString( PKG, "JobTelnet.SpecifyHost.Label" ) );
      return result;
    }

    try {

      SocketUtil.connectToHost( hostname, port, timeoutInt );

      if ( isDetailed() ) {
        logDetailed( BaseMessages.getString( PKG, "JobTelnet.OK.Label", hostname, port ) );
      }

      result.setNrErrors( 0 );
      result.setResult( true );

    } catch ( Exception ex ) {
      logError( BaseMessages.getString( PKG, "JobTelnet.NOK.Label", hostname, String.valueOf( port ) ) );
      logError( BaseMessages.getString( PKG, "JobTelnet.Error.Label" ) + ex.getMessage() );
    }

    return result;
  }
 
Example #20
Source File: JobEntryTransTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private Result generateDummyResult( int nRows ) {
  Result result = new Result();
  List<RowMetaAndData> rows = new ArrayList<>();
  for ( int i = 0; i < nRows; ++i ) {
    rows.add( new RowMetaAndData() );
  }
  result.setRows( rows );
  return result;
}
 
Example #21
Source File: JobEntryDosToUnix.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void addFileToResultFilenames( FileObject fileaddentry, Result result, Job parentJob ) {
  try {
    ResultFile resultFile =
      new ResultFile( ResultFile.FILE_TYPE_GENERAL, fileaddentry, parentJob.getJobname(), toString() );
    result.getResultFiles().put( resultFile.getFile().toString(), resultFile );

    if ( isDetailed() ) {
      logDetailed( BaseMessages.getString( PKG, "JobDosToUnix.Log.FileAddedToResultFilesName", fileaddentry ) );
    }

  } catch ( Exception e ) {
    logError( BaseMessages.getString(
      PKG, "JobDosToUnix.Error.AddingToFilenameResult", fileaddentry.toString(), e.getMessage() ) );
  }
}
 
Example #22
Source File: TransExecutorUnitTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testCollectTransResultsDisabledHop() throws KettleException {
  StepMeta outputRowsSourceStepMeta = mock( StepMeta.class );
  meta.setOutputRowsSourceStepMeta( outputRowsSourceStepMeta );

  Result result = mock( Result.class );
  RowMetaAndData rowMetaAndData = mock( RowMetaAndData.class );
  when( result.getRows() ).thenReturn( Arrays.asList( rowMetaAndData ) );

  doNothing().when( executor ).putRowTo( any(), any(), any() );

  executor.init( meta, data );
  executor.collectTransResults( result );
  verify( executor, never() ).putRowTo( any(), any(), any() );
}
 
Example #23
Source File: JobEntryDeleteFilesTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void filesWithNoPath_AreNotProcessed_ArgsOfPreviousMeta() throws Exception {
  jobEntry.setArgFromPrevious( true );

  Result prevMetaResult = new Result();
  List<RowMetaAndData> metaAndDataList = new ArrayList<>();

  metaAndDataList.add( constructRowMetaAndData( Const.EMPTY_STRING, null ) );
  metaAndDataList.add( constructRowMetaAndData( STRING_SPACES_ONLY, null ) );

  prevMetaResult.setRows( metaAndDataList );

  jobEntry.execute( prevMetaResult, 0 );
  verify( jobEntry, never() ).processFile( anyString(), anyString(), any( Job.class ) );
}
 
Example #24
Source File: JobEntryMailValidatorTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testExecute() {
  KettleLogStore.init();
  Result previousResult = new Result();
  JobEntryMailValidator validator = new JobEntryMailValidator();
  Result result = validator.execute( previousResult, 0 );
  assertNotNull( result );
}
 
Example #25
Source File: JobEntryTransTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void updateResultTestWithZeroRows() {
  JobEntryTrans jobEntryTrans = spy( getJobEntryTrans() );
  Trans transMock = mock( Trans.class );
  setInternalState( jobEntryTrans, "trans", transMock );
  //Transformation returns result with 0 rows
  when( transMock.getResult() ).thenReturn( generateDummyResult( 0 ) );
  //Previous result has 3 rows
  Result resultToBeUpdated = generateDummyResult( 3 );
  //Update the result
  jobEntryTrans.updateResult( resultToBeUpdated );
  //Result should have 3 number of rows since the trans result has no rows (meaning nothing was done)
  assertEquals( resultToBeUpdated.getRows().size(), 3 );
}
 
Example #26
Source File: JobEntryJobRunnerTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testRunWithExceptionOnExecuteSetsResult() throws Exception {
  when( mockJob.isStopped() ).thenReturn( false );
  when( mockJob.getParentJob() ).thenReturn( parentJob );
  when( parentJob.isStopped() ).thenReturn( false );
  doThrow( KettleException.class ).when( mockJob ).execute( anyInt(), any( Result.class ) );

  jobRunner.run();
  verify( mockJob, times( 1 ) ).setResult( Mockito.any( Result.class ) );
}
 
Example #27
Source File: JobEntryXMLWellFormed.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private boolean checkOneFile( FileObject file, Result result, Job parentJob ) throws KettleException {
  boolean retval = false;
  try {
    // We deal with a file..so let's check if it's well formed
    boolean retformed = CheckFile( file );
    if ( !retformed ) {
      logError( BaseMessages.getString( PKG, "JobXMLWellFormed.Error.FileBadFormed", file.toString() ) );
      // Update Bad formed files number
      updateBadFormed();
      if ( resultfilenames.equals( ADD_ALL_FILENAMES ) || resultfilenames.equals( ADD_BAD_FORMED_FILES_ONLY ) ) {
        addFileToResultFilenames( KettleVFS.getFilename( file ), result, parentJob );
      }
    } else {
      if ( log.isDetailed() ) {
        logDetailed( "---------------------------" );
        logDetailed( BaseMessages.getString( PKG, "JobXMLWellFormed.Error.FileWellFormed", file.toString() ) );
      }
      // Update Well formed files number
      updateWellFormed();
      if ( resultfilenames.equals( ADD_ALL_FILENAMES ) || resultfilenames.equals( ADD_WELL_FORMED_FILES_ONLY ) ) {
        addFileToResultFilenames( KettleVFS.getFilename( file ), result, parentJob );
      }
    }

  } catch ( Exception e ) {
    throw new KettleException( "Unable to verify file '" + file + "'", e );
  }
  return retval;
}
 
Example #28
Source File: JobExecutionExtension.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public JobExecutionExtension( Job job, Result result, JobEntryCopy jobEntryCopy, boolean executeEntry ) {
  super();
  this.job = job;
  this.result = result;
  this.jobEntryCopy = jobEntryCopy;
  this.executeEntry = executeEntry;
}
 
Example #29
Source File: JobEntryExportRepository.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void addFileToResultFilenames( String fileaddentry, LogChannelInterface log, Result result, Job parentJob ) {
  try {
    ResultFile resultFile =
      new ResultFile( ResultFile.FILE_TYPE_GENERAL, KettleVFS.getFileObject( fileaddentry, this ), parentJob
        .getJobname(), toString() );
    result.getResultFiles().put( resultFile.getFile().toString(), resultFile );
    if ( log.isDebug() ) {
      logDebug( BaseMessages.getString( PKG, "JobExportRepository.Log.FileAddedToResultFilesName", fileaddentry ) );
    }
  } catch ( Exception e ) {
    log.logError(
      BaseMessages.getString( PKG, "JobExportRepository.Error.AddingToFilenameResult" ), fileaddentry
        + "" + e.getMessage() );
  }
}
 
Example #30
Source File: JobEntrySQL.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public Result execute( Result result, int nr ) {

    if ( databaseMeta != null ) {
      try ( Database db = new Database( this, databaseMeta ) ) {
        String theSql = sqlFromFile ? buildSqlFromFile() : sql;
        if ( Utils.isEmpty( theSql ) ) {
          return result;
        }
        db.shareVariablesWith( this );
        db.connect( parentJob.getTransactionId(), null );
        // let it run
        if ( useVariableSubstitution ) {
          theSql = environmentSubstitute( theSql );
        }
        if ( isDetailed() ) {
          logDetailed( BaseMessages.getString( PKG, "JobSQL.Log.SQlStatement", theSql ) );
        }
        if ( sendOneStatement ) {
          db.execStatement( theSql );
        } else {
          db.execStatements( theSql );
        }
      } catch ( KettleDatabaseException je ) {
        result.setNrErrors( 1 );
        logError( BaseMessages.getString( PKG, "JobSQL.ErrorRunJobEntry", je.getMessage() ) );
      }
    } else {
      result.setNrErrors( 1 );
      logError( BaseMessages.getString( PKG, "JobSQL.NoDatabaseConnection" ) );
    }

    result.setResult( result.getNrErrors() == 0 );
    return result;
  }