public static Object getTransformationName( Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext ) { try { Object objTranName = Context.toString( actualObject.get( "_TransformationName_", actualObject ) ); return objTranName; } catch ( Exception e ) { throw Context.reportRuntimeError( e.toString() ); } }
public static void LoadScriptFromTab( Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext ) { try { for ( int i = 0; i < ArgList.length; i++ ) { // don't worry about "undefined" arguments String strToLoad = Context.toString( ArgList[i] ); String strScript = actualObject.get( strToLoad, actualObject ).toString(); actualContext.evaluateString( actualObject, strScript, "_" + strToLoad + "_", 0, null ); } } catch ( Exception e ) { // System.out.println(e.toString()); } }
public JsConsole(ScriptableObject scope) { setParentScope(scope); Object ctor = ScriptRuntime.getTopLevelProp(scope, "Console"); if (ctor != null && ctor instanceof Scriptable) { Scriptable scriptable = (Scriptable) ctor; setPrototype((Scriptable) scriptable.get("prototype", scriptable)); } }
public static Object[] createRowCopy( Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext ) { if ( ArgList.length == 1 ) { try { int newSize = (int) Math.round( Context.toNumber( ArgList[0] ) ); Object scmO = actualObject.get( "row", actualObject ); Object[] row = (Object[]) Context.jsToJava( scmO, ( new Object[] {} ).getClass() ); return RowDataUtil.createResizedCopy( row, newSize ); } catch ( Exception e ) { throw Context.reportRuntimeError( "Unable to create a row copy: " + Const.CR + e.toString() ); } } else { throw Context .reportRuntimeError( "The function call createRowCopy requires a single arguments : the new size of the row" ); } }
public static double getProcessCount( Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext ) { if ( ArgList.length == 1 ) { try { Object scmO = actualObject.get( "_step_", actualObject ); StepInterface scm = (StepInterface) Context.jsToJava( scmO, StepInterface.class ); String strType = Context.toString( ArgList[0] ).toLowerCase(); if ( strType.equals( "i" ) ) { return scm.getLinesInput(); } else if ( strType.equals( "o" ) ) { return scm.getLinesOutput(); } else if ( strType.equals( "r" ) ) { return scm.getLinesRead(); } else if ( strType.equals( "u" ) ) { return scm.getLinesUpdated(); } else if ( strType.equals( "w" ) ) { return scm.getLinesWritten(); } else if ( strType.equals( "e" ) ) { return scm.getLinesRejected(); } else { return 0; } } catch ( Exception e ) { // throw Context.reportRuntimeError(e.toString()); return 0; } } else { throw Context.reportRuntimeError( "The function call getProcessCount requires 1 argument." ); } }
public static RowMetaInterface getOutputRowMeta( Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext ) { if ( ArgList.length == 0 ) { try { Object scmO = actualObject.get( "_step_", actualObject ); try { ScriptValuesMod scm = (ScriptValuesMod) Context.jsToJava( scmO, ScriptValuesMod.class ); return scm.getOutputRowMeta(); } catch ( Exception e ) { ScriptValuesModDummy scm = (ScriptValuesModDummy) Context.jsToJava( scmO, ScriptValuesModDummy.class ); return scm.getOutputRowMeta(); } } catch ( Exception e ) { throw Context.reportRuntimeError( "Unable to get the output row metadata because of an error: " + Const.CR + e.toString() ); } } else { throw Context.reportRuntimeError( "The function call getOutputRowMeta doesn't require arguments." ); } }
public static RowMetaInterface getInputRowMeta( Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext ) { if ( ArgList.length == 0 ) { try { Object scmO = actualObject.get( "_step_", actualObject ); try { ScriptValuesMod scm = (ScriptValuesMod) Context.jsToJava( scmO, ScriptValuesMod.class ); return scm.getInputRowMeta(); } catch ( Exception e ) { ScriptValuesModDummy scm = (ScriptValuesModDummy) Context.jsToJava( scmO, ScriptValuesModDummy.class ); return scm.getInputRowMeta(); } } catch ( Exception e ) { throw Context.reportRuntimeError( "Unable to get the input row metadata because of an error: " + Const.CR + e.toString() ); } } else { throw Context.reportRuntimeError( "The function call getInputRowMeta doesn't require arguments." ); } }
public static String getEnvironmentVar( Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext ) { String sRC = ""; if ( ArgList.length == 1 ) { try { String sArg1 = Context.toString( ArgList[0] ); // PDI-1276 Function getEnvironmentVar() does not work for user defined variables. // check if the system property exists, and if it does not, try getting a Kettle var instead if ( System.getProperties().containsValue( sArg1 ) ) { sRC = System.getProperty( sArg1, "" ); } else { Object scmo = actualObject.get( "_step_", actualObject ); Object scmO = Context.jsToJava( scmo, StepInterface.class ); if ( scmO instanceof StepInterface ) { StepInterface scm = (StepInterface) Context.jsToJava( scmO, StepInterface.class ); sArg1 = Context.toString( ArgList[0] ); sRC = scm.getVariable( sArg1, "" ); } else { // running in test mode, return "" sRC = ""; } } } catch ( Exception e ) { sRC = ""; } } else { throw Context.reportRuntimeError( "The function call getEnvironmentVar requires 1 argument." ); } return sRC; }
try { if ( !isNull( ArgList ) && !isUndefined( ArgList ) ) { Object scmO = actualObject.get( "_step_", actualObject ); ScriptValuesMod scm = (ScriptValuesMod) Context.jsToJava( scmO, ScriptValuesMod.class ); String strMessage = Context.toString( ArgList[0] ); try { if ( !isNull( ArgList ) && !isUndefined( ArgList ) ) { Object scmO = actualObject.get( "_step_", actualObject ); ScriptValuesMod scm = (ScriptValuesMod) Context.jsToJava( scmO, ScriptValuesMod.class );
public static void putRow( Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext ) { if ( ArgList.length == 1 ) { try { Object[] newRow = (Object[]) Context.jsToJava( ArgList[0], ( new Object[] {} ).getClass() ); Object scmO = actualObject.get( "_step_", actualObject ); try { ScriptValuesMod step = (ScriptValuesMod) Context.jsToJava( scmO, ScriptValuesMod.class ); step.putRow( step.getOutputRowMeta(), newRow ); } catch ( Exception e ) { ScriptValuesModDummy step = (ScriptValuesModDummy) Context.jsToJava( scmO, ScriptValuesModDummy.class ); step.putRow( step.getOutputRowMeta(), newRow ); } } catch ( Exception e ) { throw Context.reportRuntimeError( "Unable to pass the new row to the next step(s) because of an error: " + Const.CR + e.toString() ); } } else { throw Context .reportRuntimeError( "The function call putRow requires 1 argument : the output row data (Object[])" ); } }
Object result = scope.get( fieldname[i], scope ); if ( result != null ) {
if ( ArgList.length == 2 ) { try { Object scmO = actualObject.get( "_step_", actualObject ); ScriptValuesMod scm = (ScriptValuesMod) Context.jsToJava( scmO, ScriptValuesMod.class ); String strDBName = Context.toString( ArgList[0] );
public static String getVariable( Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext ) { String sRC = ""; String sArg1 = ""; String sArg2 = ""; if ( ArgList.length == 2 ) { try { Object scmo = actualObject.get( "_step_", actualObject ); Object scmO = Context.jsToJava( scmo, StepInterface.class ); if ( scmO instanceof StepInterface ) { StepInterface scm = (StepInterface) Context.jsToJava( scmO, StepInterface.class ); sArg1 = Context.toString( ArgList[0] ); sArg2 = Context.toString( ArgList[1] ); return scm.getVariable( sArg1, sArg2 ); } else { // running via the Test button in a dialog sArg2 = Context.toString( ArgList[1] ); return sArg2; } } catch ( Exception e ) { sRC = ""; } } else { throw Context.reportRuntimeError( "The function call getVariable requires 2 arguments." ); } return sRC; }
public static void setVariable( Context actualContext, Scriptable actualObject, Object[] arguments, Function functionContext ) { if ( arguments.length != 3 ) { throw Context.reportRuntimeError( "The function call setVariable requires 3 arguments." ); } Object stepObject = Context.jsToJava( actualObject.get( "_step_", actualObject ), StepInterface.class ); if ( stepObject instanceof StepInterface ) { StepInterface step = (StepInterface) stepObject; Trans trans = step.getTrans(); final String variableName = Context.toString( arguments[ 0 ] ); final String variableValue = Context.toString( arguments[ 1 ] ); final VariableScope variableScope = getVariableScope( Context.toString( arguments[ 2 ] ) ); // Set variable in step's scope so that it can be retrieved in the same step using getVariable step.setVariable( variableName, variableValue ); switch ( variableScope ) { case PARENT: setParentScopeVariable( trans, variableName, variableValue ); break; case GRAND_PARENT: setGrandParentScopeVariable( trans, variableName, variableValue ); break; case ROOT: setRootScopeVariable( trans, variableName, variableValue ); break; case SYSTEM: setSystemScopeVariable( trans, variableName, variableValue ); break; } } }
int type = ValueMetaInterface.TYPE_STRING; int length = -1, precision = -1; Object result = jsscope.get( varname, jsscope ); if ( result != null ) { String classname = result.getClass().getName();
int type = ValueMetaInterface.TYPE_STRING; int length = -1, precision = -1; Object result = jsscope.get( varname, jsscope ); if ( result != null ) { String classname = result.getClass().getName();
bFirstRun = false; Object tran_stat = data.scope.get( "trans_Status", data.scope ); if ( tran_stat != ScriptableObject.NOT_FOUND ) { bWithTransStat = true; iTranStat = (int) Context.toNumber( data.scope.get( "trans_Status", data.scope ) ); } else { iTranStat = CONTINUE_TRANSFORMATION; bRC = true; for ( int i = 0; i < meta.getFieldname().length; i++ ) { Object result = data.scope.get( meta.getFieldname()[ i ], data.scope ); Object valueData = getValueFromJScript( result, i ); if ( data.replaceIndex[ i ] < 0 ) {
public Object get(String id, Scriptable start) { if (start == this) start = prototype; return prototype.get(id, start); }
/** * @see org.mozilla.javascript.Scriptable#get(int, Scriptable) */ public Object get(int index, Scriptable start) { return obj.get(index,start); } /**
public static Object enumValue(Object enumObj, Context cx) { IdEnumeration x = (IdEnumeration)enumObj; Object result; String s = toStringIdOrIndex(cx, x.currentId); if (s == null) { int index = lastIndexResult(cx); result = x.obj.get(index, x.obj); } else { result = x.obj.get(s, x.obj); } return result; }