Search in sources :

Example 1 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.

the class SingleThreaderDialog method loadTransformation.

private void loadTransformation() throws KettleException {
    String filename = wPath.getText();
    if (repository != null) {
        specificationMethod = ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME;
    } else {
        specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
    }
    switch(specificationMethod) {
        case FILENAME:
            if (Utils.isEmpty(filename)) {
                return;
            }
            if (!filename.endsWith(".ktr")) {
                filename = filename + ".ktr";
                wPath.setText(filename);
            }
            loadFileTrans(filename);
            break;
        case REPOSITORY_BY_NAME:
            if (Utils.isEmpty(filename)) {
                return;
            }
            if (filename.endsWith(".ktr")) {
                filename = filename.replace(".ktr", "");
                wPath.setText(filename);
            }
            String transPath = transMeta.environmentSubstitute(filename);
            String realTransname = transPath;
            String realDirectory = "";
            int index = transPath.lastIndexOf("/");
            if (index != -1) {
                realTransname = transPath.substring(index + 1);
                realDirectory = transPath.substring(0, index);
            }
            if (Utils.isEmpty(realDirectory) || Utils.isEmpty(realTransname)) {
                throw new KettleException(BaseMessages.getString(PKG, "SingleThreaderDialog.Exception.NoValidMappingDetailsFound"));
            }
            RepositoryDirectoryInterface repdir = repository.findDirectory(realDirectory);
            if (repdir == null) {
                throw new KettleException(BaseMessages.getString(PKG, "SingleThreaderDialog.Exception.UnableToFindRepositoryDirectory)"));
            }
            loadRepositoryTrans(realTransname, repdir);
            break;
        case REPOSITORY_BY_REFERENCE:
            // load the last version
            mappingTransMeta = repository.loadTransformation(referenceObjectId, null);
            mappingTransMeta.clearChanged();
            break;
        default:
            break;
    }
    wInjectStep.setText(getInjectorStep(mappingTransMeta));
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface)

Example 2 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.

the class SpoonTest method testVersioningCheckingOnServer.

@Test
public void testVersioningCheckingOnServer() throws Exception {
    Repository repository = Mockito.mock(Repository.class);
    RepositorySecurityProvider securityProvider = Mockito.mock(RepositorySecurityProvider.class);
    Mockito.doReturn(securityProvider).when(repository).getSecurityProvider();
    EngineMetaInterface jobTransMeta = Mockito.spy(new TransMeta());
    RepositoryDirectoryInterface repositoryDirectoryInterface = Mockito.mock(RepositoryDirectoryInterface.class);
    Mockito.doReturn("/home").when(repositoryDirectoryInterface).toString();
    Mockito.doReturn("trans").when(jobTransMeta).getName();
    Mockito.doReturn(RepositoryObjectType.TRANSFORMATION).when(jobTransMeta).getRepositoryElementType();
    Mockito.doReturn(true).when(securityProvider).isVersioningEnabled(Mockito.anyString());
    boolean result = Spoon.isVersionEnabled(repository, jobTransMeta);
    Assert.assertTrue(result);
}
Also used : RepositorySecurityProvider(org.pentaho.di.repository.RepositorySecurityProvider) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) Repository(org.pentaho.di.repository.Repository) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) Test(org.junit.Test)

Example 3 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.

the class SpoonTest method testVersioningDisabled.

@Test
public void testVersioningDisabled() throws Exception {
    Repository repository = Mockito.mock(Repository.class);
    RepositorySecurityProvider securityProvider = Mockito.mock(RepositorySecurityProvider.class);
    Mockito.doReturn(securityProvider).when(repository).getSecurityProvider();
    EngineMetaInterface jobTransMeta = Mockito.spy(new TransMeta());
    RepositoryDirectoryInterface repositoryDirectoryInterface = Mockito.mock(RepositoryDirectoryInterface.class);
    Mockito.doReturn("/home").when(repositoryDirectoryInterface).toString();
    Mockito.doReturn("trans").when(jobTransMeta).getName();
    Mockito.doReturn(RepositoryObjectType.TRANSFORMATION).when(jobTransMeta).getRepositoryElementType();
    Mockito.doReturn(false).when(jobTransMeta).getVersioningEnabled();
    boolean result = Spoon.isVersionEnabled(repository, jobTransMeta);
    Assert.assertFalse(result);
    Mockito.verify(securityProvider, Mockito.never()).isVersioningEnabled(Mockito.anyString());
}
Also used : RepositorySecurityProvider(org.pentaho.di.repository.RepositorySecurityProvider) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) Repository(org.pentaho.di.repository.Repository) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) Test(org.junit.Test)

Example 4 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.

the class DialogUtilsTest method testPathAndName.

private void testPathAndName(String path, String name, String expected) {
    RepositoryElementMetaInterface object = mock(RepositoryElementMetaInterface.class);
    RepositoryDirectoryInterface directory = mock(RepositoryDirectoryInterface.class);
    when(directory.getPath()).thenReturn(path);
    when(object.getRepositoryDirectory()).thenReturn(directory);
    when(object.getName()).thenReturn(name);
    assertEquals(expected, getPathOf(object));
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Example 5 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.

the class DialogUtilsTest method nullDirectoryPath.

@Test
public void nullDirectoryPath() {
    RepositoryElementMetaInterface object = mock(RepositoryElementMetaInterface.class);
    RepositoryDirectoryInterface directory = mock(RepositoryDirectoryInterface.class);
    when(object.getRepositoryDirectory()).thenReturn(directory);
    assertNull(getPathOf(object));
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface) Test(org.junit.Test)

Aggregations

RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)163 KettleException (org.pentaho.di.core.exception.KettleException)68 Test (org.junit.Test)32 TransMeta (org.pentaho.di.trans.TransMeta)30 ObjectId (org.pentaho.di.repository.ObjectId)27 JobMeta (org.pentaho.di.job.JobMeta)23 Repository (org.pentaho.di.repository.Repository)22 ArrayList (java.util.ArrayList)17 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)17 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)15 IOException (java.io.IOException)14 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)13 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)11 RepositoryObject (org.pentaho.di.repository.RepositoryObject)11 FileObject (org.apache.commons.vfs2.FileObject)10 List (java.util.List)8 TreeItem (org.eclipse.swt.widgets.TreeItem)8 KettleFileException (org.pentaho.di.core.exception.KettleFileException)8 Date (java.util.Date)7 FileSystemException (org.apache.commons.vfs2.FileSystemException)7