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));
}
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;
}
}
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);
}
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;
}
}
}
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);
}
Aggregations