Java Code Examples for org.pentaho.di.core.Result#setNrLinesWritten()
The following examples show how to use
org.pentaho.di.core.Result#setNrLinesWritten() .
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: JobEntryDosToUnix.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public Result execute( Result previousResult, int nr ) throws KettleException { Result result = previousResult; result.setNrErrors( 1 ); result.setResult( false ); List<RowMetaAndData> rows = previousResult.getRows(); RowMetaAndData resultRow = null; nrErrors = 0; nrProcessedFiles = 0; nrErrorFiles = 0; limitFiles = Const.toInt( environmentSubstitute( getNrErrorsLessThan() ), 10 ); successConditionBroken = false; successConditionBrokenExit = false; tempFolder = environmentSubstitute( "%%java.io.tmpdir%%" ); // Get source and destination files, also wildcard String[] vsourcefilefolder = source_filefolder; String[] vwildcard = wildcard; if ( arg_from_previous ) { if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobDosToUnix.Log.ArgFromPrevious.Found", ( rows != null ? rows .size() : 0 ) + "" ) ); } } if ( arg_from_previous && rows != null ) { // Copy the input row to the (command line) arguments for ( int iteration = 0; iteration < rows.size() && !parentJob.isStopped(); iteration++ ) { if ( successConditionBroken ) { if ( !successConditionBrokenExit ) { logError( BaseMessages.getString( PKG, "JobDosToUnix.Error.SuccessConditionbroken", "" + nrAllErrors ) ); successConditionBrokenExit = true; } result.setEntryNr( nrAllErrors ); result.setNrLinesRejected( nrErrorFiles ); result.setNrLinesWritten( nrProcessedFiles ); return result; } resultRow = rows.get( iteration ); // Get source and destination file names, also wildcard String vsourcefilefolder_previous = resultRow.getString( 0, null ); String vwildcard_previous = resultRow.getString( 1, null ); int convertion_type = JobEntryDosToUnix.getConversionTypeByCode( resultRow.getString( 2, null ) ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobDosToUnix.Log.ProcessingRow", vsourcefilefolder_previous, vwildcard_previous ) ); } processFileFolder( vsourcefilefolder_previous, vwildcard_previous, convertion_type, parentJob, result ); } } else if ( vsourcefilefolder != null ) { for ( int i = 0; i < vsourcefilefolder.length && !parentJob.isStopped(); i++ ) { if ( successConditionBroken ) { if ( !successConditionBrokenExit ) { logError( BaseMessages.getString( PKG, "JobDosToUnix.Error.SuccessConditionbroken", "" + nrAllErrors ) ); successConditionBrokenExit = true; } result.setEntryNr( nrAllErrors ); result.setNrLinesRejected( nrErrorFiles ); result.setNrLinesWritten( nrProcessedFiles ); return result; } if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobDosToUnix.Log.ProcessingRow", vsourcefilefolder[i], vwildcard[i] ) ); } processFileFolder( vsourcefilefolder[i], vwildcard[i], conversionTypes[i], parentJob, result ); } } // Success Condition result.setNrErrors( nrAllErrors ); result.setNrLinesRejected( nrErrorFiles ); result.setNrLinesWritten( nrProcessedFiles ); if ( getSuccessStatus() ) { result.setNrErrors( 0 ); result.setResult( true ); } displayResults(); return result; }
Example 2
Source File: JobEntryCopyMoveResultFilenames.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public Result execute( Result previousResult, int nr ) { Result result = previousResult; result.setNrErrors( 1 ); result.setResult( false ); boolean deleteFile = getAction().equals( "delete" ); //Set Embedded NamedCluter MetatStore Provider Key so that it can be passed to VFS if ( parentJobMeta.getNamedClusterEmbedManager() != null ) { parentJobMeta.getNamedClusterEmbedManager() .passEmbeddedMetastoreKey( this, parentJobMeta.getEmbeddedMetastoreProviderKey() ); } String realdestinationFolder = null; if ( !deleteFile ) { realdestinationFolder = environmentSubstitute( getDestinationFolder() ); if ( !CreateDestinationFolder( realdestinationFolder ) ) { return result; } } if ( !Utils.isEmpty( wildcard ) ) { wildcardPattern = Pattern.compile( environmentSubstitute( wildcard ) ); } if ( !Utils.isEmpty( wildcardexclude ) ) { wildcardExcludePattern = Pattern.compile( environmentSubstitute( wildcardexclude ) ); } if ( previousResult != null ) { NrErrors = 0; limitFiles = Const.toInt( environmentSubstitute( getNrErrorsLessThan() ), 10 ); NrErrors = 0; NrSuccess = 0; successConditionBroken = false; successConditionBrokenExit = false; FileObject file = null; try { int size = result.getResultFiles().size(); if ( log.isBasic() ) { logBasic( BaseMessages.getString( PKG, "JobEntryCopyMoveResultFilenames.log.FilesFound", "" + size ) ); } List<ResultFile> resultFiles = result.getResultFilesList(); if ( resultFiles != null && resultFiles.size() > 0 ) { for ( Iterator<ResultFile> it = resultFiles.iterator(); it.hasNext() && !parentJob.isStopped(); ) { if ( successConditionBroken ) { logError( BaseMessages.getString( PKG, "JobEntryCopyMoveResultFilenames.Error.SuccessConditionbroken", "" + NrErrors ) ); throw new Exception( BaseMessages.getString( PKG, "JobEntryCopyMoveResultFilenames.Error.SuccessConditionbroken", "" + NrErrors ) ); } ResultFile resultFile = it.next(); file = resultFile.getFile(); if ( file != null && file.exists() ) { if ( !specifywildcard || ( CheckFileWildcard( file.getName().getBaseName(), wildcardPattern, true ) && !CheckFileWildcard( file.getName().getBaseName(), wildcardExcludePattern, false ) && specifywildcard ) ) { // Copy or Move file if ( !processFile( file, realdestinationFolder, result, parentJob, deleteFile ) ) { // Update Errors updateErrors(); } } } else { logError( BaseMessages.getString( PKG, "JobEntryCopyMoveResultFilenames.log.ErrorCanNotFindFile", file.toString() ) ); // Update Errors updateErrors(); } } // end for } } catch ( Exception e ) { logError( BaseMessages.getString( PKG, "JobEntryCopyMoveResultFilenames.Error", e.toString() ) ); } finally { if ( file != null ) { try { file.close(); file = null; } catch ( Exception ex ) { /* Ignore */ } } } } // Success Condition result.setNrErrors( NrErrors ); result.setNrLinesWritten( NrSuccess ); if ( getSuccessStatus() ) { result.setResult( true ); } return result; }
Example 3
Source File: JobEntryColumnsExist.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public Result execute( Result previousResult, int nr ) { Result result = previousResult; result.setResult( false ); result.setNrErrors( 1 ); int nrexistcolums = 0; int nrnotexistcolums = 0; if ( Utils.isEmpty( tablename ) ) { logError( BaseMessages.getString( PKG, "JobEntryColumnsExist.Error.TablenameEmpty" ) ); return result; } if ( arguments == null ) { logError( BaseMessages.getString( PKG, "JobEntryColumnsExist.Error.ColumnameEmpty" ) ); return result; } if ( connection != null ) { Database db = getNewDatabaseFromMeta(); db.shareVariablesWith( this ); try { String realSchemaname = environmentSubstitute( schemaname ); String realTablename = environmentSubstitute( tablename ); db.connect( parentJob.getTransactionId(), null ); if ( db.checkTableExists( realSchemaname, realTablename ) ) { if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryColumnsExist.Log.TableExists", realTablename ) ); } for ( int i = 0; i < arguments.length && !parentJob.isStopped(); i++ ) { String realColumnname = environmentSubstitute( arguments[i] ); if ( db.checkColumnExists( realSchemaname, realTablename, realColumnname ) ) { if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryColumnsExist.Log.ColumnExists", realColumnname, realTablename ) ); } nrexistcolums++; } else { logError( BaseMessages.getString( PKG, "JobEntryColumnsExist.Log.ColumnNotExists", realColumnname, realTablename ) ); nrnotexistcolums++; } } } else { logError( BaseMessages.getString( PKG, "JobEntryColumnsExist.Log.TableNotExists", realTablename ) ); } } catch ( KettleDatabaseException dbe ) { logError( BaseMessages.getString( PKG, "JobEntryColumnsExist.Error.UnexpectedError", dbe.getMessage() ) ); } finally { if ( db != null ) { try { db.disconnect(); } catch ( Exception e ) { /* Ignore */ } } } } else { logError( BaseMessages.getString( PKG, "JobEntryColumnsExist.Error.NoDbConnection" ) ); } result.setEntryNr( nrnotexistcolums ); result.setNrLinesWritten( nrexistcolums ); // result is true only if all columns found (PDI-15801) if ( nrexistcolums == arguments.length ) { result.setNrErrors( 0 ); result.setResult( true ); } return result; }
Example 4
Source File: Trans.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * 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; }
Example 5
Source File: JobEntryMSAccessBulkLoad.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public Result execute( Result previousResult, int nr ) { Result result = previousResult; List<RowMetaAndData> rows = result.getRows(); RowMetaAndData resultRow = null; result.setResult( false ); NrErrors = 0; NrSuccess = 0; NrFilesToProcess = 0; continueProcessing = true; limitFiles = Const.toInt( environmentSubstitute( getLimit() ), 10 ); // Get source and destination files, also wildcard String[] vsourceFilefolder = source_filefolder; String[] vsourceWildcard = source_wildcard; String[] vsourceDelimiter = delimiter; String[] targetDb = target_Db; String[] targetTable = target_table; try { if ( is_args_from_previous ) { if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryMSAccessBulkLoad.Log.ArgFromPrevious.Found", ( rows != null ? rows.size() : 0 ) + "" ) ); } } if ( is_args_from_previous && rows != null ) { for ( int iteration = 0; iteration < rows.size() && !parentJob.isStopped() && continueProcessing; iteration++ ) { resultRow = rows.get( iteration ); // Get source and destination file names, also wildcard String vSourceFileFolder_previous = resultRow.getString( 0, null ); String vSourceWildcard_previous = resultRow.getString( 1, null ); String vDelimiter_previous = resultRow.getString( 2, null ); String vTargetDb_previous = resultRow.getString( 3, null ); String vTargetTable_previous = resultRow.getString( 4, null ); processOneRow( vSourceFileFolder_previous, vSourceWildcard_previous, vDelimiter_previous, vTargetDb_previous, vTargetTable_previous, parentJob, result ); } } else if ( vsourceFilefolder != null && targetDb != null && targetTable != null ) { for ( int i = 0; i < vsourceFilefolder.length && !parentJob.isStopped() && continueProcessing; i++ ) { // get real values String realSourceFileFolder = environmentSubstitute( vsourceFilefolder[i] ); String realSourceWildcard = environmentSubstitute( vsourceWildcard[i] ); String realSourceDelimiter = environmentSubstitute( vsourceDelimiter[i] ); String realTargetDb = environmentSubstitute( targetDb[i] ); String realTargetTable = environmentSubstitute( targetTable[i] ); processOneRow( realSourceFileFolder, realSourceWildcard, realSourceDelimiter, realTargetDb, realTargetTable, parentJob, result ); } } } catch ( Exception e ) { incrErrors(); logError( BaseMessages.getString( PKG, "JobEntryMSAccessBulkLoad.UnexpectedError", e.getMessage() ) ); } // Success Condition result.setNrErrors( NrErrors ); result.setNrLinesInput( NrFilesToProcess ); result.setNrLinesWritten( NrSuccess ); if ( getSuccessStatus() ) { result.setResult( true ); } displayResults(); return result; }
Example 6
Source File: JobEntryXSLT.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public Result execute( Result previousResult, int nr ) throws KettleException { Result result = previousResult; int NrErrors = 0; int NrSuccess = 0; // Check output parameters int nrOutputProps = getOutputPropertyName() == null ? 0 : getOutputPropertyName().length; if ( nrOutputProps > 0 ) { outputProperties = new Properties(); for ( int i = 0; i < nrOutputProps; i++ ) { outputProperties.put( getOutputPropertyName()[i], environmentSubstitute( getOutputPropertyValue()[i] ) ); } setOutputProperties = true; } // Check parameters nrParams = getParameterField() == null ? 0 : getParameterField().length; if ( nrParams > 0 ) { nameOfParams = new String[nrParams]; valueOfParams = new String[nrParams]; for ( int i = 0; i < nrParams; i++ ) { String name = environmentSubstitute( getParameterName()[i] ); String value = environmentSubstitute( getParameterField()[i] ); if ( Utils.isEmpty( value ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "Xslt.Exception.ParameterFieldMissing", name, i ) ); } nameOfParams[i] = name; valueOfParams[i] = value; } useParameters = true; } List<RowMetaAndData> rows = result.getRows(); if ( isFilenamesFromPrevious() ) { if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryXSLT.Log.ArgFromPrevious.Found", ( rows != null ? rows .size() : 0 ) + "" ) ); } } if ( isFilenamesFromPrevious() && rows != null ) { // Copy the input row to the (command line) arguments RowMetaAndData resultRow = null; for ( int iteration = 0; iteration < rows.size() && !parentJob.isStopped(); iteration++ ) { resultRow = rows.get( iteration ); // Get filenames (xml, xsl, output filename) String xmlfilename_previous = resultRow.getString( 0, null ); String xslfilename_previous = resultRow.getString( 1, null ); String ouputfilename_previous = resultRow.getString( 2, null ); if ( !Utils.isEmpty( xmlfilename_previous ) && !Utils.isEmpty( xslfilename_previous ) && !Utils.isEmpty( ouputfilename_previous ) ) { if ( processOneXMLFile( xmlfilename_previous, xslfilename_previous, ouputfilename_previous, result, parentJob ) ) { NrSuccess++; } else { NrErrors++; } } else { // We failed! logError( BaseMessages.getString( PKG, "JobEntryXSLT.AllFilesNotNull.Label" ) ); NrErrors++; } } } else { String realxmlfilename = getRealxmlfilename(); String realxslfilename = getRealxslfilename(); String realoutputfilename = getoutputfilename(); if ( !Utils.isEmpty( realxmlfilename ) && !Utils.isEmpty( realxslfilename ) && !Utils.isEmpty( realoutputfilename ) ) { if ( processOneXMLFile( realxmlfilename, realxslfilename, realoutputfilename, result, parentJob ) ) { NrSuccess++; } else { NrErrors++; } } else { // We failed! logError( BaseMessages.getString( PKG, "JobEntryXSLT.AllFilesNotNull.Label" ) ); NrErrors++; } } result.setResult( NrErrors == 0 ); result.setNrErrors( NrErrors ); result.setNrLinesWritten( NrSuccess ); return result; }
Example 7
Source File: JobEntryXMLWellFormed.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public Result execute( Result previousResult, int nr ) throws KettleException { Result result = previousResult; result.setNrErrors( 1 ); result.setResult( false ); List<RowMetaAndData> rows = result.getRows(); RowMetaAndData resultRow = null; NrErrors = 0; NrWellFormed = 0; NrBadFormed = 0; limitFiles = Const.toInt( environmentSubstitute( getNrErrorsLessThan() ), 10 ); successConditionBroken = false; successConditionBrokenExit = false; // Get source and destination files, also wildcard String[] vsourcefilefolder = source_filefolder; String[] vwildcard = wildcard; if ( arg_from_previous ) { if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobXMLWellFormed.Log.ArgFromPrevious.Found", ( rows != null ? rows .size() : 0 ) + "" ) ); } } if ( arg_from_previous && rows != null ) { // Copy the input row to the (command line) arguments for ( int iteration = 0; iteration < rows.size() && !parentJob.isStopped(); iteration++ ) { if ( successConditionBroken ) { if ( !successConditionBrokenExit ) { logError( BaseMessages.getString( PKG, "JobXMLWellFormed.Error.SuccessConditionbroken", "" + NrAllErrors ) ); successConditionBrokenExit = true; } result.setEntryNr( NrAllErrors ); result.setNrLinesRejected( NrBadFormed ); result.setNrLinesWritten( NrWellFormed ); return result; } resultRow = rows.get( iteration ); // Get source and destination file names, also wildcard String vsourcefilefolder_previous = resultRow.getString( 0, null ); String vwildcard_previous = resultRow.getString( 1, null ); if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobXMLWellFormed.Log.ProcessingRow", vsourcefilefolder_previous, vwildcard_previous ) ); } processFileFolder( vsourcefilefolder_previous, vwildcard_previous, parentJob, result ); } } else if ( vsourcefilefolder != null ) { for ( int i = 0; i < vsourcefilefolder.length && !parentJob.isStopped(); i++ ) { if ( successConditionBroken ) { if ( !successConditionBrokenExit ) { logError( BaseMessages.getString( PKG, "JobXMLWellFormed.Error.SuccessConditionbroken", "" + NrAllErrors ) ); successConditionBrokenExit = true; } result.setEntryNr( NrAllErrors ); result.setNrLinesRejected( NrBadFormed ); result.setNrLinesWritten( NrWellFormed ); return result; } if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobXMLWellFormed.Log.ProcessingRow", vsourcefilefolder[i], vwildcard[i] ) ); } processFileFolder( vsourcefilefolder[i], vwildcard[i], parentJob, result ); } } // Success Condition result.setNrErrors( NrAllErrors ); result.setNrLinesRejected( NrBadFormed ); result.setNrLinesWritten( NrWellFormed ); if ( getSuccessStatus() ) { result.setNrErrors( 0 ); result.setResult( true ); } displayResults(); return result; }