Search in sources :

Example 16 with AbstractMeta

use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.

the class Spoon method setShellText.

public void setShellText() {
    if (shell.isDisposed()) {
        return;
    }
    String filename = null;
    String name = null;
    String version = null;
    ChangedFlagInterface changed = null;
    boolean versioningEnabled = true;
    AbstractMeta meta = getActiveJob() != null ? getActiveJob() : getActiveTransformation();
    if (meta != null) {
        changed = meta;
        filename = meta.getFilename();
        name = meta.getName();
        version = meta.getObjectRevision() == null ? null : meta.getObjectRevision().getName();
        try {
            versioningEnabled = isVersionEnabled(rep, meta);
        } catch (KettleRepositoryLostException krle) {
            handleRepositoryLost(krle);
        }
    }
    String text = "";
    if (rep != null) {
        text += APP_TITLE + " - [" + getRepositoryName() + "] ";
    } else {
        text += APP_TITLE + " - ";
    }
    if (Utils.isEmpty(name)) {
        if (!Utils.isEmpty(filename)) {
            text += filename;
        } else {
            String tab = getActiveTabText();
            if (!Utils.isEmpty(tab)) {
                text += tab;
            } else {
                // "[no name]"
                text += BaseMessages.getString(PKG, "Spoon.Various.NoName");
            }
        }
    } else {
        text += name;
    }
    if (versioningEnabled && !Utils.isEmpty(version)) {
        text += " v" + version;
    }
    if (changed != null && changed.hasChanged()) {
        text += " " + BaseMessages.getString(PKG, "Spoon.Various.Changed");
    }
    shell.setText(text);
    markTabsChanged(false);
}
Also used : ChangedFlagInterface(org.pentaho.di.core.changed.ChangedFlagInterface) AbstractMeta(org.pentaho.di.base.AbstractMeta) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException)

Example 17 with AbstractMeta

use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.

the class ConditionSelectionAdapterFileDialogTest method testWidgetSelectedHelper.

@Test
public void testWidgetSelectedHelper() {
    // SETUP
    LogChannelInterface log = mock(LogChannelInterface.class);
    TextVar textVar = mock(TextVar.class);
    AbstractMeta meta = mock(AbstractMeta.class);
    RepositoryUtility repositoryUtility = mock(RepositoryUtility.class);
    ExtensionPointWrapper extensionPointWrapper = mock(ExtensionPointWrapper.class);
    SelectionAdapterOptions options = new SelectionAdapterOptions(SelectionOperation.FILE);
    SelectionEvent event = mock(SelectionEvent.class);
    String testPath = "/home/devuser/some/path";
    when(meta.environmentSubstitute(testPath)).thenReturn(testPath);
    when(textVar.getText()).thenReturn(testPath);
    ArgumentCaptor textCapture = ArgumentCaptor.forClass(String.class);
    doNothing().when(textVar).setText((String) textCapture.capture());
    ConditionSelectionAdapterFileDialogTextVar testInstance = new ConditionSelectionAdapterFileDialogTextVar(log, textVar, meta, options, repositoryUtility, extensionPointWrapper, () -> SelectionOperation.FOLDER);
    testInstance.widgetSelected(event);
    assertTrue(testInstance.getSelectionOptions().getSelectionOperation() == SelectionOperation.FOLDER);
    options = new SelectionAdapterOptions(SelectionOperation.FILE);
    ConditionSelectionAdapterFileDialogTextVar testInstance2 = new ConditionSelectionAdapterFileDialogTextVar(log, textVar, meta, options, repositoryUtility, extensionPointWrapper, () -> SelectionOperation.FILE);
    testInstance.widgetSelected(event);
    assertTrue(testInstance2.getSelectionOptions().getSelectionOperation() == SelectionOperation.FILE);
}
Also used : ExtensionPointWrapper(org.pentaho.di.ui.core.events.dialog.extension.ExtensionPointWrapper) ArgumentCaptor(org.mockito.ArgumentCaptor) AbstractMeta(org.pentaho.di.base.AbstractMeta) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) TextVar(org.pentaho.di.ui.core.widget.TextVar) Test(org.junit.Test)

Example 18 with AbstractMeta

use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.

the class SelectionAdapterFileDialogTest method testIsConnectedToRepository.

@Test
public void testIsConnectedToRepository() {
    // SETUP
    LogChannelInterface log = mock(LogChannelInterface.class);
    StringBuilder textVar = new StringBuilder();
    AbstractMeta meta = mock(AbstractMeta.class);
    ExtensionPointWrapper extensionPointWrapper = mock(ExtensionPointWrapper.class);
    SelectionAdapterOptions options = new SelectionAdapterOptions(SelectionOperation.FILE);
    // True case:
    RepositoryUtility repositoryUtilityTrue = mock(RepositoryUtility.class);
    when(repositoryUtilityTrue.isConnectedToRepository()).thenReturn(true);
    SelectionAdapterFileDialog testInstance1 = createTestInstance(log, textVar, meta, options, repositoryUtilityTrue, extensionPointWrapper);
    assertTrue(testInstance1.isConnectedToRepository());
    // False case:
    RepositoryUtility repositoryUtilityFalse = mock(RepositoryUtility.class);
    when(repositoryUtilityFalse.isConnectedToRepository()).thenReturn(false);
    SelectionAdapterFileDialog testInstance2 = createTestInstance(log, textVar, meta, options, repositoryUtilityFalse, extensionPointWrapper);
    assertFalse(testInstance2.isConnectedToRepository());
}
Also used : ExtensionPointWrapper(org.pentaho.di.ui.core.events.dialog.extension.ExtensionPointWrapper) AbstractMeta(org.pentaho.di.base.AbstractMeta) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) Test(org.junit.Test)

Example 19 with AbstractMeta

use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.

the class SelectionAdapterFileDialogTest method testApplyRelativePathEnvVar.

@Test
public void testApplyRelativePathEnvVar() throws IOException {
    // SETUP
    LogChannelInterface log = mock(LogChannelInterface.class);
    StringBuilder textVar = new StringBuilder();
    AbstractMeta meta = mock(AbstractMeta.class);
    RepositoryUtility repositoryUtility = mock(RepositoryUtility.class);
    ExtensionPointWrapper extensionPointWrapper = mock(ExtensionPointWrapper.class);
    SelectionAdapterOptions options = new SelectionAdapterOptions(SelectionOperation.FILE);
    File testFile = temporaryFolder.newFile("testFileName");
    String testPath = testFile.getPath();
    when(meta.environmentSubstitute(testPath)).thenReturn(testPath);
    SelectionAdapterFileDialog testInstance1 = createTestInstance(log, textVar, meta, options, repositoryUtility, extensionPointWrapper);
    testInstance1.setText(testPath);
    String pathWithCurrentDirVar = testInstance1.applyRelativePathEnvVar(testPath);
    assertEquals(testPath, pathWithCurrentDirVar);
    when(meta.getFilename()).thenReturn(testPath);
    pathWithCurrentDirVar = testInstance1.applyRelativePathEnvVar(testPath);
    assertEquals("${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}/testFileName", pathWithCurrentDirVar);
}
Also used : ExtensionPointWrapper(org.pentaho.di.ui.core.events.dialog.extension.ExtensionPointWrapper) AbstractMeta(org.pentaho.di.base.AbstractMeta) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) File(java.io.File) Test(org.junit.Test)

Example 20 with AbstractMeta

use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.

the class SelectionAdapterFileDialogTest method testResolveFile.

@Test
public void testResolveFile() throws Exception {
    String unresolvedPath = "{SOME_VAR}/some/path";
    String resolvedPath = "/home/devuser/some/path";
    AbstractMeta abstractMeta = mock(AbstractMeta.class);
    when(abstractMeta.environmentSubstitute(unresolvedPath)).thenReturn(resolvedPath);
    assertNotNull(testInstance.resolveFile(abstractMeta, unresolvedPath));
}
Also used : AbstractMeta(org.pentaho.di.base.AbstractMeta) Test(org.junit.Test)

Aggregations

AbstractMeta (org.pentaho.di.base.AbstractMeta)50 Test (org.junit.Test)18 KettleException (org.pentaho.di.core.exception.KettleException)10 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)7 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)6 JobMeta (org.pentaho.di.job.JobMeta)6 TransMeta (org.pentaho.di.trans.TransMeta)6 FileObject (org.apache.commons.vfs2.FileObject)5 ExtensionPointWrapper (org.pentaho.di.ui.core.events.dialog.extension.ExtensionPointWrapper)5 SlaveServer (org.pentaho.di.cluster.SlaveServer)4 EngineMetaInterface (org.pentaho.di.core.EngineMetaInterface)4 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 RunConfiguration (org.pentaho.di.engine.configuration.api.RunConfiguration)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 EmbeddedMetaStore (org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore)3 ExtensionPoint (org.pentaho.di.core.extension.ExtensionPoint)3 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)3 EmbeddedRunConfigurationManager (org.pentaho.di.engine.configuration.impl.EmbeddedRunConfigurationManager)3 RunConfigurationManager (org.pentaho.di.engine.configuration.impl.RunConfigurationManager)3 RepositoryObject (org.pentaho.di.repository.RepositoryObject)3