Search in sources :

Example 86 with RepositoryDirectoryInterface

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

the class TransExecutorStepAnalyzerTest method testCustomAnalyze_repoFile.

@Test
public void testCustomAnalyze_repoFile() throws Exception {
    when(meta.getDirectoryPath()).thenReturn("/home/admin");
    when(meta.getTransName()).thenReturn("my");
    Repository repo = mock(Repository.class);
    RepositoryDirectoryInterface repoDir = mock(RepositoryDirectoryInterface.class);
    when(repo.findDirectory(anyString())).thenReturn(repoDir);
    when(repo.loadTransformation(anyString(), eq(repoDir), any(ProgressMonitorListener.class), anyBoolean(), anyString())).thenReturn(childTransMeta);
    when(parentTransMeta.getRepository()).thenReturn(repo);
    doReturn(childTransMeta).when(spyAnalyzer).getSubTransMeta(anyString());
    when(childTransMeta.getPathAndName()).thenReturn("/home/admin/my");
    when(childTransMeta.getDefaultExtension()).thenReturn("ktr");
    when(meta.getSpecificationMethod()).thenReturn(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
    // don't bother running the connectX methods, we'll test those later
    doNothing().when(spyAnalyzer).connectToSubTransInputFields(eq(meta), any(TransMeta.class), any(IMetaverseNode.class), any(IComponentDescriptor.class));
    doNothing().when(spyAnalyzer).connectToSubTransOutputFields(eq(meta), any(TransMeta.class), any(IMetaverseNode.class), any(IComponentDescriptor.class));
    spyAnalyzer.customAnalyze(meta, node);
    verify(node).setProperty(eq(TransExecutorStepAnalyzer.TRANSFORMATION_TO_EXECUTE), Mockito.contains("/home/admin/my.ktr"));
    // we should have one link created that "executes" the sub transformation
    verify(builder, times(1)).addLink(eq(node), eq(DictionaryConst.LINK_EXECUTES), any(IMetaverseNode.class));
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) Repository(org.pentaho.di.repository.Repository) IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) ProgressMonitorListener(org.pentaho.di.core.ProgressMonitorListener) Test(org.junit.Test)

Example 87 with RepositoryDirectoryInterface

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

the class ExecuteTransServlet method loadTransformation.

private TransMeta loadTransformation(Repository repository, String trans) throws KettleException {
    if (repository == null) {
        // Without a repository it's a filename --> file:///foo/bar/trans.ktr
        // 
        TransMeta transMeta = new TransMeta(trans);
        return transMeta;
    } else {
        // With a repository we need to load it from /foo/bar/Transformation
        // We need to extract the folder name from the path in front of the name...
        // 
        String directoryPath;
        String name;
        int lastSlash = trans.lastIndexOf(RepositoryDirectory.DIRECTORY_SEPARATOR);
        if (lastSlash < 0) {
            directoryPath = "/";
            name = trans;
        } else {
            directoryPath = trans.substring(0, lastSlash);
            name = trans.substring(lastSlash + 1);
        }
        RepositoryDirectoryInterface directory = repository.loadRepositoryDirectoryTree().findDirectory(directoryPath);
        if (directory == null) {
            throw new KettleException("Unable to find directory path '" + directoryPath + "' in the repository");
        }
        ObjectId transformationID = repository.getTransformationID(name, directory);
        if (transformationID == null) {
            throw new KettleException("Unable to find transformation '" + name + "' in directory :" + directory);
        }
        TransMeta transMeta = repository.loadTransformation(transformationID, null);
        return transMeta;
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException) ObjectId(org.pentaho.di.repository.ObjectId) TransMeta(org.pentaho.di.trans.TransMeta)

Example 88 with RepositoryDirectoryInterface

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

the class TransExecutorMeta method lookupRepositoryReferences.

@Override
public void lookupRepositoryReferences(Repository repository) throws KettleException {
    // The correct reference is stored in the trans name and directory attributes...
    // 
    RepositoryDirectoryInterface repositoryDirectoryInterface = RepositoryImportLocation.getRepositoryImportLocation().findDirectory(directoryPath);
    transObjectId = repository.getTransformationID(transName, repositoryDirectoryInterface);
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface)

Example 89 with RepositoryDirectoryInterface

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

the class RunJobServlet method loadJob.

private JobMeta loadJob(Repository repository, String job) throws KettleException {
    if (repository == null) {
        throw new KettleException("Repository required.");
    } else {
        synchronized (repository) {
            // With a repository we need to load it from /foo/bar/Transformation
            // We need to extract the folder name from the path in front of the
            // name...
            // 
            String directoryPath;
            String name;
            int lastSlash = job.lastIndexOf(RepositoryDirectory.DIRECTORY_SEPARATOR);
            if (lastSlash < 0) {
                directoryPath = "/";
                name = job;
            } else {
                directoryPath = job.substring(0, lastSlash);
                name = job.substring(lastSlash + 1);
            }
            RepositoryDirectoryInterface directory = repository.loadRepositoryDirectoryTree().findDirectory(directoryPath);
            ObjectId jobID = repository.getJobId(name, directory);
            JobMeta transJob = repository.loadJob(jobID, null);
            return transJob;
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) JobMeta(org.pentaho.di.job.JobMeta) ObjectId(org.pentaho.di.repository.ObjectId)

Example 90 with RepositoryDirectoryInterface

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

the class SimpleMappingMeta method lookupRepositoryReferences.

@Override
public void lookupRepositoryReferences(Repository repository) throws KettleException {
    // The correct reference is stored in the trans name and directory attributes...
    // 
    RepositoryDirectoryInterface repositoryDirectoryInterface = RepositoryImportLocation.getRepositoryImportLocation().findDirectory(directoryPath);
    transObjectId = repository.getTransformationID(transName, repositoryDirectoryInterface);
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface)

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