public static void LoadScriptFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext ) { for ( int i = 0; i < ArgList.length; i++ ) { // don't worry about "undefined" arguments checkAndLoadJSFile( actualContext, actualObject, (String) ArgList[i] ); } }
public String[] getJSScriptNames() { String[] strJSNames = new String[jsScripts.length]; for ( int i = 0; i < jsScripts.length; i++ ) { strJSNames[i] = jsScripts[i].getScriptName(); } return strJSNames; }
public ScriptMeta() { super(); // allocate BaseStepMeta try { parseXmlForAdditionalClasses(); } catch ( Exception e ) { /* Ignore */ } }
@Override public String toString() { return String.format( "ScriptValuesScript: (%d, %s, %s, %b)", getScriptType(), getScriptName(), getScript(), isActive() ); } }
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (ScriptMeta) smi; data = (ScriptData) sdi; if ( super.init( smi, sdi ) ) { // Add init code here. // Get the actual Scripts from our MetaData jsScripts = meta.getJSScripts(); for ( int j = 0; j < jsScripts.length; j++ ) { switch ( jsScripts[ j ].getScriptType() ) { case ScriptValuesScript.TRANSFORM_SCRIPT: strTransformScript = jsScripts[ j ].getScript(); break; case ScriptValuesScript.START_SCRIPT: strStartScript = jsScripts[ j ].getScript(); break; case ScriptValuesScript.END_SCRIPT: strEndScript = jsScripts[ j ].getScript(); break; default: break; } } return true; } return false; }
public void setDefault() { jsScripts = new ScriptValuesScript[1]; jsScripts[0] = new ScriptValuesScript( ScriptValuesScript.TRANSFORM_SCRIPT, BaseMessages .getString( PKG, "Script.Script1" ), "//" + BaseMessages.getString( PKG, "Script.ScriptHere" ) + Const.CR + Const.CR ); int nrfields = 0; allocate( nrfields ); for ( int i = 0; i < nrfields; i++ ) { fieldname[i] = "newvalue"; rename[i] = "newvalue"; type[i] = ValueMetaInterface.TYPE_NUMBER; length[i] = -1; precision[i] = -1; replace[i] = false; } }
public void modify( StepMetaInterface someMeta ) { if ( someMeta instanceof ScriptMeta ) { ( (ScriptMeta) someMeta ).allocate( 5 ); } }
@Override public ScriptValuesScript getTestObject() { int scriptType = rand.nextInt( 4 ); if ( scriptType == 3 ) { scriptType = -1; } ScriptValuesScript rtn = new ScriptValuesScript( scriptType, UUID.randomUUID().toString(), UUID.randomUUID().toString() ); return rtn; }
public StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta transMeta, Trans trans ) { return new Script( stepMeta, stepDataInterface, cnr, transMeta, trans ); }
public static Object isDate( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext ) { if ( ArgList.length == 1 ) { try { if ( isNull( ArgList[0] ) ) { return null; } else if ( isUndefined( ArgList[0] ) ) { return undefinedValue; } /* java.util.Date d = (java.util.Date) */ return Boolean.TRUE; } catch ( Exception e ) { return Boolean.FALSE; } } else { throw new RuntimeException( "The function call isDate requires 1 argument." ); } }
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." ); } }
public void modifyText( ModifyEvent e ) { input.setChanged(); } };
private static boolean isUndefined( Object ArgList ) { return isUndefined( new Object[] { ArgList }, new int[] { 0 } ); }
public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException { readData( stepnode ); }
public StepDataInterface getStepData() { return new ScriptData(); }
private static boolean isNull( Object ArgList ) { return isNull( new Object[] { ArgList }, new int[] { 0 } ); }
public static void println( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext ) { print( actualContext, actualObject, ArgList, FunctionContext ); java.lang.System.out.println(); }
@Override public boolean validateTestObject( ScriptValuesScript testObject, Object actual ) { if ( !( actual instanceof ScriptValuesScript ) ) { return false; } return ( actual.toString().equals( testObject.toString() ) ); } }
public Object clone() { ScriptMeta retval = (ScriptMeta) super.clone(); int nrfields = fieldname.length; retval.allocate( nrfields ); System.arraycopy( fieldname, 0, retval.fieldname, 0, nrfields ); System.arraycopy( rename, 0, retval.rename, 0, nrfields ); System.arraycopy( type, 0, retval.type, 0, nrfields ); System.arraycopy( length, 0, retval.length, 0, nrfields ); System.arraycopy( precision, 0, retval.precision, 0, nrfields ); System.arraycopy( replace, 0, retval.replace, 0, nrfields ); return retval; }