use of org.pentaho.di.core.variables.VariableSpace in project pentaho-kettle by pentaho.
the class RunConfigurationRunExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface logChannelInterface, Object o) throws KettleException {
ExecutionConfiguration executionConfiguration = (ExecutionConfiguration) ((Object[]) o)[0];
AbstractMeta meta = (AbstractMeta) ((Object[]) o)[1];
VariableSpace variableSpace = (VariableSpace) ((Object[]) o)[2];
Repository repository = (Repository) ((Object[]) o)[3];
EmbeddedMetaStore embeddedMetaStore = meta.getEmbeddedMetaStore();
RunConfiguration runConfiguration = runConfigurationManager.load(executionConfiguration.getRunConfiguration());
if (runConfiguration == null) {
RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build(embeddedMetaStore);
runConfiguration = embeddedRunConfigurationManager.load(executionConfiguration.getRunConfiguration());
}
if (runConfiguration != null) {
RunConfigurationExecutor runConfigurationExecutor = runConfigurationManager.getExecutor(runConfiguration.getType());
if (runConfigurationExecutor != null) {
runConfigurationExecutor.execute(runConfiguration, executionConfiguration, meta, variableSpace, repository);
}
} else {
String name = "";
if (variableSpace instanceof TransMeta) {
name = ((TransMeta) variableSpace).getFilename();
}
throw new KettleException(BaseMessages.getString(PKG, "RunConfigurationRunExtensionPoint.ConfigNotFound.Error", name, executionConfiguration.getRunConfiguration(), "{0}"));
}
}
use of org.pentaho.di.core.variables.VariableSpace in project pentaho-kettle by pentaho.
the class SpoonDBDelegate method newConnection.
public void newConnection(HasDatabasesInterface hasDatabasesInterface) {
DatabaseMeta databaseMeta = new DatabaseMeta();
if (hasDatabasesInterface instanceof VariableSpace) {
databaseMeta.shareVariablesWith((VariableSpace) hasDatabasesInterface);
} else {
databaseMeta.initializeVariablesFrom(null);
}
getDatabaseDialog().setDatabaseMeta(databaseMeta);
String con_name = getDatabaseDialog().open();
if (!Utils.isEmpty(con_name)) {
con_name = con_name.trim();
databaseMeta.setName(con_name);
databaseMeta.setDisplayName(con_name);
databaseMeta = getDatabaseDialog().getDatabaseMeta();
if (databaseMeta.findDatabase(hasDatabasesInterface.getDatabases(), con_name) == null) {
hasDatabasesInterface.addDatabase(databaseMeta);
spoon.addUndoNew((UndoInterface) hasDatabasesInterface, new DatabaseMeta[] { (DatabaseMeta) databaseMeta.clone() }, new int[] { hasDatabasesInterface.indexOfDatabase(databaseMeta) });
if (spoon.rep != null) {
try {
if (!spoon.rep.getSecurityProvider().isReadOnly()) {
// spoon.rep.getDatabaseID( )
spoon.rep.save(databaseMeta, Const.VERSION_COMMENT_INITIAL_VERSION, null);
} else {
throw new KettleException(BaseMessages.getString(PKG, "Spoon.Dialog.Exception.ReadOnlyRepositoryUser"));
}
} catch (KettleException e) {
new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorSavingConnection.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorSavingConnection.Message", databaseMeta.getName()), e);
}
}
spoon.refreshTree();
} else {
DatabaseDialog.showDatabaseExistsDialog(spoon.getShell(), databaseMeta);
}
}
}
use of org.pentaho.di.core.variables.VariableSpace in project pentaho-kettle by pentaho.
the class MetaInjectMetaTest method testLoadMappingMetaWhenConnectedToRep.
@Test
public void testLoadMappingMetaWhenConnectedToRep() throws Exception {
String variablePath = "Internal.Entry.Current.Directory";
String virtualDir = "/testFolder/test";
String fileName = "testTrans.ktr";
VariableSpace variables = new Variables();
variables.setVariable(variablePath, virtualDir);
MetaInjectMeta metaInjectMetaMock = mock(MetaInjectMeta.class);
when(metaInjectMetaMock.getSpecificationMethod()).thenReturn(ObjectLocationSpecificationMethod.FILENAME);
when(metaInjectMetaMock.getFileName()).thenReturn("${" + variablePath + "}/" + fileName);
// mock repo and answers
Repository rep = mock(Repository.class);
doAnswer(invocation -> {
String originalArgument = (String) (invocation.getArguments())[0];
// be sure that the variable was replaced by real path
assertEquals(originalArgument, virtualDir);
return null;
}).when(rep).findDirectory(anyString());
doAnswer(invocation -> {
String originalArgument = (String) (invocation.getArguments())[0];
// be sure that transformation name was resolved correctly
assertEquals(originalArgument, fileName);
return mock(TransMeta.class);
}).when(rep).loadTransformation(anyString(), any(RepositoryDirectoryInterface.class), any(ProgressMonitorListener.class), anyBoolean(), anyString());
assertNotNull(MetaInjectMeta.loadTransformationMeta(metaInjectMetaMock, rep, null, variables));
}
use of org.pentaho.di.core.variables.VariableSpace in project pentaho-kettle by pentaho.
the class StringOperationsMetaTest method testGetFields.
@Test
public void testGetFields() throws Exception {
StringOperationsMeta meta = new StringOperationsMeta();
meta.allocate(1);
meta.setFieldInStream(new String[] { "field1" });
RowMetaInterface rowMetaInterface = new RowMeta();
ValueMetaInterface valueMeta = new ValueMetaString("field1");
valueMeta.setStorageMetadata(new ValueMetaString("field1"));
valueMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
rowMetaInterface.addValueMeta(valueMeta);
VariableSpace space = mock(VariableSpace.class);
meta.getFields(rowMetaInterface, "STRING_OPERATIONS", null, null, space, null, null);
RowMetaInterface expectedRowMeta = new RowMeta();
expectedRowMeta.addValueMeta(new ValueMetaString("field1"));
assertEquals(expectedRowMeta.toString(), rowMetaInterface.toString());
}
Aggregations