use of org.pentaho.metaverse.api.Namespace in project pentaho-metaverse by pentaho.
the class BaseLocator method getNamespace.
protected INamespace getNamespace() {
IMetaverseNode locatorNode = metaverseBuilder.getMetaverseObjectFactory().createNodeObject(UUID.randomUUID().toString(), getRepositoryId(), DictionaryConst.NODE_TYPE_LOCATOR);
locatorNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_LOCATOR);
return new Namespace(locatorNode.getLogicalId());
}
use of org.pentaho.metaverse.api.Namespace in project pentaho-metaverse by pentaho.
the class TransExtensionPointUtil method addLineageGraph.
public static void addLineageGraph(final TransMeta transMeta) throws MetaverseException {
if (transMeta == null) {
throw new MetaverseException(Messages.getString("ERROR.Document.IsNull"));
}
// Get the "natural" filename (repo-based if in repository, filesystem-based otherwise)
String filename = getFilename(transMeta);
final Graph graph = new TinkerGraph();
final IMetaverseBuilder metaverseBuilder = new MetaverseBuilder(graph);
final IMetaverseObjectFactory objFactory = MetaverseUtil.getDocumentController().getMetaverseObjectFactory();
// Add the client design node
final String clientName = KettleClientEnvironment.getInstance().getClient().toString();
final INamespace namespace = new Namespace(clientName);
final IMetaverseNode designNode = objFactory.createNodeObject(clientName, clientName, DictionaryConst.NODE_TYPE_LOCATOR);
metaverseBuilder.addNode(designNode);
// Create a document object containing the transMeta
final IDocument document = MetaverseUtil.createDocument(namespace, transMeta, filename, transMeta.getName(), "ktr", URLConnection.getFileNameMap().getContentTypeFor("trans.ktr"));
MetaverseUtil.addLineageGraph(document, graph);
}
use of org.pentaho.metaverse.api.Namespace in project pentaho-metaverse by pentaho.
the class TransformationRuntimeExtensionPoint method startAnalyzer.
protected void startAnalyzer(Trans trans) throws KettleException {
if (trans == null) {
return;
}
// Create and populate an execution profile with what we know so far
ExecutionProfile executionProfile = new ExecutionProfile();
populateExecutionProfile(executionProfile, trans);
IMetaverseBuilder builder = TransLineageHolderMap.getInstance().getMetaverseBuilder(trans);
// 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 TransMeta transMeta = trans.getTransMeta();
String id = TransExtensionPointUtil.getFilename(transMeta);
IDocument metaverseDocument = builder.getMetaverseObjectFactory().createDocumentObject();
metaverseDocument.setNamespace(namespace);
metaverseDocument.setContent(transMeta);
metaverseDocument.setStringID(id);
metaverseDocument.setName(transMeta.getName());
metaverseDocument.setExtension("ktr");
metaverseDocument.setMimeType(URLConnection.getFileNameMap().getContentTypeFor("trans.ktr"));
metaverseDocument.setContext(new AnalysisContext(DictionaryConst.CONTEXT_RUNTIME));
String normalizedPath;
try {
normalizedPath = KettleAnalyzerUtil.normalizeFilePath(id);
} catch (MetaverseException e) {
normalizedPath = id;
}
metaverseDocument.setProperty(DictionaryConst.PROPERTY_NAME, trans.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 = TransLineageHolderMap.getInstance().getLineageHolder(trans);
holder.setExecutionProfile(executionProfile);
holder.setMetaverseBuilder(builder);
}
use of org.pentaho.metaverse.api.Namespace in project pentaho-metaverse by pentaho.
the class StepAnalyzer method getStepFieldOriginDescriptor.
protected IComponentDescriptor getStepFieldOriginDescriptor(IComponentDescriptor descriptor, String fieldName) throws MetaverseAnalyzerException {
if (descriptor == null || stepFields == null) {
return null;
}
ValueMetaInterface vmi = stepFields.searchValueMeta(fieldName);
String origin = (vmi == null) ? fieldName : vmi.getOrigin();
// if we can't determine the origin, throw an exception
if (origin == null && !ArrayUtils.isEmpty(prevStepNames)) {
throw new MetaverseAnalyzerException(Messages.getString("ERROR.NoOriginForField", fieldName));
}
IMetaverseNode tmpOriginNode = metaverseObjectFactory.createNodeObject(UUID.randomUUID().toString(), origin, DictionaryConst.NODE_TYPE_TRANS_STEP);
tmpOriginNode.setProperty(DictionaryConst.PROPERTY_NAMESPACE, rootNode.getProperty(DictionaryConst.PROPERTY_NAMESPACE));
INamespace stepFieldNamespace = new Namespace(tmpOriginNode.getLogicalId());
MetaverseComponentDescriptor d = new MetaverseComponentDescriptor(fieldName, DictionaryConst.NODE_TYPE_TRANS_FIELD, tmpOriginNode, descriptor.getContext());
return d;
}
use of org.pentaho.metaverse.api.Namespace 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);
}
Aggregations