@Test @SuppressWarnings( "ResultOfMethodCallIgnored" ) public void testSetParamsIntoMetaInExecuteTransformation() throws KettleException { doCallRealMethod().when( delegate ).executeTransformation( transMeta, true, false, false, false, false, null, false, LogLevel.BASIC ); RowMetaInterface rowMeta = mock( RowMetaInterface.class ); TransExecutionConfiguration transExecutionConfiguration = mock( TransExecutionConfiguration.class ); TransGraph activeTransGraph = mock( TransGraph.class ); activeTransGraph.transLogDelegate = mock( TransLogDelegate.class ); doReturn( rowMeta ).when( spoon.variables ).getRowMeta(); doReturn( EMPTY_STRING_ARRAY ).when( rowMeta ).getFieldNames(); doReturn( transExecutionConfiguration ).when( spoon ).getTransExecutionConfiguration(); doReturn( MAP_WITH_TEST_PARAM ).when( transExecutionConfiguration ).getParams(); doReturn( activeTransGraph ).when( spoon ).getActiveTransGraph(); doReturn( TEST_LOG_LEVEL ).when( transExecutionConfiguration ).getLogLevel(); doReturn( TEST_BOOLEAN_PARAM ).when( transExecutionConfiguration ).isClearingLog(); doReturn( TEST_BOOLEAN_PARAM ).when( transExecutionConfiguration ).isSafeModeEnabled(); doReturn( TEST_BOOLEAN_PARAM ).when( transExecutionConfiguration ).isGatheringMetrics(); delegate.executeTransformation( transMeta, true, false, false, false, false, null, false, LogLevel.BASIC ); verify( transMeta ).setParameterValue( TEST_PARAM_KEY, TEST_PARAM_VALUE ); verify( transMeta ).activateParameters(); verify( transMeta ).setLogLevel( TEST_LOG_LEVEL ); verify( transMeta ).setClearingLog( TEST_BOOLEAN_PARAM ); verify( transMeta ).setSafeModeEnabled( TEST_BOOLEAN_PARAM ); verify( transMeta ).setGatheringMetrics( TEST_BOOLEAN_PARAM ); }
public void executeTransformation( final TransMeta transMeta, final boolean local, final boolean remote, final boolean cluster, final boolean preview, final boolean debug, final Date replayDate, final boolean safe, LogLevel logLevel ) throws KettleException { if ( transMeta == null ) { return; } TransDebugMeta transDebugMeta = null; TransExecutionConfiguration executionConfiguration = null; if ( preview ) { executionConfiguration = spoon.getTransPreviewExecutionConfiguration(); } else if ( debug ) { executionConfiguration = spoon.getTransDebugExecutionConfiguration(); } else { executionConfiguration = spoon.getTransExecutionConfiguration(); } executionConfiguration.setExecutingLocally( true ); executionConfiguration.setExecutingRemotely( false ); executionConfiguration.setExecutingClustered( false ); transMeta.setRepository( spoon.rep ); transMeta.setMetaStore( spoon.metaStore ); executionConfiguration.setRepository( spoon.rep ); executionConfiguration.setSafeModeEnabled( safe ); if ( debug ) { transDebugMeta = transDebugMetaMap.get( transMeta ); if ( transDebugMeta == null ) { transDebugMeta = new TransDebugMeta( transMeta ); transDebugMetaMap.put( transMeta, transDebugMeta ); } List<StepMeta> selectedSteps = transMeta.getSelectedSteps(); if ( selectedSteps != null && selectedSteps.size() > 0 ) { transDebugMeta.getStepDebugMetaMap().clear(); for ( StepMeta stepMeta : transMeta.getSelectedSteps() ) { StepDebugMeta stepDebugMeta = new StepDebugMeta( stepMeta ); stepDebugMeta.setRowCount( PropsUI.getInstance().getDefaultPreviewSize() ); stepDebugMeta.setPausingOnBreakPoint( true ); stepDebugMeta.setReadingFirstRows( false ); transDebugMeta.getStepDebugMetaMap().put( stepMeta, stepDebugMeta ); } } } else if ( preview ) { transDebugMeta = transPreviewMetaMap.get( transMeta ); if ( transDebugMeta == null ) { transDebugMeta = new TransDebugMeta( transMeta ); transPreviewMetaMap.put( transMeta, transDebugMeta ); } List<StepMeta> selectedSteps = transMeta.getSelectedSteps(); if ( selectedSteps != null && selectedSteps.size() > 0 ) { transDebugMeta.getStepDebugMetaMap().clear(); for ( StepMeta stepMeta : transMeta.getSelectedSteps() ) { StepDebugMeta stepDebugMeta = new StepDebugMeta( stepMeta ); stepDebugMeta.setRowCount( PropsUI.getInstance().getDefaultPreviewSize() ); stepDebugMeta.setPausingOnBreakPoint( false ); stepDebugMeta.setReadingFirstRows( true ); transDebugMeta.getStepDebugMetaMap().put( stepMeta, stepDebugMeta ); } } } int debugAnswer = TransDebugDialog.DEBUG_CONFIG; if ( debug || preview ) { transDebugMeta.getTransMeta().setRepository( spoon.rep ); TransDebugDialog transDebugDialog = new TransDebugDialog( spoon.getShell(), transDebugMeta ); debugAnswer = transDebugDialog.open(); if ( debugAnswer != TransDebugDialog.DEBUG_CANCEL ) { executionConfiguration.setExecutingLocally( true ); executionConfiguration.setExecutingRemotely( false ); executionConfiguration.setExecutingClustered( false ); } else { return; } } Object[] data = spoon.variables.getData(); String[] fields = spoon.variables.getRowMeta().getFieldNames(); Map<String, String> variableMap = new HashMap<String, String>(); variableMap.putAll( executionConfiguration.getVariables() ); for ( int idx = 0; idx < fields.length; idx++ ) { String value = executionConfiguration.getVariables().get( fields[idx] ); if ( Utils.isEmpty( value ) ) { value = data[idx].toString(); } variableMap.put( fields[idx], value ); } executionConfiguration.setVariables( variableMap ); executionConfiguration.getUsedVariables( transMeta ); executionConfiguration.getUsedArguments( transMeta, spoon.getArguments() ); executionConfiguration.setReplayDate( replayDate ); executionConfiguration.setLogLevel( logLevel ); boolean execConfigAnswer = true; if ( debugAnswer == TransDebugDialog.DEBUG_CONFIG && replayDate == null && transMeta.isShowDialog() ) { TransExecutionConfigurationDialog dialog = new TransExecutionConfigurationDialog( spoon.getShell(), executionConfiguration, transMeta ); execConfigAnswer = dialog.open(); } if ( execConfigAnswer ) { TransGraph activeTransGraph = spoon.getActiveTransGraph(); activeTransGraph.transLogDelegate.addTransLog(); Map<String, String> paramMap = executionConfiguration.getParams(); for ( String key : paramMap.keySet() ) { transMeta.setParameterValue( key, Const.NVL( paramMap.get( key ), "" ) ); } transMeta.activateParameters(); if ( executionConfiguration.getLogLevel() != null ) { transMeta.setLogLevel( executionConfiguration.getLogLevel() ); } transMeta.setClearingLog( executionConfiguration.isClearingLog() ); transMeta.setSafeModeEnabled( executionConfiguration.isSafeModeEnabled() ); transMeta.setGatheringMetrics( executionConfiguration.isGatheringMetrics() ); ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonTransMetaExecutionStart.id, transMeta ); ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonTransExecutionConfiguration.id, executionConfiguration ); try { ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonTransBeforeStart.id, new Object[] { executionConfiguration, transMeta, transMeta, spoon.getRepository() } ); } catch ( KettleException e ) { log.logError( e.getMessage(), transMeta.getFilename() ); return; } if ( !executionConfiguration.isExecutingLocally() && !executionConfiguration.isExecutingRemotely() ) { if ( transMeta.hasChanged() ) { activeTransGraph.showSaveFileMessage(); } } if ( debug || preview ) { if ( transDebugMeta.getNrOfUsedSteps() == 0 ) { MessageBox box = new MessageBox( spoon.getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO ); box.setText( BaseMessages.getString( PKG, "Spoon.Dialog.Warning.NoPreviewOrDebugSteps.Title" ) ); box.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.Warning.NoPreviewOrDebugSteps.Message" ) ); int answer = box.open(); if ( answer != SWT.YES ) { return; } } } if ( executionConfiguration.isExecutingLocally() ) { if ( debug || preview ) { activeTransGraph.debug( executionConfiguration, transDebugMeta ); } else { activeTransGraph.start( executionConfiguration ); } } else if ( executionConfiguration.isExecutingRemotely() ) { activeTransGraph.handleTransMetaChanges( transMeta ); if ( transMeta.hasChanged() ) { showSaveTransformationBeforeRunningDialog( spoon.getShell() ); } else if ( executionConfiguration.getRemoteServer() != null ) { String carteObjectId = Trans.sendToSlaveServer( transMeta, executionConfiguration, spoon.rep, spoon.metaStore ); monitorRemoteTrans( transMeta, carteObjectId, executionConfiguration.getRemoteServer() ); spoon.delegates.slaves.addSpoonSlave( executionConfiguration.getRemoteServer() ); } else { MessageBox mb = new MessageBox( spoon.getShell(), SWT.OK | SWT.ICON_INFORMATION ); mb.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.NoRemoteServerSpecified.Message" ) ); mb.setText( BaseMessages.getString( PKG, "Spoon.Dialog.NoRemoteServerSpecified.Title" ) ); mb.open(); } } else if ( executionConfiguration.isExecutingClustered() ) { activeTransGraph.handleTransMetaChanges( transMeta ); if ( transMeta.hasChanged() ) { showSaveTransformationBeforeRunningDialog( spoon.getShell() ); } else { splitTrans( transMeta, executionConfiguration ); } } } }
SpoonTransformationDelegate extends SpoonDelegate { public void executeTransformation( final TransMeta transMeta, final boolean local, final boolean remote, final boolean cluster, final boolean preview, final boolean debug, final Date replayDate, final boolean safe, LogLevel logLevel ) throws KettleException { if ( transMeta == null ) { return; } TransDebugMeta transDebugMeta = null; TransExecutionConfiguration executionConfiguration = null; if ( preview ) { executionConfiguration = spoon.getTransPreviewExecutionConfiguration(); } else if ( debug ) { executionConfiguration = spoon.getTransDebugExecutionConfiguration(); } else { executionConfiguration = spoon.getTransExecutionConfiguration(); } executionConfiguration.setExecutingLocally( true ); executionConfiguration.setExecutingRemotely( false ); executionConfiguration.setExecutingClustered( false ); transMeta.setRepository( spoon.rep ); transMeta.setMetaStore( spoon.metaStore ); executionConfiguration.setRepository( spoon.rep ); executionConfiguration.setSafeModeEnabled( safe ); if ( debug ) { transDebugMeta = transDebugMetaMap.get( transMeta ); if ( transDebugMeta == null ) { transDebugMeta = new TransDebugMeta( transMeta ); transDebugMetaMap.put( transMeta, transDebugMeta ); } List<StepMeta> selectedSteps = transMeta.getSelectedSteps(); if ( selectedSteps != null && selectedSteps.size() > 0 ) { transDebugMeta.getStepDebugMetaMap().clear(); for ( StepMeta stepMeta : transMeta.getSelectedSteps() ) { StepDebugMeta stepDebugMeta = new StepDebugMeta( stepMeta ); stepDebugMeta.setRowCount( PropsUI.getInstance().getDefaultPreviewSize() ); stepDebugMeta.setPausingOnBreakPoint( true ); stepDebugMeta.setReadingFirstRows( false ); transDebugMeta.getStepDebugMetaMap().put( stepMeta, stepDebugMeta ); } } } else if ( preview ) { transDebugMeta = transPreviewMetaMap.get( transMeta ); if ( transDebugMeta == null ) { transDebugMeta = new TransDebugMeta( transMeta ); transPreviewMetaMap.put( transMeta, transDebugMeta ); } List<StepMeta> selectedSteps = transMeta.getSelectedSteps(); if ( selectedSteps != null && selectedSteps.size() > 0 ) { transDebugMeta.getStepDebugMetaMap().clear(); for ( StepMeta stepMeta : transMeta.getSelectedSteps() ) { StepDebugMeta stepDebugMeta = new StepDebugMeta( stepMeta ); stepDebugMeta.setRowCount( PropsUI.getInstance().getDefaultPreviewSize() ); stepDebugMeta.setPausingOnBreakPoint( false ); stepDebugMeta.setReadingFirstRows( true ); transDebugMeta.getStepDebugMetaMap().put( stepMeta, stepDebugMeta ); } } } int debugAnswer = TransDebugDialog.DEBUG_CONFIG; if ( debug || preview ) { transDebugMeta.getTransMeta().setRepository( spoon.rep ); TransDebugDialog transDebugDialog = new TransDebugDialog( spoon.getShell(), transDebugMeta ); debugAnswer = transDebugDialog.open(); if ( debugAnswer != TransDebugDialog.DEBUG_CANCEL ) { executionConfiguration.setExecutingLocally( true ); executionConfiguration.setExecutingRemotely( false ); executionConfiguration.setExecutingClustered( false ); } else { return; } } Object[] data = spoon.variables.getData(); String[] fields = spoon.variables.getRowMeta().getFieldNames(); Map<String, String> variableMap = new HashMap<String, String>(); variableMap.putAll( executionConfiguration.getVariables() ); for ( int idx = 0; idx < fields.length; idx++ ) { String value = executionConfiguration.getVariables().get( fields[idx] ); if ( Utils.isEmpty( value ) ) { value = data[idx].toString(); } variableMap.put( fields[idx], value ); } executionConfiguration.setVariables( variableMap ); executionConfiguration.getUsedVariables( transMeta ); executionConfiguration.getUsedArguments( transMeta, spoon.getArguments() ); executionConfiguration.setReplayDate( replayDate ); executionConfiguration.setLogLevel( logLevel ); boolean execConfigAnswer = true; if ( debugAnswer == TransDebugDialog.DEBUG_CONFIG && replayDate == null && transMeta.isShowDialog() ) { TransExecutionConfigurationDialog dialog = new TransExecutionConfigurationDialog( spoon.getShell(), executionConfiguration, transMeta ); execConfigAnswer = dialog.open(); } if ( execConfigAnswer ) { TransGraph activeTransGraph = spoon.getActiveTransGraph(); activeTransGraph.transLogDelegate.addTransLog(); Map<String, String> paramMap = executionConfiguration.getParams(); for ( String key : paramMap.keySet() ) { transMeta.setParameterValue( key, Const.NVL( paramMap.get( key ), "" ) ); } transMeta.activateParameters(); if ( executionConfiguration.getLogLevel() != null ) { transMeta.setLogLevel( executionConfiguration.getLogLevel() ); } transMeta.setClearingLog( executionConfiguration.isClearingLog() ); transMeta.setSafeModeEnabled( executionConfiguration.isSafeModeEnabled() ); transMeta.setGatheringMetrics( executionConfiguration.isGatheringMetrics() ); ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonTransMetaExecutionStart.id, transMeta ); ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonTransExecutionConfiguration.id, executionConfiguration ); try { ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonTransBeforeStart.id, new Object[] { executionConfiguration, transMeta, transMeta, spoon.getRepository() } ); } catch ( KettleException e ) { log.logError( e.getMessage(), transMeta.getFilename() ); return; } if ( !executionConfiguration.isExecutingLocally() && !executionConfiguration.isExecutingRemotely() ) { if ( transMeta.hasChanged() ) { activeTransGraph.showSaveFileMessage(); } } if ( debug || preview ) { if ( transDebugMeta.getNrOfUsedSteps() == 0 ) { MessageBox box = new MessageBox( spoon.getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO ); box.setText( BaseMessages.getString( PKG, "Spoon.Dialog.Warning.NoPreviewOrDebugSteps.Title" ) ); box.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.Warning.NoPreviewOrDebugSteps.Message" ) ); int answer = box.open(); if ( answer != SWT.YES ) { return; } } } if ( executionConfiguration.isExecutingLocally() ) { if ( debug || preview ) { activeTransGraph.debug( executionConfiguration, transDebugMeta ); } else { activeTransGraph.start( executionConfiguration ); } } else if ( executionConfiguration.isExecutingRemotely() ) { activeTransGraph.handleTransMetaChanges( transMeta ); if ( transMeta.hasChanged() ) { showSaveTransformationBeforeRunningDialog( spoon.getShell() ); } else if ( executionConfiguration.getRemoteServer() != null ) { String carteObjectId = Trans.sendToSlaveServer( transMeta, executionConfiguration, spoon.rep, spoon.metaStore ); monitorRemoteTrans( transMeta, carteObjectId, executionConfiguration.getRemoteServer() ); spoon.delegates.slaves.addSpoonSlave( executionConfiguration.getRemoteServer() ); } else { MessageBox mb = new MessageBox( spoon.getShell(), SWT.OK | SWT.ICON_INFORMATION ); mb.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.NoRemoteServerSpecified.Message" ) ); mb.setText( BaseMessages.getString( PKG, "Spoon.Dialog.NoRemoteServerSpecified.Title" ) ); mb.open(); } } else if ( executionConfiguration.isExecutingClustered() ) { activeTransGraph.handleTransMetaChanges( transMeta ); if ( transMeta.hasChanged() ) { showSaveTransformationBeforeRunningDialog( spoon.getShell() ); } else { splitTrans( transMeta, executionConfiguration ); } } } } }
SpoonTransformationDelegate extends SpoonDelegate { public void executeTransformation( final TransMeta transMeta, final boolean local, final boolean remote, final boolean cluster, final boolean preview, final boolean debug, final Date replayDate, final boolean safe, LogLevel logLevel ) throws KettleException { if ( transMeta == null ) { return; } TransDebugMeta transDebugMeta = null; TransExecutionConfiguration executionConfiguration = null; if ( preview ) { executionConfiguration = spoon.getTransPreviewExecutionConfiguration(); } else if ( debug ) { executionConfiguration = spoon.getTransDebugExecutionConfiguration(); } else { executionConfiguration = spoon.getTransExecutionConfiguration(); } executionConfiguration.setExecutingLocally( true ); executionConfiguration.setExecutingRemotely( false ); executionConfiguration.setExecutingClustered( false ); transMeta.setRepository( spoon.rep ); transMeta.setMetaStore( spoon.metaStore ); executionConfiguration.setRepository( spoon.rep ); executionConfiguration.setSafeModeEnabled( safe ); if ( debug ) { transDebugMeta = transDebugMetaMap.get( transMeta ); if ( transDebugMeta == null ) { transDebugMeta = new TransDebugMeta( transMeta ); transDebugMetaMap.put( transMeta, transDebugMeta ); } List<StepMeta> selectedSteps = transMeta.getSelectedSteps(); if ( selectedSteps != null && selectedSteps.size() > 0 ) { transDebugMeta.getStepDebugMetaMap().clear(); for ( StepMeta stepMeta : transMeta.getSelectedSteps() ) { StepDebugMeta stepDebugMeta = new StepDebugMeta( stepMeta ); stepDebugMeta.setRowCount( PropsUI.getInstance().getDefaultPreviewSize() ); stepDebugMeta.setPausingOnBreakPoint( true ); stepDebugMeta.setReadingFirstRows( false ); transDebugMeta.getStepDebugMetaMap().put( stepMeta, stepDebugMeta ); } } } else if ( preview ) { transDebugMeta = transPreviewMetaMap.get( transMeta ); if ( transDebugMeta == null ) { transDebugMeta = new TransDebugMeta( transMeta ); transPreviewMetaMap.put( transMeta, transDebugMeta ); } List<StepMeta> selectedSteps = transMeta.getSelectedSteps(); if ( selectedSteps != null && selectedSteps.size() > 0 ) { transDebugMeta.getStepDebugMetaMap().clear(); for ( StepMeta stepMeta : transMeta.getSelectedSteps() ) { StepDebugMeta stepDebugMeta = new StepDebugMeta( stepMeta ); stepDebugMeta.setRowCount( PropsUI.getInstance().getDefaultPreviewSize() ); stepDebugMeta.setPausingOnBreakPoint( false ); stepDebugMeta.setReadingFirstRows( true ); transDebugMeta.getStepDebugMetaMap().put( stepMeta, stepDebugMeta ); } } } int debugAnswer = TransDebugDialog.DEBUG_CONFIG; if ( debug || preview ) { transDebugMeta.getTransMeta().setRepository( spoon.rep ); TransDebugDialog transDebugDialog = new TransDebugDialog( spoon.getShell(), transDebugMeta ); debugAnswer = transDebugDialog.open(); if ( debugAnswer != TransDebugDialog.DEBUG_CANCEL ) { executionConfiguration.setExecutingLocally( true ); executionConfiguration.setExecutingRemotely( false ); executionConfiguration.setExecutingClustered( false ); } else { return; } } Object[] data = spoon.variables.getData(); String[] fields = spoon.variables.getRowMeta().getFieldNames(); Map<String, String> variableMap = new HashMap<String, String>(); variableMap.putAll( executionConfiguration.getVariables() ); for ( int idx = 0; idx < fields.length; idx++ ) { String value = executionConfiguration.getVariables().get( fields[idx] ); if ( Utils.isEmpty( value ) ) { value = data[idx].toString(); } variableMap.put( fields[idx], value ); } executionConfiguration.setVariables( variableMap ); executionConfiguration.getUsedVariables( transMeta ); executionConfiguration.getUsedArguments( transMeta, spoon.getArguments() ); executionConfiguration.setReplayDate( replayDate ); executionConfiguration.setLogLevel( logLevel ); boolean execConfigAnswer = true; if ( debugAnswer == TransDebugDialog.DEBUG_CONFIG && replayDate == null && transMeta.isShowDialog() ) { TransExecutionConfigurationDialog dialog = new TransExecutionConfigurationDialog( spoon.getShell(), executionConfiguration, transMeta ); execConfigAnswer = dialog.open(); } if ( execConfigAnswer ) { TransGraph activeTransGraph = spoon.getActiveTransGraph(); activeTransGraph.transLogDelegate.addTransLog(); Map<String, String> paramMap = executionConfiguration.getParams(); for ( String key : paramMap.keySet() ) { transMeta.setParameterValue( key, Const.NVL( paramMap.get( key ), "" ) ); } transMeta.activateParameters(); if ( executionConfiguration.getLogLevel() != null ) { transMeta.setLogLevel( executionConfiguration.getLogLevel() ); } transMeta.setClearingLog( executionConfiguration.isClearingLog() ); transMeta.setSafeModeEnabled( executionConfiguration.isSafeModeEnabled() ); transMeta.setGatheringMetrics( executionConfiguration.isGatheringMetrics() ); ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonTransMetaExecutionStart.id, transMeta ); ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonTransExecutionConfiguration.id, executionConfiguration ); try { ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonTransBeforeStart.id, new Object[] { executionConfiguration, transMeta, transMeta, spoon.getRepository() } ); } catch ( KettleException e ) { log.logError( e.getMessage(), transMeta.getFilename() ); return; } if ( !executionConfiguration.isExecutingLocally() && !executionConfiguration.isExecutingRemotely() ) { if ( transMeta.hasChanged() ) { activeTransGraph.showSaveFileMessage(); } } if ( debug || preview ) { if ( transDebugMeta.getNrOfUsedSteps() == 0 ) { MessageBox box = new MessageBox( spoon.getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO ); box.setText( BaseMessages.getString( PKG, "Spoon.Dialog.Warning.NoPreviewOrDebugSteps.Title" ) ); box.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.Warning.NoPreviewOrDebugSteps.Message" ) ); int answer = box.open(); if ( answer != SWT.YES ) { return; } } } if ( executionConfiguration.isExecutingLocally() ) { if ( debug || preview ) { activeTransGraph.debug( executionConfiguration, transDebugMeta ); } else { activeTransGraph.start( executionConfiguration ); } } else if ( executionConfiguration.isExecutingRemotely() ) { activeTransGraph.handleTransMetaChanges( transMeta ); if ( transMeta.hasChanged() ) { showSaveTransformationBeforeRunningDialog( spoon.getShell() ); } else if ( executionConfiguration.getRemoteServer() != null ) { String carteObjectId = Trans.sendToSlaveServer( transMeta, executionConfiguration, spoon.rep, spoon.metaStore ); monitorRemoteTrans( transMeta, carteObjectId, executionConfiguration.getRemoteServer() ); spoon.delegates.slaves.addSpoonSlave( executionConfiguration.getRemoteServer() ); } else { MessageBox mb = new MessageBox( spoon.getShell(), SWT.OK | SWT.ICON_INFORMATION ); mb.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.NoRemoteServerSpecified.Message" ) ); mb.setText( BaseMessages.getString( PKG, "Spoon.Dialog.NoRemoteServerSpecified.Title" ) ); mb.open(); } } else if ( executionConfiguration.isExecutingClustered() ) { activeTransGraph.handleTransMetaChanges( transMeta ); if ( transMeta.hasChanged() ) { showSaveTransformationBeforeRunningDialog( spoon.getShell() ); } else { splitTrans( transMeta, executionConfiguration ); } } } } SpoonTransformationDelegate( Spoon spoon ); }
SpoonTransformationDelegate extends SpoonDelegate { public void executeTransformation( final TransMeta transMeta, final boolean local, final boolean remote, final boolean cluster, final boolean preview, final boolean debug, final Date replayDate, final boolean safe, LogLevel logLevel ) throws KettleException { if ( transMeta == null ) { return; } TransDebugMeta transDebugMeta = null; TransExecutionConfiguration executionConfiguration = null; if ( preview ) { executionConfiguration = spoon.getTransPreviewExecutionConfiguration(); } else if ( debug ) { executionConfiguration = spoon.getTransDebugExecutionConfiguration(); } else { executionConfiguration = spoon.getTransExecutionConfiguration(); } executionConfiguration.setExecutingLocally( true ); executionConfiguration.setExecutingRemotely( false ); executionConfiguration.setExecutingClustered( false ); transMeta.setRepository( spoon.rep ); transMeta.setMetaStore( spoon.metaStore ); executionConfiguration.setRepository( spoon.rep ); executionConfiguration.setSafeModeEnabled( safe ); if ( debug ) { transDebugMeta = transDebugMetaMap.get( transMeta ); if ( transDebugMeta == null ) { transDebugMeta = new TransDebugMeta( transMeta ); transDebugMetaMap.put( transMeta, transDebugMeta ); } List<StepMeta> selectedSteps = transMeta.getSelectedSteps(); if ( selectedSteps != null && selectedSteps.size() > 0 ) { transDebugMeta.getStepDebugMetaMap().clear(); for ( StepMeta stepMeta : transMeta.getSelectedSteps() ) { StepDebugMeta stepDebugMeta = new StepDebugMeta( stepMeta ); stepDebugMeta.setRowCount( PropsUI.getInstance().getDefaultPreviewSize() ); stepDebugMeta.setPausingOnBreakPoint( true ); stepDebugMeta.setReadingFirstRows( false ); transDebugMeta.getStepDebugMetaMap().put( stepMeta, stepDebugMeta ); } } } else if ( preview ) { transDebugMeta = transPreviewMetaMap.get( transMeta ); if ( transDebugMeta == null ) { transDebugMeta = new TransDebugMeta( transMeta ); transPreviewMetaMap.put( transMeta, transDebugMeta ); } List<StepMeta> selectedSteps = transMeta.getSelectedSteps(); if ( selectedSteps != null && selectedSteps.size() > 0 ) { transDebugMeta.getStepDebugMetaMap().clear(); for ( StepMeta stepMeta : transMeta.getSelectedSteps() ) { StepDebugMeta stepDebugMeta = new StepDebugMeta( stepMeta ); stepDebugMeta.setRowCount( PropsUI.getInstance().getDefaultPreviewSize() ); stepDebugMeta.setPausingOnBreakPoint( false ); stepDebugMeta.setReadingFirstRows( true ); transDebugMeta.getStepDebugMetaMap().put( stepMeta, stepDebugMeta ); } } } int debugAnswer = TransDebugDialog.DEBUG_CONFIG; if ( debug || preview ) { transDebugMeta.getTransMeta().setRepository( spoon.rep ); TransDebugDialog transDebugDialog = new TransDebugDialog( spoon.getShell(), transDebugMeta ); debugAnswer = transDebugDialog.open(); if ( debugAnswer != TransDebugDialog.DEBUG_CANCEL ) { executionConfiguration.setExecutingLocally( true ); executionConfiguration.setExecutingRemotely( false ); executionConfiguration.setExecutingClustered( false ); } else { return; } } Object[] data = spoon.variables.getData(); String[] fields = spoon.variables.getRowMeta().getFieldNames(); Map<String, String> variableMap = new HashMap<String, String>(); variableMap.putAll( executionConfiguration.getVariables() ); for ( int idx = 0; idx < fields.length; idx++ ) { String value = executionConfiguration.getVariables().get( fields[idx] ); if ( Utils.isEmpty( value ) ) { value = data[idx].toString(); } variableMap.put( fields[idx], value ); } executionConfiguration.setVariables( variableMap ); executionConfiguration.getUsedVariables( transMeta ); executionConfiguration.getUsedArguments( transMeta, spoon.getArguments() ); executionConfiguration.setReplayDate( replayDate ); executionConfiguration.setLogLevel( logLevel ); boolean execConfigAnswer = true; if ( debugAnswer == TransDebugDialog.DEBUG_CONFIG && replayDate == null && transMeta.isShowDialog() ) { TransExecutionConfigurationDialog dialog = new TransExecutionConfigurationDialog( spoon.getShell(), executionConfiguration, transMeta ); execConfigAnswer = dialog.open(); } if ( execConfigAnswer ) { TransGraph activeTransGraph = spoon.getActiveTransGraph(); activeTransGraph.transLogDelegate.addTransLog(); Map<String, String> paramMap = executionConfiguration.getParams(); for ( String key : paramMap.keySet() ) { transMeta.setParameterValue( key, Const.NVL( paramMap.get( key ), "" ) ); } transMeta.activateParameters(); if ( executionConfiguration.getLogLevel() != null ) { transMeta.setLogLevel( executionConfiguration.getLogLevel() ); } transMeta.setClearingLog( executionConfiguration.isClearingLog() ); transMeta.setSafeModeEnabled( executionConfiguration.isSafeModeEnabled() ); transMeta.setGatheringMetrics( executionConfiguration.isGatheringMetrics() ); ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonTransMetaExecutionStart.id, transMeta ); ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonTransExecutionConfiguration.id, executionConfiguration ); try { ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonTransBeforeStart.id, new Object[] { executionConfiguration, transMeta, transMeta, spoon.getRepository() } ); } catch ( KettleException e ) { log.logError( e.getMessage(), transMeta.getFilename() ); return; } if ( !executionConfiguration.isExecutingLocally() && !executionConfiguration.isExecutingRemotely() ) { if ( transMeta.hasChanged() ) { activeTransGraph.showSaveFileMessage(); } } if ( debug || preview ) { if ( transDebugMeta.getNrOfUsedSteps() == 0 ) { MessageBox box = new MessageBox( spoon.getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO ); box.setText( BaseMessages.getString( PKG, "Spoon.Dialog.Warning.NoPreviewOrDebugSteps.Title" ) ); box.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.Warning.NoPreviewOrDebugSteps.Message" ) ); int answer = box.open(); if ( answer != SWT.YES ) { return; } } } if ( executionConfiguration.isExecutingLocally() ) { if ( debug || preview ) { activeTransGraph.debug( executionConfiguration, transDebugMeta ); } else { activeTransGraph.start( executionConfiguration ); } } else if ( executionConfiguration.isExecutingRemotely() ) { activeTransGraph.handleTransMetaChanges( transMeta ); if ( transMeta.hasChanged() ) { showSaveTransformationBeforeRunningDialog( spoon.getShell() ); } else if ( executionConfiguration.getRemoteServer() != null ) { String carteObjectId = Trans.sendToSlaveServer( transMeta, executionConfiguration, spoon.rep, spoon.metaStore ); monitorRemoteTrans( transMeta, carteObjectId, executionConfiguration.getRemoteServer() ); spoon.delegates.slaves.addSpoonSlave( executionConfiguration.getRemoteServer() ); } else { MessageBox mb = new MessageBox( spoon.getShell(), SWT.OK | SWT.ICON_INFORMATION ); mb.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.NoRemoteServerSpecified.Message" ) ); mb.setText( BaseMessages.getString( PKG, "Spoon.Dialog.NoRemoteServerSpecified.Title" ) ); mb.open(); } } else if ( executionConfiguration.isExecutingClustered() ) { activeTransGraph.handleTransMetaChanges( transMeta ); if ( transMeta.hasChanged() ) { showSaveTransformationBeforeRunningDialog( spoon.getShell() ); } else { splitTrans( transMeta, executionConfiguration ); } } } } SpoonTransformationDelegate( Spoon spoon ); boolean addTransformation( TransMeta transMeta ); synchronized void closeTransformation( TransMeta transMeta ); Spoon getSpoon(); void addTransGraph( TransMeta transMeta ); void tabSelected( TabItem item ); List<TransMeta> getTransformationList(); TransMeta getTransformation( String name ); void removeTransformation( TransMeta transMeta ); TransMeta[] getLoadedTransformations(); TransGraph findTransGraphOfTransformation( TransMeta transMeta ); boolean isDefaultTransformationName( String name ); void undoTransformationAction( TransMeta transMeta, TransAction transAction ); void redoTransformationAction( TransMeta transMeta, TransAction transAction ); void executeTransformation( final TransMeta transMeta, final boolean local, final boolean remote,
      final boolean cluster, final boolean preview, final boolean debug, final Date replayDate, final boolean safe,
      LogLevel logLevel ); }
SpoonTransformationDelegate extends SpoonDelegate { public void executeTransformation( final TransMeta transMeta, final boolean local, final boolean remote, final boolean cluster, final boolean preview, final boolean debug, final Date replayDate, final boolean safe, LogLevel logLevel ) throws KettleException { if ( transMeta == null ) { return; } TransDebugMeta transDebugMeta = null; TransExecutionConfiguration executionConfiguration = null; if ( preview ) { executionConfiguration = spoon.getTransPreviewExecutionConfiguration(); } else if ( debug ) { executionConfiguration = spoon.getTransDebugExecutionConfiguration(); } else { executionConfiguration = spoon.getTransExecutionConfiguration(); } executionConfiguration.setExecutingLocally( true ); executionConfiguration.setExecutingRemotely( false ); executionConfiguration.setExecutingClustered( false ); transMeta.setRepository( spoon.rep ); transMeta.setMetaStore( spoon.metaStore ); executionConfiguration.setRepository( spoon.rep ); executionConfiguration.setSafeModeEnabled( safe ); if ( debug ) { transDebugMeta = transDebugMetaMap.get( transMeta ); if ( transDebugMeta == null ) { transDebugMeta = new TransDebugMeta( transMeta ); transDebugMetaMap.put( transMeta, transDebugMeta ); } List<StepMeta> selectedSteps = transMeta.getSelectedSteps(); if ( selectedSteps != null && selectedSteps.size() > 0 ) { transDebugMeta.getStepDebugMetaMap().clear(); for ( StepMeta stepMeta : transMeta.getSelectedSteps() ) { StepDebugMeta stepDebugMeta = new StepDebugMeta( stepMeta ); stepDebugMeta.setRowCount( PropsUI.getInstance().getDefaultPreviewSize() ); stepDebugMeta.setPausingOnBreakPoint( true ); stepDebugMeta.setReadingFirstRows( false ); transDebugMeta.getStepDebugMetaMap().put( stepMeta, stepDebugMeta ); } } } else if ( preview ) { transDebugMeta = transPreviewMetaMap.get( transMeta ); if ( transDebugMeta == null ) { transDebugMeta = new TransDebugMeta( transMeta ); transPreviewMetaMap.put( transMeta, transDebugMeta ); } List<StepMeta> selectedSteps = transMeta.getSelectedSteps(); if ( selectedSteps != null && selectedSteps.size() > 0 ) { transDebugMeta.getStepDebugMetaMap().clear(); for ( StepMeta stepMeta : transMeta.getSelectedSteps() ) { StepDebugMeta stepDebugMeta = new StepDebugMeta( stepMeta ); stepDebugMeta.setRowCount( PropsUI.getInstance().getDefaultPreviewSize() ); stepDebugMeta.setPausingOnBreakPoint( false ); stepDebugMeta.setReadingFirstRows( true ); transDebugMeta.getStepDebugMetaMap().put( stepMeta, stepDebugMeta ); } } } int debugAnswer = TransDebugDialog.DEBUG_CONFIG; if ( debug || preview ) { transDebugMeta.getTransMeta().setRepository( spoon.rep ); TransDebugDialog transDebugDialog = new TransDebugDialog( spoon.getShell(), transDebugMeta ); debugAnswer = transDebugDialog.open(); if ( debugAnswer != TransDebugDialog.DEBUG_CANCEL ) { executionConfiguration.setExecutingLocally( true ); executionConfiguration.setExecutingRemotely( false ); executionConfiguration.setExecutingClustered( false ); } else { return; } } Object[] data = spoon.variables.getData(); String[] fields = spoon.variables.getRowMeta().getFieldNames(); Map<String, String> variableMap = new HashMap<String, String>(); variableMap.putAll( executionConfiguration.getVariables() ); for ( int idx = 0; idx < fields.length; idx++ ) { String value = executionConfiguration.getVariables().get( fields[idx] ); if ( Utils.isEmpty( value ) ) { value = data[idx].toString(); } variableMap.put( fields[idx], value ); } executionConfiguration.setVariables( variableMap ); executionConfiguration.getUsedVariables( transMeta ); executionConfiguration.getUsedArguments( transMeta, spoon.getArguments() ); executionConfiguration.setReplayDate( replayDate ); executionConfiguration.setLogLevel( logLevel ); boolean execConfigAnswer = true; if ( debugAnswer == TransDebugDialog.DEBUG_CONFIG && replayDate == null && transMeta.isShowDialog() ) { TransExecutionConfigurationDialog dialog = new TransExecutionConfigurationDialog( spoon.getShell(), executionConfiguration, transMeta ); execConfigAnswer = dialog.open(); } if ( execConfigAnswer ) { TransGraph activeTransGraph = spoon.getActiveTransGraph(); activeTransGraph.transLogDelegate.addTransLog(); Map<String, String> paramMap = executionConfiguration.getParams(); for ( String key : paramMap.keySet() ) { transMeta.setParameterValue( key, Const.NVL( paramMap.get( key ), "" ) ); } transMeta.activateParameters(); if ( executionConfiguration.getLogLevel() != null ) { transMeta.setLogLevel( executionConfiguration.getLogLevel() ); } transMeta.setClearingLog( executionConfiguration.isClearingLog() ); transMeta.setSafeModeEnabled( executionConfiguration.isSafeModeEnabled() ); transMeta.setGatheringMetrics( executionConfiguration.isGatheringMetrics() ); ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonTransMetaExecutionStart.id, transMeta ); ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonTransExecutionConfiguration.id, executionConfiguration ); try { ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.SpoonTransBeforeStart.id, new Object[] { executionConfiguration, transMeta, transMeta, spoon.getRepository() } ); } catch ( KettleException e ) { log.logError( e.getMessage(), transMeta.getFilename() ); return; } if ( !executionConfiguration.isExecutingLocally() && !executionConfiguration.isExecutingRemotely() ) { if ( transMeta.hasChanged() ) { activeTransGraph.showSaveFileMessage(); } } if ( debug || preview ) { if ( transDebugMeta.getNrOfUsedSteps() == 0 ) { MessageBox box = new MessageBox( spoon.getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO ); box.setText( BaseMessages.getString( PKG, "Spoon.Dialog.Warning.NoPreviewOrDebugSteps.Title" ) ); box.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.Warning.NoPreviewOrDebugSteps.Message" ) ); int answer = box.open(); if ( answer != SWT.YES ) { return; } } } if ( executionConfiguration.isExecutingLocally() ) { if ( debug || preview ) { activeTransGraph.debug( executionConfiguration, transDebugMeta ); } else { activeTransGraph.start( executionConfiguration ); } } else if ( executionConfiguration.isExecutingRemotely() ) { activeTransGraph.handleTransMetaChanges( transMeta ); if ( transMeta.hasChanged() ) { showSaveTransformationBeforeRunningDialog( spoon.getShell() ); } else if ( executionConfiguration.getRemoteServer() != null ) { String carteObjectId = Trans.sendToSlaveServer( transMeta, executionConfiguration, spoon.rep, spoon.metaStore ); monitorRemoteTrans( transMeta, carteObjectId, executionConfiguration.getRemoteServer() ); spoon.delegates.slaves.addSpoonSlave( executionConfiguration.getRemoteServer() ); } else { MessageBox mb = new MessageBox( spoon.getShell(), SWT.OK | SWT.ICON_INFORMATION ); mb.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.NoRemoteServerSpecified.Message" ) ); mb.setText( BaseMessages.getString( PKG, "Spoon.Dialog.NoRemoteServerSpecified.Title" ) ); mb.open(); } } else if ( executionConfiguration.isExecutingClustered() ) { activeTransGraph.handleTransMetaChanges( transMeta ); if ( transMeta.hasChanged() ) { showSaveTransformationBeforeRunningDialog( spoon.getShell() ); } else { splitTrans( transMeta, executionConfiguration ); } } } } SpoonTransformationDelegate( Spoon spoon ); boolean addTransformation( TransMeta transMeta ); synchronized void closeTransformation( TransMeta transMeta ); Spoon getSpoon(); void addTransGraph( TransMeta transMeta ); void tabSelected( TabItem item ); List<TransMeta> getTransformationList(); TransMeta getTransformation( String name ); void removeTransformation( TransMeta transMeta ); TransMeta[] getLoadedTransformations(); TransGraph findTransGraphOfTransformation( TransMeta transMeta ); boolean isDefaultTransformationName( String name ); void undoTransformationAction( TransMeta transMeta, TransAction transAction ); void redoTransformationAction( TransMeta transMeta, TransAction transAction ); void executeTransformation( final TransMeta transMeta, final boolean local, final boolean remote,
      final boolean cluster, final boolean preview, final boolean debug, final Date replayDate, final boolean safe,
      LogLevel logLevel );  }