use of org.pentaho.metaverse.api.IComponentDescriptor in project pentaho-metaverse by pentaho.
the class TransJobEntryAnalyzer method customAnalyze.
@Override
protected void customAnalyze(JobEntryTrans entry, IMetaverseNode rootNode) throws MetaverseAnalyzerException {
TransMeta subTransMeta = null;
JobMeta parentJobMeta = entry.getParentJob().getJobMeta();
// For some reason the JobMeta's variables have been reset by now, so re-activate them
parentJobMeta.activateParameters();
Repository repo = parentJobMeta.getRepository();
String transPath = null;
switch(entry.getSpecificationMethod()) {
case FILENAME:
try {
transPath = parentJobMeta.environmentSubstitute(entry.getFilename());
String normalized = KettleAnalyzerUtil.normalizeFilePath(transPath);
subTransMeta = getSubTransMeta(normalized);
transPath = normalized;
} catch (Exception e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found - " + transPath, e);
}
break;
case REPOSITORY_BY_NAME:
if (repo != null) {
String dir = parentJobMeta.environmentSubstitute(entry.getDirectory());
String file = parentJobMeta.environmentSubstitute(entry.getTransname());
try {
RepositoryDirectoryInterface rdi = repo.findDirectory(dir);
subTransMeta = repo.loadTransformation(file, rdi, null, true, null);
transPath = subTransMeta.getPathAndName() + "." + subTransMeta.getDefaultExtension();
} catch (KettleException e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found in repository - " + file, e);
}
} else {
throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
}
break;
case REPOSITORY_BY_REFERENCE:
if (repo != null) {
try {
subTransMeta = repo.loadTransformation(entry.getTransObjectId(), null);
transPath = subTransMeta.getPathAndName() + "." + subTransMeta.getDefaultExtension();
} catch (KettleException e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found by reference - " + entry.getTransObjectId(), e);
}
} else {
throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
}
break;
}
IComponentDescriptor ds = new MetaverseComponentDescriptor(subTransMeta.getName(), DictionaryConst.NODE_TYPE_TRANS, descriptor.getNamespace().getParentNamespace());
IMetaverseNode transformationNode = createNodeFromDescriptor(ds);
transformationNode.setProperty(DictionaryConst.PROPERTY_NAMESPACE, ds.getNamespaceId());
transformationNode.setProperty(DictionaryConst.PROPERTY_PATH, transPath);
transformationNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DOCUMENT);
metaverseBuilder.addLink(rootNode, DictionaryConst.LINK_EXECUTES, transformationNode);
}
use of org.pentaho.metaverse.api.IComponentDescriptor in project pentaho-metaverse by pentaho.
the class MongoDbConnectionAnalyzerTest method testBuildComponentDescriptor.
@Test
public void testBuildComponentDescriptor() throws Exception {
IComponentDescriptor dbDesc = analyzer.buildComponentDescriptor(mockDescriptor, mongoDbMeta);
assertNotNull(dbDesc);
assertEquals("db", dbDesc.getName());
}
use of org.pentaho.metaverse.api.IComponentDescriptor in project pentaho-metaverse by pentaho.
the class BaseKettleMetaverseComponentTest method testCreateNodeFromDescriptor.
@Test
public void testCreateNodeFromDescriptor() throws Exception {
String namespaceId = "{namespace: 'my namespace', name: 'my name', type: 'my type'}";
ILogicalIdGenerator idGenerator = DictionaryConst.LOGICAL_ID_GENERATOR_DEFAULT;
IComponentDescriptor descriptor = mock(IComponentDescriptor.class);
INamespace ns = mock(INamespace.class);
when(descriptor.getParentNamespace()).thenReturn(mock(INamespace.class));
when(descriptor.getNamespace()).thenReturn(ns);
when(ns.getNamespaceId()).thenReturn(namespaceId);
component.metaverseObjectFactory = spy(new MetaverseObjectFactory());
IMetaverseNode node = component.createNodeFromDescriptor(descriptor, idGenerator);
assertNotNull(node);
assertTrue(node.getLogicalId().contains(namespaceId));
}
use of org.pentaho.metaverse.api.IComponentDescriptor in project pentaho-metaverse by pentaho.
the class DatabaseConnectionAnalyzerTest method testBuildComponentDescriptor.
@Test
public void testBuildComponentDescriptor() throws Exception {
when(databaseMeta.getName()).thenReturn("connectionName");
when(mockDescriptor.getNamespace()).thenReturn(mock(INamespace.class));
when(mockDescriptor.getContext()).thenReturn(mock(IAnalysisContext.class));
IComponentDescriptor dbDesc = dbConnectionAnalyzer.buildComponentDescriptor(mockDescriptor, databaseMeta);
assertNotNull(dbDesc);
assertEquals("connectionName", dbDesc.getName());
}
use of org.pentaho.metaverse.api.IComponentDescriptor in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testGetInputFieldsWithException.
@Test
public void testGetInputFieldsWithException() {
analyzer = new StepAnalyzer() {
@Override
public void validateState(IComponentDescriptor descriptor, BaseStepMeta object) throws MetaverseAnalyzerException {
throw new MetaverseAnalyzerException("expected exception");
}
@Override
public Set<Class<? extends BaseStepMeta>> getSupportedSteps() {
return null;
}
@Override
protected Set getUsedFields(BaseStepMeta meta) {
// TODO Auto-generated method stub
return null;
}
@Override
protected void customAnalyze(BaseStepMeta meta, IMetaverseNode rootNode) throws MetaverseAnalyzerException {
// TODO Auto-generated method stub
}
};
assertNull(analyzer.getInputFields(null));
}
Aggregations