Java Code Examples for org.pentaho.di.core.Result#setResult()
The following examples show how to use
org.pentaho.di.core.Result#setResult() .
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: JobEntrySpecial.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public Result execute( Result previousResult, int nr ) throws KettleJobException { Result result = previousResult; if ( isStart() ) { try { long sleepTime = getNextExecutionTime(); if ( sleepTime > 0 ) { parentJob.getLogChannel().logBasic( parentJob.getJobname(), "Sleeping: " + ( sleepTime / 1000 / 60 ) + " minutes (sleep time=" + sleepTime + ")" ); long totalSleep = 0L; while ( totalSleep < sleepTime && !parentJob.isStopped() ) { Thread.sleep( 1000L ); totalSleep += 1000L; } } } catch ( InterruptedException e ) { throw new KettleJobException( e ); } result = previousResult; result.setResult( true ); } else if ( isDummy() ) { result = previousResult; } return result; }
Example 2
Source File: PaloCubeDelete.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public Result execute( Result prevResult, int nr ) throws KettleException { Result result = new Result( nr ); result.setResult( false ); logDetailed( toString(), "Start of processing" ); // String substitution.. String realCubeName = environmentSubstitute( getCubeName() ); PaloHelper database = new PaloHelper( this.getDatabaseMeta(), getLogLevel() ); try { database.connect(); int cubesremoved = database.removeCube( realCubeName ); result.setResult( true ); result.setNrLinesOutput( cubesremoved ); } catch ( Exception e ) { result.setNrErrors( 1 ); e.printStackTrace(); logError( toString(), "Error processing Palo Cube Delete : " + e.getMessage() ); } finally { database.disconnect(); } return result; }
Example 3
Source File: JobEntryTableExists.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public Result execute( Result previousResult, int nr ) { Result result = previousResult; result.setResult( false ); if ( connection != null ) { Database db = new Database( this, connection ); db.shareVariablesWith( this ); try { db.connect( parentJob.getTransactionId(), null ); String realTablename = environmentSubstitute( tablename ); String realSchemaname = environmentSubstitute( schemaname ); if ( db.checkTableExists( realSchemaname, realTablename ) ) { if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "TableExists.Log.TableExists", realTablename ) ); } result.setResult( true ); } else { if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "TableExists.Log.TableNotExists", realTablename ) ); } } } catch ( KettleDatabaseException dbe ) { result.setNrErrors( 1 ); logError( BaseMessages.getString( PKG, "TableExists.Error.RunningJobEntry", dbe.getMessage() ) ); } finally { if ( db != null ) { try { db.disconnect(); } catch ( Exception e ) { /* Ignore */ } } } } else { result.setNrErrors( 1 ); logError( BaseMessages.getString( PKG, "TableExists.Error.NoConnectionDefined" ) ); } return result; }
Example 4
Source File: MissingEntry.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public Result execute( Result previousResult, int nr ) throws KettleJobException { previousResult.setResult( false ); previousResult.setNrErrors( previousResult.getNrErrors() + 1 ); getLogChannel().logError( BaseMessages.getString( MissingEntry.class, "MissingEntry.Log.CannotRunJob" ) ); return previousResult; }
Example 5
Source File: SlaveServerTransStatus.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public Result getResult( TransMeta transMeta ) { Result result = new Result(); for ( StepStatus stepStatus : stepStatusList ) { result.setNrErrors( result.getNrErrors() + stepStatus.getErrors() + ( result.isStopped() ? 1 : 0 ) ); // If the // remote // trans is // stopped, // count as // an error if ( stepStatus.getStepname().equals( transMeta.getTransLogTable().getStepnameRead() ) ) { result.increaseLinesRead( stepStatus.getLinesRead() ); } if ( stepStatus.getStepname().equals( transMeta.getTransLogTable().getStepnameInput() ) ) { result.increaseLinesInput( stepStatus.getLinesInput() ); } if ( stepStatus.getStepname().equals( transMeta.getTransLogTable().getStepnameWritten() ) ) { result.increaseLinesWritten( stepStatus.getLinesWritten() ); } if ( stepStatus.getStepname().equals( transMeta.getTransLogTable().getStepnameOutput() ) ) { result.increaseLinesOutput( stepStatus.getLinesOutput() ); } if ( stepStatus.getStepname().equals( transMeta.getTransLogTable().getStepnameUpdated() ) ) { result.increaseLinesUpdated( stepStatus.getLinesUpdated() ); } if ( stepStatus.getStepname().equals( transMeta.getTransLogTable().getStepnameRejected() ) ) { result.increaseLinesRejected( stepStatus.getLinesRejected() ); } if ( stepStatus.isStopped() ) { result.setStopped( true ); result.setResult( false ); } } return result; }
Example 6
Source File: PaloCubeCreate.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public Result execute( Result prevResult, int nr ) throws KettleException { Result result = new Result( nr ); result.setResult( false ); logDetailed( toString(), "Start of processing" ); // String substitution.. String realCubeName = environmentSubstitute( getCubeName() ); PaloHelper database = new PaloHelper( this.getDatabaseMeta(), getLogLevel() ); try { database.connect(); database.createCube( realCubeName, dimensionNames.toArray( new String[dimensionNames.size()] ) ); result.setResult( true ); result.setNrLinesOutput( 1 ); } catch ( Exception e ) { result.setNrErrors( 1 ); e.printStackTrace(); logError( toString(), "Error processing Palo Cube Create : " + e.getMessage() ); } finally { database.disconnect(); } return result; }
Example 7
Source File: JobEntryDeleteResultFilenames.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public Result execute( Result previousResult, int nr ) { Result result = previousResult; result.setResult( false ); if ( previousResult != null ) { try { int size = previousResult.getResultFiles().size(); if ( log.isBasic() ) { logBasic( BaseMessages.getString( PKG, "JobEntryDeleteResultFilenames.log.FilesFound", "" + size ) ); } if ( !specifywildcard ) { // Delete all files previousResult.getResultFiles().clear(); if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryDeleteResultFilenames.log.DeletedFiles", "" + size ) ); } } else { List<ResultFile> resultFiles = result.getResultFilesList(); if ( resultFiles != null && resultFiles.size() > 0 ) { for ( Iterator<ResultFile> it = resultFiles.iterator(); it.hasNext() && !parentJob.isStopped(); ) { ResultFile resultFile = it.next(); FileObject file = resultFile.getFile(); if ( file != null && file.exists() ) { if ( CheckFileWildcard( file.getName().getBaseName(), environmentSubstitute( wildcard ), true ) && !CheckFileWildcard( file.getName().getBaseName(), environmentSubstitute( wildcardexclude ), false ) ) { // Remove file from result files list result.getResultFiles().remove( resultFile.getFile().toString() ); if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryDeleteResultFilenames.log.DeletedFile", file.toString() ) ); } } } } } } result.setResult( true ); } catch ( Exception e ) { logError( BaseMessages.getString( PKG, "JobEntryDeleteResultFilenames.Error", e.toString() ) ); } } return result; }
Example 8
Source File: JobEntryFilesExist.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( 0 ); int missingfiles = 0; int nrErrors = 0; // see PDI-10270 for details boolean oldBehavior = "Y".equalsIgnoreCase( getVariable( Const.KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES, "N" ) ); if ( arguments != null ) { for ( int i = 0; i < arguments.length && !parentJob.isStopped(); i++ ) { FileObject file = null; try { String realFilefoldername = environmentSubstitute( arguments[i] ); //Set Embedded NamedCluter MetatStore Provider Key so that it can be passed to VFS if ( parentJobMeta.getNamedClusterEmbedManager() != null ) { parentJobMeta.getNamedClusterEmbedManager() .passEmbeddedMetastoreKey( this, parentJobMeta.getEmbeddedMetastoreProviderKey() ); } file = KettleVFS.getFileObject( realFilefoldername, this ); if ( file.exists() && file.isReadable() ) { // TODO: is it needed to check file for readability? if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFilesExist.File_Exists", realFilefoldername ) ); } } else { missingfiles++; if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFilesExist.File_Does_Not_Exist", realFilefoldername ) ); } } } catch ( Exception e ) { nrErrors++; missingfiles++; logError( BaseMessages.getString( PKG, "JobEntryFilesExist.ERROR_0004_IO_Exception", e.toString() ), e ); } finally { if ( file != null ) { try { file.close(); file = null; } catch ( IOException ex ) { /* Ignore */ } } } } } result.setNrErrors( nrErrors ); if ( oldBehavior ) { result.setNrErrors( missingfiles ); } if ( missingfiles == 0 ) { result.setResult( true ); } return result; }
Example 9
Source File: JobEntryDeleteFiles.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public Result execute( Result result, int nr ) throws KettleException { List<RowMetaAndData> resultRows = result.getRows(); int numberOfErrFiles = 0; result.setResult( false ); result.setNrErrors( 1 ); if ( argFromPrevious && log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryDeleteFiles.FoundPreviousRows", String .valueOf( ( resultRows != null ? resultRows.size() : 0 ) ) ) ); } //Set Embedded NamedCluter MetatStore Provider Key so that it can be passed to VFS if ( parentJobMeta.getNamedClusterEmbedManager() != null ) { parentJobMeta.getNamedClusterEmbedManager() .passEmbeddedMetastoreKey( this, parentJobMeta.getEmbeddedMetastoreProviderKey() ); } Multimap<String, String> pathToMaskMap = populateDataForJobExecution( resultRows ); for ( Map.Entry<String, String> pathToMask : pathToMaskMap.entries() ) { final String filePath = environmentSubstitute( pathToMask.getKey() ); if ( filePath.trim().isEmpty() ) { // Relative paths are permitted, and providing an empty path means deleting all files inside a root pdi-folder. // It is much more likely to be a mistake than a desirable action, so we don't delete anything (see PDI-15181) if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryDeleteFiles.NoPathProvided" ) ); } } else { final String fileMask = environmentSubstitute( pathToMask.getValue() ); if ( parentJob.isStopped() ) { break; } if ( !processFile( filePath, fileMask, parentJob ) ) { numberOfErrFiles++; } } } if ( numberOfErrFiles == 0 ) { result.setResult( true ); result.setNrErrors( 0 ); } else { result.setNrErrors( numberOfErrFiles ); result.setResult( false ); } return result; }
Example 10
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; }
Example 11
Source File: JobEntryDelay.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * Execute this job entry and return the result. In this case it means, just set the result boolean in the Result * class. * * @param previousResult * The result of the previous execution * @return The Result of the execution. */ @Override public Result execute( Result previousResult, int nr ) { Result result = previousResult; result.setResult( false ); int Multiple; String Waitscale; // Scale time switch ( scaleTime ) { case 0: // Second Multiple = 1000; Waitscale = BaseMessages.getString( PKG, "JobEntryDelay.SScaleTime.Label" ); break; case 1: // Minute Multiple = 60000; Waitscale = BaseMessages.getString( PKG, "JobEntryDelay.MnScaleTime.Label" ); break; default: // Hour Multiple = 3600000; Waitscale = BaseMessages.getString( PKG, "JobEntryDelay.HrScaleTime.Label" ); break; } try { // starttime (in seconds ,Minutes or Hours) double timeStart = (double) System.currentTimeMillis() / (double) Multiple; double iMaximumTimeout = Const.toInt( getRealMaximumTimeout(), Const.toInt( DEFAULT_MAXIMUM_TIMEOUT, 0 ) ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryDelay.LetsWaitFor.Label", iMaximumTimeout, Waitscale ) ); } boolean continueLoop = true; // // Sanity check on some values, and complain on insanity // if ( iMaximumTimeout < 0 ) { iMaximumTimeout = Const.toInt( DEFAULT_MAXIMUM_TIMEOUT, 0 ); logBasic( BaseMessages.getString( PKG, "JobEntryDelay.MaximumTimeReset.Label", String .valueOf( iMaximumTimeout ), String.valueOf( Waitscale ) ) ); } // Loop until the delay time has expired. // while ( continueLoop && !parentJob.isStopped() ) { // Update Time value double now = (double) System.currentTimeMillis() / (double) Multiple; // Let's check the limit time if ( ( iMaximumTimeout >= 0 ) && ( now >= ( timeStart + iMaximumTimeout ) ) ) { // We have reached the time limit if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryDelay.WaitTimeIsElapsed.Label" ) ); } continueLoop = false; result.setResult( true ); } else { Thread.sleep( 100 ); } } } catch ( Exception e ) { // We get an exception result.setResult( false ); logError( "Error : " + e.getMessage() ); if ( Thread.currentThread().isInterrupted() ) { Thread.currentThread().interrupt(); } } return result; }
Example 12
Source File: JobEntryTruncateTables.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( true ); nrErrors = 0; continueProcess = true; nrSuccess = 0; if ( argFromPrevious ) { if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryTruncateTables.FoundPreviousRows", String .valueOf( ( rows != null ? rows.size() : 0 ) ) ) ); } if ( rows.size() == 0 ) { return result; } } if ( connection != null ) { Database db = new Database( this, connection ); db.shareVariablesWith( this ); try { db.connect( parentJob.getTransactionId(), null ); if ( argFromPrevious && rows != null ) { // Copy the input row to the (command line) arguments for ( int iteration = 0; iteration < rows.size() && !parentJob.isStopped() && continueProcess; iteration++ ) { resultRow = rows.get( iteration ); // Get values from previous result String tablename_previous = resultRow.getString( 0, null ); String schemaname_previous = resultRow.getString( 1, null ); if ( !Utils.isEmpty( tablename_previous ) ) { if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryTruncateTables.ProcessingRow", tablename_previous, schemaname_previous ) ); } // let's truncate table if ( truncateTables( tablename_previous, schemaname_previous, db ) ) { updateSuccess(); } else { updateErrors(); } } else { logError( BaseMessages.getString( PKG, "JobEntryTruncateTables.RowEmpty" ) ); } } } else if ( arguments != null ) { for ( int i = 0; i < arguments.length && !parentJob.isStopped() && continueProcess; i++ ) { String realTablename = environmentSubstitute( arguments[i] ); String realSchemaname = environmentSubstitute( schemaname[i] ); if ( !Utils.isEmpty( realTablename ) ) { if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryTruncateTables.ProcessingArg", arguments[i], schemaname[i] ) ); } // let's truncate table if ( truncateTables( realTablename, realSchemaname, db ) ) { updateSuccess(); } else { updateErrors(); } } else { logError( BaseMessages.getString( PKG, "JobEntryTruncateTables.ArgEmpty", arguments[i], schemaname[i] ) ); } } } } catch ( Exception dbe ) { result.setNrErrors( 1 ); logError( BaseMessages.getString( PKG, "JobEntryTruncateTables.Error.RunningEntry", dbe.getMessage() ) ); } finally { if ( db != null ) { db.disconnect(); } } } else { result.setNrErrors( 1 ); logError( BaseMessages.getString( PKG, "JobEntryTruncateTables.NoDbConnection" ) ); } result.setNrErrors( nrErrors ); result.setNrLinesDeleted( nrSuccess ); result.setResult( nrErrors == 0 ); return result; }
Example 13
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 14
Source File: JobEntryConnectedToRepository.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * Execute this job entry and return the result. In this case it means, just set the result boolean in the Result * class. * * @param previousResult * The result of the previous execution * @return The Result of the execution. */ public Result execute( Result previousResult, int nr ) { Result result = previousResult; result.setNrErrors( 1 ); result.setResult( false ); if ( rep == null ) { logError( BaseMessages.getString( PKG, "JobEntryConnectedToRepository.Log.NotConnected" ) ); return result; } if ( isspecificrep ) { if ( Utils.isEmpty( repname ) ) { logError( BaseMessages.getString( PKG, "JobEntryConnectedToRepository.Error.NoRep" ) ); return result; } String Reponame = environmentSubstitute( repname ); if ( !Reponame.equals( rep.getName() ) ) { logError( BaseMessages.getString( PKG, "JobEntryConnectedToRepository.Error.DiffRep", rep.getName(), Reponame ) ); return result; } } if ( isspecificuser ) { if ( Utils.isEmpty( username ) ) { logError( BaseMessages.getString( PKG, "JobEntryConnectedToRepository.Error.NoUser" ) ); return result; } String realUsername = environmentSubstitute( username ); if ( rep.getUserInfo() != null && !realUsername.equals( rep.getUserInfo().getLogin() ) ) { logError( BaseMessages.getString( PKG, "JobEntryConnectedToRepository.Error.DiffUser", rep .getUserInfo().getLogin(), realUsername ) ); return result; } } if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryConnectedToRepository.Log.Connected", rep.getName(), rep .getUserInfo() != null ? rep.getUserInfo().getLogin() : "" ) ); } result.setResult( true ); result.setNrErrors( 0 ); return result; }
Example 15
Source File: JobEntryPing.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 ); String hostname = getRealHostname(); int timeoutInt = Const.toInt( getRealTimeOut(), 300 ); int packets = Const.toInt( getRealNbrPackets(), 2 ); boolean status = false; if ( Utils.isEmpty( hostname ) ) { // No Host was specified logError( BaseMessages.getString( PKG, "JobPing.SpecifyHost.Label" ) ); return result; } try { if ( ipingtype == isystemPing || ipingtype == ibothPings ) { // Perform a system (Java) ping ... status = systemPing( hostname, timeoutInt ); if ( status ) { if ( log.isDetailed() ) { log.logDetailed( BaseMessages.getString( PKG, "JobPing.SystemPing" ), BaseMessages.getString( PKG, "JobPing.OK.Label", hostname ) ); } } else { log.logError( BaseMessages.getString( PKG, "JobPing.SystemPing" ), BaseMessages.getString( PKG, "JobPing.NOK.Label", hostname ) ); } } if ( ( ipingtype == iclassicPing ) || ( ipingtype == ibothPings && !status ) ) { // Perform a classic ping .. status = classicPing( hostname, packets ); if ( status ) { if ( log.isDetailed() ) { log.logDetailed( BaseMessages.getString( PKG, "JobPing.ClassicPing" ), BaseMessages.getString( PKG, "JobPing.OK.Label", hostname ) ); } } else { log.logError( BaseMessages.getString( PKG, "JobPing.ClassicPing" ), BaseMessages.getString( PKG, "JobPing.NOK.Label", hostname ) ); } } } catch ( Exception ex ) { logError( BaseMessages.getString( PKG, "JobPing.Error.Label" ) + ex.getMessage() ); } if ( status ) { if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobPing.OK.Label", hostname ) ); } result.setNrErrors( 0 ); result.setResult( true ); } else { logError( BaseMessages.getString( PKG, "JobPing.NOK.Label", hostname ) ); } return result; }
Example 16
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 17
Source File: JobEntrySendNagiosPassiveCheck.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public Result execute( Result previousResult, int nr ) { log.logBasic( BaseMessages.getString( PKG, "JobEntrySendNagiosPassiveCheck.Started", serverName ) ); Result result = previousResult; result.setNrErrors( 1 ); result.setResult( false ); // Target String realServername = environmentSubstitute( serverName ); String realPassword = Utils.resolvePassword( variables, password ); int realPort = Const.toInt( environmentSubstitute( port ), DEFAULT_PORT ); int realResponseTimeOut = Const.toInt( environmentSubstitute( responseTimeOut ), DEFAULT_RESPONSE_TIME_OUT ); int realConnectionTimeOut = Const.toInt( environmentSubstitute( connectionTimeOut ), DEFAULT_CONNECTION_TIME_OUT ); // Sender String realSenderServerName = environmentSubstitute( senderServerName ); String realSenderServiceName = environmentSubstitute( senderServiceName ); try { if ( Utils.isEmpty( realServername ) ) { throw new KettleException( BaseMessages.getString( PKG, "JobSendNagiosPassiveCheck.Error.TargetServerMissing" ) ); } String realMessageString = environmentSubstitute( message ); if ( Utils.isEmpty( realMessageString ) ) { throw new KettleException( BaseMessages.getString( PKG, "JobSendNagiosPassiveCheck.Error.MessageMissing" ) ); } Level level = Level.UNKNOWN; switch ( getLevel() ) { case LEVEL_TYPE_OK: level = Level.OK; break; case LEVEL_TYPE_CRITICAL: level = Level.CRITICAL; break; case LEVEL_TYPE_WARNING: level = Level.WARNING; break; default: break; } Encryption encr = Encryption.NONE; switch ( getEncryptionMode() ) { case ENCRYPTION_MODE_TRIPLEDES: encr = Encryption.TRIPLE_DES; break; case ENCRYPTION_MODE_XOR: encr = Encryption.XOR; break; default: break; } // settings NagiosSettingsBuilder ns = new NagiosSettingsBuilder(); ns.withNagiosHost( realServername ); ns.withPort( realPort ); ns.withConnectionTimeout( realConnectionTimeOut ); ns.withResponseTimeout( realResponseTimeOut ); ns.withEncryption( encr ); if ( !Utils.isEmpty( realPassword ) ) { ns.withPassword( realPassword ); } else { ns.withNoPassword(); } // target nagios host NagiosSettings settings = ns.create(); // sender MessagePayloadBuilder pb = new MessagePayloadBuilder(); if ( !Utils.isEmpty( realSenderServerName ) ) { pb.withHostname( realSenderServerName ); } pb.withLevel( level ); if ( !Utils.isEmpty( realSenderServiceName ) ) { pb.withServiceName( realSenderServiceName ); } pb.withMessage( realMessageString ); MessagePayload payload = pb.create(); NagiosPassiveCheckSender sender = new NagiosPassiveCheckSender( settings ); sender.send( payload ); result.setNrErrors( 0 ); result.setResult( true ); } catch ( Exception e ) { log.logError( BaseMessages.getString( PKG, "JobEntrySendNagiosPassiveCheck.ErrorGetting", e.toString() ) ); } return result; }
Example 18
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 19
Source File: JobEntryWriteToLog.java From pentaho-kettle with Apache License 2.0 | 2 votes |
/** * Execute this job entry and return the result. In this case it means, just set the result boolean in the Result * class. * * @param prev_result * The result of the previous execution * @return The Result of the execution. */ @Override public Result execute( Result prev_result, int nr ) { prev_result.setResult( evaluate( prev_result ) ); return prev_result; }
Example 20
Source File: JobEntryMsgBoxInfo.java From pentaho-kettle with Apache License 2.0 | 2 votes |
/** * Execute this job entry and return the result. In this case it means, just set the result boolean in the Result * class. * * @param prev_result * The result of the previous execution * @return The Result of the execution. */ public Result execute( Result prev_result, int nr ) { prev_result.setResult( evaluate( prev_result ) ); return prev_result; }