use of org.pentaho.di.core.variables.VariableSpace in project pentaho-kettle by pentaho.
the class Spoon method fillVariables.
private void fillVariables(RowMetaAndData vars) {
TransMeta[] transMetas = getLoadedTransformations();
JobMeta[] jobMetas = getLoadedJobs();
if ((transMetas == null || transMetas.length == 0) && (jobMetas == null || jobMetas.length == 0)) {
return;
}
Properties sp = new Properties();
sp.putAll(System.getProperties());
VariableSpace space = Variables.getADefaultVariableSpace();
String[] keys = space.listVariables();
for (String key : keys) {
sp.put(key, space.getVariable(key));
}
for (TransMeta transMeta : transMetas) {
List<String> list = transMeta.getUsedVariables();
for (String varName : list) {
String varValue = sp.getProperty(varName, "");
if (vars.getRowMeta().indexOfValue(varName) < 0 && !varName.startsWith(Const.INTERNAL_VARIABLE_PREFIX)) {
vars.addValue(new ValueMetaString(varName), varValue);
}
}
}
for (JobMeta jobMeta : jobMetas) {
List<String> list = jobMeta.getUsedVariables();
for (String varName : list) {
String varValue = sp.getProperty(varName, "");
if (vars.getRowMeta().indexOfValue(varName) < 0 && !varName.startsWith(Const.INTERNAL_VARIABLE_PREFIX)) {
vars.addValue(new ValueMetaString(varName), varValue);
}
}
}
}
use of org.pentaho.di.core.variables.VariableSpace in project pentaho-metaverse by pentaho.
the class MongoDbResourceInfoTest method setUp.
@Before
public void setUp() throws Exception {
meta = mock(MongoDbMeta.class);
when(meta.getDbName()).thenReturn(null);
when(meta.getPort()).thenReturn(null);
when(meta.getHostnames()).thenReturn(null);
when(meta.getAuthenticationUser()).thenReturn(null);
when(meta.getAuthenticationPassword()).thenReturn(null);
when(meta.getUseAllReplicaSetMembers()).thenReturn(false);
when(meta.getUseKerberosAuthentication()).thenReturn(false);
when(meta.getConnectTimeout()).thenReturn(null);
when(meta.getSocketTimeout()).thenReturn(null);
when(meta.getCollection()).thenReturn(null);
StepMeta stepMeta = new StepMeta();
TransMeta transMeta = new TransMeta();
stepMeta.setParentTransMeta(transMeta);
VariableSpace variables = new Variables();
when(meta.getParentStepMeta()).thenReturn(stepMeta);
info = new MongoDbResourceInfo(meta);
}
use of org.pentaho.di.core.variables.VariableSpace in project pdi-dataservice-server-plugin by pentaho.
the class ParameterGeneration method setQueryParameter.
protected String setQueryParameter(String query, String parameterValue) {
VariableSpace varSpace = new Variables();
varSpace.setVariable(getParameterName(), parameterValue);
return varSpace.environmentSubstitute(query);
}
use of org.pentaho.di.core.variables.VariableSpace in project pdi-dataservice-server-plugin by pentaho.
the class MongoDbBasicValidation method checkStep.
@Override
public void checkStep(CheckStepsExtension checkStepExtension, DataServiceMeta dataServiceMeta, LogChannelInterface log) {
StepMeta stepMeta = checkStepExtension.getStepMetas()[0];
List<CheckResultInterface> remarks = checkStepExtension.getRemarks();
MongoDbInputMeta mongoDbMeta = (MongoDbInputMeta) checkStepExtension.getStepMetas()[0].getStepMetaInterface();
VariableSpace space = checkStepExtension.getVariableSpace();
checkOutputJson(stepMeta, remarks, mongoDbMeta);
checkPushdownParameter(stepMeta, remarks, mongoDbMeta, space);
checkParameterGenerationOptimizedMeta(checkStepExtension, dataServiceMeta, log);
}
use of org.pentaho.di.core.variables.VariableSpace in project pentaho-metaverse by pentaho.
the class JdbcResourceInfoTest method testDbMetaVarPort.
@Test
public void testDbMetaVarPort() throws Exception {
DatabaseMeta dbMeta = mock(DatabaseMeta.class);
DatabaseInterface dbInterface = mock(DatabaseInterface.class);
when(dbMeta.getDatabaseInterface()).thenReturn(dbInterface);
when(dbMeta.getAccessTypeDesc()).thenReturn("Native");
final VariableSpace vs = new Variables();
when(dbMeta.getDatabasePortNumberString()).thenReturn("${port_var}");
when(dbMeta.environmentSubstitute(any(String.class))).thenAnswer(new Answer<String>() {
public String answer(InvocationOnMock invocation) throws Throwable {
return vs.environmentSubstitute((String) invocation.getArguments()[0]);
}
});
// check if var replaced
vs.setVariable("port_var", "4321");
JdbcResourceInfo jdbcResourceInfo = new JdbcResourceInfo(dbMeta);
assertEquals(jdbcResourceInfo.getPort(), new Integer(4321));
// check no exception when empty
vs.setVariable("port_var", "");
jdbcResourceInfo = new JdbcResourceInfo(dbMeta);
}
Aggregations