本文整理了Java中org.pentaho.di.core.variables.Variables.setVariable()
方法的一些代码示例,展示了Variables.setVariable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Variables.setVariable()
方法的具体详情如下:
包路径:org.pentaho.di.core.variables.Variables
类名称:Variables
方法名:setVariable
暂无
代码示例来源:origin: pentaho/pentaho-kettle
/**
* @return new var space with follow vars from parent space or just new space if parent was null
*
* {@link org.pentaho.di.core.Const#INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY}
* {@link org.pentaho.di.core.Const#INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY}
* {@link org.pentaho.di.core.Const#INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY}
* {@link org.pentaho.di.core.Const#INTERNAL_VARIABLE_JOB_FILENAME_NAME}
*/
private static VariableSpace getVarSpaceOnlyWithRequiredParentVars( VariableSpace parentSpace ) {
Variables tmpSpace = new Variables();
if ( parentSpace != null ) {
tmpSpace.setVariable( INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY, parentSpace.getVariable( INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY ) );
tmpSpace.setVariable( INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, parentSpace.getVariable( INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY ) );
tmpSpace.setVariable( INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, parentSpace.getVariable( INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY ) );
tmpSpace.setVariable( INTERNAL_VARIABLE_JOB_FILENAME_NAME, parentSpace.getVariable( INTERNAL_VARIABLE_JOB_FILENAME_NAME ) );
}
return tmpSpace;
}
代码示例来源:origin: pentaho/pentaho-kettle
tmpSpace.setVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY, directory.toString() );
tmpSpace.setVariable( Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, directory.toString() );
tmpSpace.setVariable( Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, directory.toString() );
} else if ( filename != null ) {
try {
tmpSpace.setVariable( Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, fileName.getBaseName() );
tmpSpace.setVariable( Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, fileDir.getURI() );
tmpSpace.setVariable( Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, fileDir.getURI() );
tmpSpace.setVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY, fileDir.getURI() );
} catch ( Exception e ) {
代码示例来源:origin: pentaho/pentaho-kettle
private String reapplyCurrentDir( String oldCurrentDir, String newCurrentDir, String path ) {
Variables vars = new Variables();
vars.setVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY, oldCurrentDir );
String newPath = vars.environmentSubstitute( path );
return getPath( newCurrentDir, newPath );
}
代码示例来源:origin: pentaho/pentaho-kettle
String variable = (String) key;
String value = variables.environmentSubstitute( (String) kettleProperties.get( key ) );
variables.setVariable( variable, value );
代码示例来源:origin: pentaho/pentaho-kettle
@Test
public void testPassEmbeddedMetastoreKey() {
Variables mockVariables = mock( Variables.class );
namedClusterEmbedManager.passEmbeddedMetastoreKey( mockVariables, "key" );
verify( mockVariables ).setVariable( anyString(), anyString() );
}
代码示例来源:origin: pentaho/pentaho-kettle
@Test
public void testCheckErrorsOnVariables() {
List<CheckResultInterface> remarks = new ArrayList<>();
Variables space = new Variables();
space.setVariable( "something", "1000" );
meta.setBatchSize( "${something}" );
meta.setBatchDuration( "0" );
meta.check( remarks, null, null, null, null, null, null, space, null, null );
assertEquals( 0, remarks.size() );
}
代码示例来源:origin: pentaho/pentaho-kettle
@Test
public void testCheckErrorsOnVariablesSubstituteError() {
List<CheckResultInterface> remarks = new ArrayList<>();
Variables space = new Variables();
space.setVariable( "something", "0" );
meta.setBatchSize( "${something}" );
meta.setBatchDuration( "${something}" );
meta.check( remarks, null, null, null, null, null, null, space, null, null );
assertEquals( 1, remarks.size() );
assertEquals( "The \"Number of records\" and \"Duration\" fields can’t both be set to 0. Please set a value of 1 "
+ "or higher for one of the fields.", remarks.get( 0 ).getText() );
testRoundTrip( meta );
}
代码示例来源:origin: pentaho/pentaho-kettle
@Test
public void testNullMin() throws Exception {
variables.setVariable( Const.KETTLE_AGGREGATION_MIN_NULL_IS_VALUED, "Y" );
addColumn( new ValueMetaInteger( "intg" ), null, 0L, 1L, -1L );
addColumn( new ValueMetaString( "str" ), "A", null, "B", null );
aggregates = Maps.toMap( ImmutableList.of( "min", "max" ), Functions.forMap( default_aggregates ) );
RowMetaAndData output = runStep();
assertThat( output.getInteger( "intg_min" ), nullValue() );
assertThat( output.getInteger( "intg_max" ), is( 1L ) );
assertThat( output.getString( "str_min", null ), nullValue() );
assertThat( output.getString( "str_max", "invalid" ), is( "B" ) );
}
代码示例来源:origin: pentaho/pentaho-kettle
@Test
public void testNullsAreZeroCompatible() throws Exception {
variables.setVariable( Const.KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO, "Y" );
variables.setVariable( Const.KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE, "Y" );
addColumn( new ValueMetaInteger( "nul" ) );
addColumn( new ValueMetaInteger( "both" ), -2L, 0L, null, 10L );
RowMetaAndData output = runStep();
assertThat( output.getInteger( "nul_min" ), is( 0L ) );
assertThat( output.getInteger( "nul_max" ), is( 0L ) );
assertThat( output.getInteger( "nul_sum" ), is( 0L ) );
assertThat( output.getInteger( "nul_ave" ), is( 0L ) );
assertThat( output.getInteger( "nul_count" ), is( 0L ) );
assertThat( output.getInteger( "nul_count_any" ), is( 4L ) );
assertThat( output.getInteger( "nul_count_distinct" ), is( 0L ) );
assertThat( output.getInteger( "both_max" ), is( 10L ) );
assertThat( output.getInteger( "both_min" ), is( -2L ) );
assertThat( output.getInteger( "both_sum" ), is( 8L ) );
assertThat( output.getInteger( "both_ave" ), is( 3L ) );
assertThat( output.getInteger( "both_count" ), is( 3L ) );
assertThat( output.getInteger( "both_count_any" ), is( 4L ) );
assertThat( output.getInteger( "both_count_distinct" ), is( 3L ) );
}
代码示例来源:origin: pentaho/pentaho-kettle
@Test
public void testNullsAreZeroDefault() throws Exception {
variables.setVariable( Const.KETTLE_AGGREGATION_ALL_NULLS_ARE_ZERO, "Y" );
addColumn( new ValueMetaInteger( "nul" ) );
addColumn( new ValueMetaInteger( "both" ), -2L, 0L, null, 10L );
addColumn( new ValueMetaNumber( "both_num" ), -2.0, 0.0, null, 10.0 );
RowMetaAndData output = runStep();
assertThat( output.getInteger( "nul_min" ), is( 0L ) );
assertThat( output.getInteger( "nul_max" ), is( 0L ) );
assertThat( output.getInteger( "nul_sum" ), is( 0L ) );
assertThat( output.getInteger( "nul_ave" ), is( 0L ) );
assertThat( output.getInteger( "nul_count" ), is( 0L ) );
assertThat( output.getInteger( "nul_count_any" ), is( 4L ) );
assertThat( output.getInteger( "nul_count_distinct" ), is( 0L ) );
assertThat( output.getInteger( "both_max" ), is( 10L ) );
assertThat( output.getInteger( "both_min" ), is( -2L ) );
assertThat( output.getInteger( "both_sum" ), is( 8L ) );
assertThat( output.getInteger( "both_ave" ), is( 2L ) );
assertThat( output.getInteger( "both_count" ), is( 3L ) );
assertThat( output.getInteger( "both_count_any" ), is( 4L ) );
assertThat( output.getInteger( "both_count_distinct" ), is( 3L ) );
assertThat( output.getNumber( "both_num_max", Double.NaN ), is( 10.0 ) );
assertThat( output.getNumber( "both_num_min", Double.NaN ), is( -2.0 ) );
assertThat( output.getNumber( "both_num_sum", Double.NaN ), is( 8.0 ) );
assertEquals( 2.666666, output.getNumber( "both_num_ave", Double.NaN ), 0.000001 /* delta */ );
assertThat( output.getInteger( "both_num_count" ), is( 3L ) );
assertThat( output.getInteger( "both_num_count_any" ), is( 4L ) );
assertThat( output.getInteger( "both_num_count_distinct" ), is( 3L ) );
}
代码示例来源:origin: pentaho/pentaho-kettle
@Test
public void testCompatibility() throws KettleException {
variables.setVariable( Const.KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE, "Y" );
代码示例来源:origin: pentaho/pentaho-kettle
@Test
public void testFilterVariables() throws Exception {
initByFile( "default.csv" );
Variables vars = new Variables();
vars.setVariable( "VAR_TEST", "second" );
data.filterProcessor =
new TextFileFilterProcessor( new TextFileFilter[] { new TextFileFilter( 0, "${VAR_TEST}", false, false ) },
vars );
setFields( new BaseFileField( "f1", -1, -1 ), new BaseFileField( "f2", -1, -1 ),
new BaseFileField( "f2", -1, -1 ) );
process();
check( new Object[][] { { "first", "1", "1.1" }, { "third", "3", "3.3" } } );
}
代码示例来源:origin: pentaho/pentaho-kettle
vars.setVariable( Const.KETTLE_COMPATIBILITY_MEMORY_GROUP_BY_SUM_AVERAGE_RETURN_NUMBER_TYPE, "Y" );
meta.getFields( rm, stepName, null, null, vars, null, null );
assertNotNull( rm );
内容来源于网络,如有侵权,请联系作者删除!