use of org.pentaho.metaverse.api.IMetaverseBuilder in project pentaho-metaverse by pentaho.
the class BaseRuntimeExtensionPoint method addRuntimeLineageInfo.
public void addRuntimeLineageInfo(LineageHolder holder) {
// TODO
IMetaverseBuilder builder = holder.getMetaverseBuilder();
IExecutionProfile profile = holder.getExecutionProfile();
}
use of org.pentaho.metaverse.api.IMetaverseBuilder in project pentaho-metaverse by pentaho.
the class JobRuntimeExtensionPoint method callExtensionPoint.
/**
* Callback when a job is about to be started
*
* @param logChannelInterface A reference to the log in this context (the Job object's log)
* @param o The object being operated on (Job in this case)
* @throws org.pentaho.di.core.exception.KettleException
*/
@Override
public void callExtensionPoint(LogChannelInterface logChannelInterface, Object o) throws KettleException {
// Job Started listeners get called after the extension point is invoked, so just add a job listener
if (o instanceof Job) {
Job job = ((Job) o);
// If runtime lineage collection is disabled, don't run any lineage processes/methods
if (!isRuntimeEnabled()) {
return;
}
// Create and populate an execution profile with what we know so far
ExecutionProfile executionProfile = new ExecutionProfile();
populateExecutionProfile(executionProfile, job);
IMetaverseBuilder builder = JobLineageHolderMap.getInstance().getMetaverseBuilder(job);
// Add the job finished listener
job.addJobListener(this);
// Analyze the current transformation
if (documentAnalyzer != null) {
documentAnalyzer.setMetaverseBuilder(builder);
// Create a document for the Trans
final String clientName = executionProfile.getExecutionEngine().getName();
final INamespace namespace = new Namespace(clientName);
final IMetaverseNode designNode = builder.getMetaverseObjectFactory().createNodeObject(clientName, clientName, DictionaryConst.NODE_TYPE_LOCATOR);
builder.addNode(designNode);
final JobMeta jobMeta = job.getJobMeta();
// The variables and parameters in the Job may not have been set on the meta, so we do it here
// to ensure the job analyzer will have access to the parameter values.
jobMeta.copyParametersFrom(job);
jobMeta.activateParameters();
job.copyVariablesFrom(jobMeta);
if (job.getRep() != null) {
jobMeta.setRepository(job.getRep());
}
String id = getFilename(jobMeta);
if (!id.endsWith(jobMeta.getDefaultExtension())) {
id += "." + jobMeta.getDefaultExtension();
}
IDocument metaverseDocument = builder.getMetaverseObjectFactory().createDocumentObject();
metaverseDocument.setNamespace(namespace);
metaverseDocument.setContent(jobMeta);
metaverseDocument.setStringID(id);
metaverseDocument.setName(jobMeta.getName());
metaverseDocument.setExtension("kjb");
metaverseDocument.setMimeType(URLConnection.getFileNameMap().getContentTypeFor("job.kjb"));
metaverseDocument.setContext(new AnalysisContext(DictionaryConst.CONTEXT_RUNTIME));
String normalizedPath;
try {
normalizedPath = KettleAnalyzerUtil.normalizeFilePath(id);
} catch (MetaverseException e) {
normalizedPath = id;
}
metaverseDocument.setProperty(DictionaryConst.PROPERTY_NAME, job.getName());
metaverseDocument.setProperty(DictionaryConst.PROPERTY_PATH, normalizedPath);
metaverseDocument.setProperty(DictionaryConst.PROPERTY_NAMESPACE, namespace.getNamespaceId());
Runnable analyzerRunner = MetaverseUtil.getAnalyzerRunner(documentAnalyzer, metaverseDocument);
MetaverseCompletionService.getInstance().submit(analyzerRunner, id);
}
// Save the lineage objects for later
LineageHolder holder = JobLineageHolderMap.getInstance().getLineageHolder(job);
holder.setExecutionProfile(executionProfile);
holder.setMetaverseBuilder(builder);
}
}
use of org.pentaho.metaverse.api.IMetaverseBuilder in project pentaho-metaverse by pentaho.
the class TransLineageHolderMapTest method testGetMetaverseBuilder.
@Test
public void testGetMetaverseBuilder() throws Exception {
assertNull(jobLineageHolderMap.getMetaverseBuilder(null));
Trans trans = mock(Trans.class);
when(trans.getParentJob()).thenReturn(null);
when(trans.getParentTrans()).thenReturn(null);
mockHolder.setMetaverseBuilder(mockBuilder);
jobLineageHolderMap.putLineageHolder(trans, mockHolder);
IMetaverseBuilder builder = jobLineageHolderMap.getMetaverseBuilder(trans);
assertNotNull(builder);
Trans parentTrans = mock(Trans.class);
when(parentTrans.getParentJob()).thenReturn(null);
when(parentTrans.getParentTrans()).thenReturn(null);
when(trans.getParentTrans()).thenReturn(parentTrans);
LineageHolder mockParentHolder = spy(new LineageHolder());
IMetaverseBuilder mockParentBuilder = mock(IMetaverseBuilder.class);
jobLineageHolderMap.putLineageHolder(parentTrans, mockParentHolder);
mockParentHolder.setMetaverseBuilder(null);
assertEquals(defaultBuilder, jobLineageHolderMap.getMetaverseBuilder(trans));
mockParentHolder.setMetaverseBuilder(mockParentBuilder);
builder = jobLineageHolderMap.getMetaverseBuilder(trans);
assertNotNull(builder);
}
use of org.pentaho.metaverse.api.IMetaverseBuilder in project pentaho-metaverse by pentaho.
the class FileSystemLineageWriterTest method testOutputLineageGraph.
@Test
public void testOutputLineageGraph() throws Exception {
Graph g = new TinkerGraph();
IMetaverseBuilder builder = new MetaverseBuilder(g);
holder.setMetaverseBuilder(builder);
writer.outputLineageGraph(holder);
}
use of org.pentaho.metaverse.api.IMetaverseBuilder in project pentaho-metaverse by pentaho.
the class LineageWriterTest method testOutputLineageGraphNoOutputStream.
@Test(expected = IOException.class)
public void testOutputLineageGraphNoOutputStream() throws Exception {
Graph g = new TinkerGraph();
IMetaverseBuilder builder = new MetaverseBuilder(g);
holder.setMetaverseBuilder(builder);
writer.outputLineageGraph(holder);
}
Aggregations