public StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta transMeta, Trans trans ) { return new Script( stepMeta, stepDataInterface, cnr, transMeta, trans ); }
data = (ScriptData) sdi; Object[] r = getRow(); // Get row from input rowset & set row busy! if ( r == null ) { logDetailed( ( "End Script found!" ) ); logDetailed( ( "No end Script found!" ) ); logError( BaseMessages.getString( PKG, "Script.Log.UnexpectedeError" ) + " : " + e.toString() ); logError( BaseMessages.getString( PKG, "Script.Log.ErrorStackTrace" ) + Const.CR + Const.getStackTracker( e ) ); setErrors( 1 ); stopAll(); setOutputDone(); return false; addValues( getInputRowMeta(), r ); } catch ( KettleValueException e ) { String location = null; if ( getStepMeta().isDoingErrorHandling() ) { putError( getInputRowMeta(), r, 1, e.getMessage() + Const.CR + location, null, "SCR-001" ); bRC = true; // continue by all means, even on the first row and if ( checkFeedback( getLinesRead() ) ) { logBasic( BaseMessages.getString( PKG, "Script.Log.LineNumber" ) + getLinesRead() );
data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); determineUsedFields( rowMeta ); data.cx = ScriptMeta.createNewScriptEngine( getStepname() ); data.scope = data.cx.getBindings( ScriptContext.ENGINE_SCOPE ); data.scope.put( "_TransformationName_", this.getStepname() ); startScript.eval( data.scope ); if ( log.isDetailed() ) { logDetailed( ( "Start Script found!" ) ); logDetailed( ( "No starting Script found!" ) ); logDetailed( ( "tran_Status found. Checking transformation status while script execution." ) ); logDetailed( ( "No tran_Status found. Transformation status checking not available." ) ); for ( int i = 0; i < meta.getFieldname().length; i++ ) { Object result = data.scope.get( meta.getFieldname()[ i ] ); Object valueData = getValueFromJScript( result, i ); if ( data.replaceIndex[ i ] < 0 ) { outputRow[ outputIndex++ ] = valueData; putRow( data.outputRowMeta, outputRow ); } else { switch ( iTranStat ) {
@Test public void testOutputDoneIfInputEmpty() throws Exception { Script step = new Script( helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans ); step.init( helper.initStepMetaInterface, helper.initStepDataInterface ); RowSet rs = helper.getMockInputRowSet( new Object[ 0 ][ 0 ] ); List<RowSet> in = new ArrayList<RowSet>(); in.add( rs ); step.setInputRowSets( in ); TransTestingUtil.execute( step, helper.processRowsStepMetaInterface, helper.processRowsStepDataInterface, 0, true ); rs.getRow(); }
String strDBName = (String) ArgList[0]; String strSQL = (String) ArgList[1]; DatabaseMeta ci = DatabaseMeta.findDatabase( scm.getTransMeta().getDatabases(), strDBName ); if ( ci == null ) { throw new RuntimeException( "Database connection not found: " + strDBName ); db.setQueryLimit( 0 ); try { if ( scm.getTransMeta().isUsingUniqueConnections() ) { synchronized ( scm.getTrans() ) { db.connect( scm.getTrans().getTransactionId(), scm.getPartitionID() ); db.connect( scm.getPartitionID() );
public static void putRow( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext ) { if ( ArgList.length == 1 ) { try { Object[] newRow = (Object[]) ArgList[0]; Object scmO = actualObject.get( "_step_" ); try { Script step = (Script) scmO; step.putRow( step.getOutputRowMeta(), newRow ); } catch ( Exception e ) { ScriptDummy step = (ScriptDummy) scmO; step.putRow( step.getOutputRowMeta(), newRow ); } } catch ( Exception e ) { throw new RuntimeException( "Unable to pass the new row to the next step(s) because of an error: " + Const.CR + e.toString() ); } } else { throw new RuntimeException( "The function call putRow requires 1 argument : the output row data (Object[])" ); } }
public static RowMetaInterface getOutputRowMeta( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext ) { if ( ArgList.length == 0 ) { try { Object scmO = actualObject.get( "_step_" ); try { Script scm = (Script) scmO; return scm.getOutputRowMeta(); } catch ( Exception e ) { ScriptDummy scm = (ScriptDummy) scmO; return scm.getOutputRowMeta(); } } catch ( Exception e ) { throw new RuntimeException( "Unable to get the output row metadata because of an error: " + Const.CR + e.toString() ); } } else { throw new RuntimeException( "The function call getOutputRowMeta doesn't require arguments." ); } }
public static RowMetaInterface getInputRowMeta( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext ) { if ( ArgList.length == 0 ) { try { Object scmO = actualObject.get( "_step_" ); try { Script scm = (Script) scmO; return scm.getInputRowMeta(); } catch ( Exception e ) { ScriptDummy scm = (ScriptDummy) scmO; return scm.getInputRowMeta(); } } catch ( Exception e ) { throw new RuntimeException( "Unable to get the input row metadata because of an error: " + Const.CR + e.toString() ); } } else { throw new RuntimeException( "The function call getInputRowMeta doesn't require arguments." ); } }