use of org.pentaho.metaverse.api.IDocument in project pentaho-metaverse by pentaho.
the class LineageClientIT method setUp.
@Before
public void setUp() throws Exception {
transMeta = new TransMeta(MERGE_JOIN_KTR_FILENAME);
IDocument doc = MetaverseUtil.createDocument(new Namespace("SPOON"), transMeta, transMeta.getFilename(), transMeta.getName(), "ktr", URLConnection.getFileNameMap().getContentTypeFor(transMeta.getFilename()));
Graph graph = new TinkerGraph();
MetaverseUtil.addLineageGraph(doc, graph);
}
use of org.pentaho.metaverse.api.IDocument 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.IDocument in project pentaho-metaverse by pentaho.
the class MetaverseUtil method createDocument.
public static IDocument createDocument(INamespace namespace, Object content, String id, String name, String extension, String mimeType) {
IDocument metaverseDocument = getDocumentController().getMetaverseObjectFactory().createDocumentObject();
metaverseDocument.setNamespace(namespace);
metaverseDocument.setContent(content);
metaverseDocument.setStringID(id);
metaverseDocument.setName(name);
metaverseDocument.setExtension(extension);
metaverseDocument.setMimeType(mimeType);
metaverseDocument.setProperty(DictionaryConst.PROPERTY_PATH, id);
metaverseDocument.setProperty(DictionaryConst.PROPERTY_NAMESPACE, namespace.getNamespaceId());
return metaverseDocument;
}
use of org.pentaho.metaverse.api.IDocument in project pentaho-metaverse by pentaho.
the class JobAnalyzerTest method testAnalyzeWithBadXML.
@Test(expected = MetaverseAnalyzerException.class)
public void testAnalyzeWithBadXML() throws MetaverseAnalyzerException {
IDocument newMockJobDoc = mock(IDocument.class);
when(newMockJobDoc.getType()).thenReturn(DictionaryConst.NODE_TYPE_JOB);
when(newMockJobDoc.getContent()).thenReturn("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<job>This is not a valid JobMeta doc!");
analyzer.analyze(descriptor, newMockJobDoc);
}
use of org.pentaho.metaverse.api.IDocument in project pentaho-metaverse by pentaho.
the class TransformationAnalyzerTest method testAnalyzeWithBadXML.
@Test(expected = MetaverseAnalyzerException.class)
public void testAnalyzeWithBadXML() throws MetaverseAnalyzerException {
IDocument newMockTransDoc = mock(IDocument.class);
when(newMockTransDoc.getType()).thenReturn(DictionaryConst.NODE_TYPE_TRANS);
when(newMockTransDoc.getContent()).thenReturn("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<transformation>This is not a valid TransMeta doc!");
analyzer.analyze(descriptor, newMockTransDoc);
}
Aggregations