Java Code Examples for org.pentaho.di.trans.TransMeta#getTransLogTable()
The following examples show how to use
org.pentaho.di.trans.TransMeta#getTransLogTable() .
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: PentahoMapReduceJobBuilderImpl.java From pentaho-hadoop-shims with Apache License 2.0 | 5 votes |
private void deleteLogging( Optional<TransConfiguration> transConfiguration ) { if ( !transConfiguration.isPresent() ) { return; } TransMeta meta = transConfiguration.get().getTransMeta(); if ( meta == null ) { return; } BaseLogTable table = meta.getStepLogTable(); table.setConnectionName( null ); meta.setStepLogTable( (StepLogTable) table ); table = meta.getMetricsLogTable(); table.setConnectionName( null ); meta.setMetricsLogTable( (MetricsLogTable) table ); table = meta.getPerformanceLogTable(); table.setConnectionName( null ); meta.setPerformanceLogTable( (PerformanceLogTable) table ); table = meta.getTransLogTable(); table.setConnectionName( null ); meta.setTransLogTable( (TransLogTable) table ); table = meta.getChannelLogTable(); table.setConnectionName( null ); meta.setChannelLogTable( (ChannelLogTable) table ); }
Example 2
Source File: XmlExportHelper.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * When exporting meta we should not export user global parameters. * Method makes clone for each table and deletes all global parameters. * We have to make clones of each table, because we don't want to change real tables content. * * @param transMeta * meta, that contains log tables to be refactored before export */ public static void swapTables( TransMeta transMeta ) { TransLogTable transLogTable = transMeta.getTransLogTable(); if ( transLogTable != null ) { TransLogTable cloneTransLogTable = (TransLogTable) transLogTable.clone(); cloneTransLogTable.setAllGlobalParametersToNull(); transMeta.setTransLogTable( cloneTransLogTable ); } StepLogTable stepLogTable = transMeta.getStepLogTable(); if ( stepLogTable != null ) { StepLogTable cloneStepLogTable = (StepLogTable) stepLogTable.clone(); cloneStepLogTable.setAllGlobalParametersToNull(); transMeta.setStepLogTable( cloneStepLogTable ); } PerformanceLogTable performanceLogTable = transMeta.getPerformanceLogTable(); if ( performanceLogTable != null ) { PerformanceLogTable clonePerformanceLogTable = (PerformanceLogTable) performanceLogTable.clone(); clonePerformanceLogTable.setAllGlobalParametersToNull(); transMeta.setPerformanceLogTable( clonePerformanceLogTable ); } ChannelLogTable channelLogTable = transMeta.getChannelLogTable(); if ( channelLogTable != null ) { ChannelLogTable cloneChannelLogTable = (ChannelLogTable) channelLogTable.clone(); cloneChannelLogTable.setAllGlobalParametersToNull(); transMeta.setChannelLogTable( cloneChannelLogTable ); } MetricsLogTable metricsLogTable = transMeta.getMetricsLogTable(); if ( metricsLogTable != null ) { MetricsLogTable cloneMetricsLogTable = (MetricsLogTable) metricsLogTable.clone(); cloneMetricsLogTable.setAllGlobalParametersToNull(); transMeta.setMetricsLogTable( cloneMetricsLogTable ); } }
Example 3
Source File: SpoonExportXmlTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test public void savingTransToXmlNotChangesLogTables() { TransMeta transMeta = new TransMeta(); initTables( transMeta ); TransLogTable originTransLogTable = transMeta.getTransLogTable(); StepLogTable originStepLogTable = transMeta.getStepLogTable(); PerformanceLogTable originPerformanceLogTable = transMeta.getPerformanceLogTable(); ChannelLogTable originChannelLogTable = transMeta.getChannelLogTable(); MetricsLogTable originMetricsLogTable = transMeta.getMetricsLogTable(); when( spoon.getActiveTransformation() ).thenReturn( transMeta ); when( spoon.saveXMLFile( any( TransMeta.class ), anyBoolean() ) ).thenReturn( true ); when( spoon.saveXMLFile( anyBoolean() ) ).thenCallRealMethod(); spoon.saveXMLFile( true ); tablesCommonValuesEqual( originTransLogTable, transMeta.getTransLogTable() ); assertEquals( originTransLogTable.getLogInterval(), transMeta.getTransLogTable().getLogInterval() ); assertEquals( originTransLogTable.getLogSizeLimit(), transMeta.getTransLogTable().getLogSizeLimit() ); tablesCommonValuesEqual( originStepLogTable, transMeta.getStepLogTable() ); tablesCommonValuesEqual( originPerformanceLogTable, transMeta.getPerformanceLogTable() ); assertEquals( originPerformanceLogTable.getLogInterval(), transMeta.getPerformanceLogTable().getLogInterval() ); tablesCommonValuesEqual( originChannelLogTable, transMeta.getChannelLogTable() ); tablesCommonValuesEqual( originMetricsLogTable, transMeta.getMetricsLogTable() ); }
Example 4
Source File: TransformationHasTransLogConfiguredImportRuleIT.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public void testRule() throws Exception { TransMeta transMeta = new TransMeta(); DatabaseMeta logDbMeta = new DatabaseMeta( "LOGDB", "MYSQL", "JDBC", "localhost", "test", "3306", "foo", "bar" ); transMeta.addDatabase( logDbMeta ); TransLogTable logTable = transMeta.getTransLogTable(); PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.findPluginWithId( ImportRulePluginType.class, "TransformationHasTransLogConfigured" ); assertNotNull( "The 'transformation has trans log table configured' rule could not be found in the plugin registry!", plugin ); TransformationHasTransLogConfiguredImportRule rule = (TransformationHasTransLogConfiguredImportRule) registry.loadClass( plugin ); assertNotNull( "The 'transformation has trans log table configured' class could not be loaded by the plugin registry!", plugin ); rule.setEnabled( true ); List<ImportValidationFeedback> feedback = rule.verifyRule( transMeta ); assertTrue( "We didn't get any feedback from the 'transformation has trans log table configured'", !feedback .isEmpty() ); assertTrue( "An error ruling was expected", feedback.get( 0 ).getResultType() == ImportValidationResultType.ERROR ); logTable.setTableName( "SCHEMA" ); logTable.setTableName( "LOGTABLE" ); logTable.setConnectionName( logDbMeta.getName() ); feedback = rule.verifyRule( transMeta ); assertTrue( "We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty() ); assertTrue( "An approval ruling was expected", feedback.get( 0 ).getResultType() == ImportValidationResultType.APPROVAL ); // Make the rules stricter! // rule.setTableName( "SCHEMA" ); rule.setTableName( "LOGTABLE" ); rule.setConnectionName( logDbMeta.getName() ); feedback = rule.verifyRule( transMeta ); assertTrue( "We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty() ); assertTrue( "An approval ruling was expected", feedback.get( 0 ).getResultType() == ImportValidationResultType.APPROVAL ); // Break the rule // rule.setSchemaName( "INCORRECT_SCHEMA" ); rule.setTableName( "LOGTABLE" ); rule.setConnectionName( logDbMeta.getName() ); feedback = rule.verifyRule( transMeta ); assertTrue( "We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty() ); assertTrue( "An error ruling was expected", feedback.get( 0 ).getResultType() == ImportValidationResultType.ERROR ); rule.setSchemaName( "SCHEMA" ); rule.setTableName( "INCORRECT_LOGTABLE" ); rule.setConnectionName( logDbMeta.getName() ); feedback = rule.verifyRule( transMeta ); assertTrue( "We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty() ); assertTrue( "An error ruling was expected", feedback.get( 0 ).getResultType() == ImportValidationResultType.ERROR ); rule.setSchemaName( "SCHEMA" ); rule.setTableName( "LOGTABLE" ); rule.setConnectionName( "INCORRECT_DATABASE" ); feedback = rule.verifyRule( transMeta ); assertTrue( "We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty() ); assertTrue( "An error ruling was expected", feedback.get( 0 ).getResultType() == ImportValidationResultType.ERROR ); // No feedback expected! // rule.setEnabled( false ); feedback = rule.verifyRule( transMeta ); assertTrue( "We didn't expect any feedback from the 'transformation has trans " + "log table configured' since the rule is not enabled", feedback.isEmpty() ); }
Example 5
Source File: TransformationHasTransLogConfiguredImportRule.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Override public List<ImportValidationFeedback> verifyRule( Object subject ) { List<ImportValidationFeedback> feedback = new ArrayList<ImportValidationFeedback>(); if ( !isEnabled() ) { return feedback; } if ( !( subject instanceof TransMeta ) ) { return feedback; } TransMeta transMeta = (TransMeta) subject; TransLogTable transLogTable = transMeta.getTransLogTable(); if ( !transLogTable.isDefined() ) { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.ERROR, "The logging table is not defined" ) ); } else { if ( !Utils.isEmpty( schemaName ) ) { if ( schemaName.equals( transLogTable.getSchemaName() ) ) { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.APPROVAL, "The schema name is set to: " + schemaName ) ); } else { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.ERROR, "The schema name is not set to: " + schemaName ) ); } } if ( !Utils.isEmpty( tableName ) ) { if ( tableName.equals( transLogTable.getTableName() ) ) { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.APPROVAL, "The table name is set to: " + tableName ) ); } else { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.ERROR, "The table name is not set to: " + tableName ) ); } } if ( !Utils.isEmpty( connectionName ) ) { if ( connectionName.equals( transLogTable.getDatabaseMeta().getName() ) ) { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.APPROVAL, "The database connection used for logging is: " + connectionName ) ); } else { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.ERROR, "The database connection used for logging is not: " + connectionName ) ); } } if ( feedback.isEmpty() ) { feedback.add( new ImportValidationFeedback( this, ImportValidationResultType.APPROVAL, "The logging table is correctly defined" ) ); } } return feedback; }
Example 6
Source File: KettleFileTableModel.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public static String getLastExecutionResult( LogChannelInterface log, LoggingObjectInterface parentObject, ReportSubjectLocation filename ) throws KettleException { LogTableInterface logTable = null; if ( filename.isTransformation() ) { TransMeta transMeta = TransformationInformation.getInstance().getTransMeta( filename ); logTable = transMeta.getTransLogTable(); } else { JobMeta jobMeta = JobInformation.getInstance().getJobMeta( filename ); logTable = jobMeta.getJobLogTable(); } if ( logTable != null && logTable.isDefined() ) { DatabaseMeta dbMeta = logTable.getDatabaseMeta(); Database database = new Database( parentObject, dbMeta ); try { database.connect(); String sql = "SELECT "; sql += dbMeta.quoteField( logTable.getStatusField().getFieldName() ) + ", "; sql += dbMeta.quoteField( logTable.getLogDateField().getFieldName() ) + ", "; sql += dbMeta.quoteField( logTable.getErrorsField().getFieldName() ) + ""; sql += " FROM "; sql += dbMeta.getQuotedSchemaTableCombination( logTable.getSchemaName(), logTable.getTableName() ); sql += " ORDER BY " + dbMeta.quoteField( logTable.getLogDateField().getFieldName() ) + " DESC"; RowMetaAndData oneRow = database.getOneRow( sql ); String status = oneRow.getString( 0, "?" ); Date date = oneRow.getDate( 1, null ); Long nrErrors = oneRow.getInteger( 2 ); String evaluation; if ( status.equalsIgnoreCase( LogStatus.END.getStatus() ) ) { evaluation = "Ended"; } else if ( status.equalsIgnoreCase( LogStatus.START.getStatus() ) ) { evaluation = "Started"; } else if ( status.equalsIgnoreCase( LogStatus.STOP.getStatus() ) ) { evaluation = "Stopped"; } else if ( status.equalsIgnoreCase( LogStatus.RUNNING.getStatus() ) ) { evaluation = "Running"; } else if ( status.equalsIgnoreCase( LogStatus.PAUSED.getStatus() ) ) { evaluation = "Paused"; } else if ( status.equalsIgnoreCase( LogStatus.ERROR.getStatus() ) ) { evaluation = "Failed"; } else { evaluation = "Unknown"; } if ( nrErrors > 0 ) { evaluation += " with errors"; } else { evaluation += " with success"; } return evaluation + " at " + XMLHandler.date2string( date ); } catch ( Exception e ) { log.logBasic( "Unable to get logging information from log table" + logTable ); } finally { database.disconnect(); } } return null; }