Java Code Examples for org.pentaho.di.core.Const#INTERNAL_JOB_VARIABLES
The following examples show how to use
org.pentaho.di.core.Const#INTERNAL_JOB_VARIABLES .
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: JobExecutionConfiguration.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void getUsedVariables( JobMeta jobMeta ) { Properties sp = new Properties(); VariableSpace space = Variables.getADefaultVariableSpace(); String[] keys = space.listVariables(); for ( int i = 0; i < keys.length; i++ ) { sp.put( keys[i], space.getVariable( keys[i] ) ); } List<String> vars = jobMeta.getUsedVariables(); if ( vars != null && vars.size() > 0 ) { HashMap<String, String> newVariables = new HashMap<String, String>(); for ( int i = 0; i < vars.size(); i++ ) { String varname = vars.get( i ); if ( !varname.startsWith( Const.INTERNAL_VARIABLE_PREFIX ) ) { // add all new non-internal variables to newVariablesMap newVariables.put( varname, Const.NVL( variables.get( varname ), sp.getProperty( varname, "" ) ) ); } } // variables.clear(); variables.putAll( newVariables ); } // Also add the internal job variables if these are set... // for ( String variableName : Const.INTERNAL_JOB_VARIABLES ) { String value = jobMeta.getVariable( variableName ); if ( !Utils.isEmpty( value ) ) { variables.put( variableName, value ); } } }
Example 2
Source File: TransExecutionConfiguration.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void getAllVariables( TransMeta transMeta ) { Properties sp = new Properties(); VariableSpace space = Variables.getADefaultVariableSpace(); String[] keys = space.listVariables(); for ( int i = 0; i < keys.length; i++ ) { sp.put( keys[i], space.getVariable( keys[i] ) ); } String[] vars = transMeta.listVariables(); if ( vars != null && vars.length > 0 ) { HashMap<String, String> newVariables = new HashMap<String, String>(); for ( int i = 0; i < vars.length; i++ ) { String varname = vars[i]; newVariables.put( varname, Const.NVL( variables.get( varname ), sp.getProperty( varname, "" ) ) ); } // variables.clear(); variables.putAll( newVariables ); } // Also add the internal job variables if these are set... // for ( String variableName : Const.INTERNAL_JOB_VARIABLES ) { String value = transMeta.getVariable( variableName ); if ( !Utils.isEmpty( value ) ) { variables.put( variableName, value ); } } }
Example 3
Source File: TransExecutionConfiguration.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void getUsedVariables( TransMeta transMeta ) { Properties sp = new Properties(); VariableSpace space = Variables.getADefaultVariableSpace(); String[] keys = space.listVariables(); for ( int i = 0; i < keys.length; i++ ) { sp.put( keys[i], space.getVariable( keys[i] ) ); } List<String> vars = transMeta.getUsedVariables(); if ( vars != null && vars.size() > 0 ) { HashMap<String, String> newVariables = new HashMap<String, String>(); for ( int i = 0; i < vars.size(); i++ ) { String varname = vars.get( i ); if ( !varname.startsWith( Const.INTERNAL_VARIABLE_PREFIX ) ) { newVariables.put( varname, Const.NVL( variables.get( varname ), sp.getProperty( varname, "" ) ) ); } } // variables.clear(); variables.putAll( newVariables ); } // Also add the internal job variables if these are set... // for ( String variableName : Const.INTERNAL_JOB_VARIABLES ) { String value = transMeta.getVariable( variableName ); if ( !Utils.isEmpty( value ) ) { variables.put( variableName, value ); } } }
Example 4
Source File: StepWithMappingMetaTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test @PrepareForTest( StepWithMappingMeta.class ) public void replaceVariablesWithJobInternalVariablesTest() { String variableOverwrite = "paramOverwrite"; String variableChildOnly = "childValueVariable"; String [] jobVariables = Const.INTERNAL_JOB_VARIABLES; VariableSpace ChildVariables = new Variables(); VariableSpace replaceByParentVariables = new Variables(); for ( String internalVariable : jobVariables ) { ChildVariables.setVariable( internalVariable, "childValue" ); replaceByParentVariables.setVariable( internalVariable, "parentValue" ); } ChildVariables.setVariable( variableChildOnly, "childValueVariable" ); ChildVariables.setVariable( variableOverwrite, "childNotInternalValue" ); replaceByParentVariables.setVariable( variableOverwrite, "parentNotInternalValue" ); StepWithMappingMeta.replaceVariableValues( ChildVariables, replaceByParentVariables ); // do not replace internal variables Assert.assertEquals( "childValue", ChildVariables.getVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY ) ); // replace non internal variables Assert.assertEquals( "parentNotInternalValue", ChildVariables.getVariable( variableOverwrite ) ); // keep child only variables Assert.assertEquals( variableChildOnly, ChildVariables.getVariable( variableChildOnly ) ); }
Example 5
Source File: JobGraph.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public static void copyInternalJobVariables( JobMeta sourceJobMeta, TransMeta targetTransMeta ) { // Also set some internal JOB variables... // String[] internalVariables = Const.INTERNAL_JOB_VARIABLES; for ( String variableName : internalVariables ) { targetTransMeta.setVariable( variableName, sourceJobMeta.getVariable( variableName ) ); } }