Search in sources :

Example 1 with Namespace

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());
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) INamespace(org.pentaho.metaverse.api.INamespace) Namespace(org.pentaho.metaverse.api.Namespace)

Example 2 with Namespace

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);
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) INamespace(org.pentaho.metaverse.api.INamespace) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) IMetaverseObjectFactory(org.pentaho.metaverse.api.IMetaverseObjectFactory) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) MetaverseBuilder(org.pentaho.metaverse.impl.MetaverseBuilder) MetaverseException(org.pentaho.metaverse.api.MetaverseException) INamespace(org.pentaho.metaverse.api.INamespace) Namespace(org.pentaho.metaverse.api.Namespace) IDocument(org.pentaho.metaverse.api.IDocument)

Example 3 with Namespace

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);
}
Also used : INamespace(org.pentaho.metaverse.api.INamespace) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) TransMeta(org.pentaho.di.trans.TransMeta) AnalysisContext(org.pentaho.metaverse.api.AnalysisContext) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) ExecutionProfile(org.pentaho.metaverse.impl.model.ExecutionProfile) IExecutionProfile(org.pentaho.metaverse.api.model.IExecutionProfile) INamespace(org.pentaho.metaverse.api.INamespace) Namespace(org.pentaho.metaverse.api.Namespace) IDocument(org.pentaho.metaverse.api.IDocument) MetaverseException(org.pentaho.metaverse.api.MetaverseException) LineageHolder(org.pentaho.metaverse.api.model.LineageHolder)

Example 4 with Namespace

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;
}
Also used : MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) INamespace(org.pentaho.metaverse.api.INamespace) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) INamespace(org.pentaho.metaverse.api.INamespace) Namespace(org.pentaho.metaverse.api.Namespace) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor)

Example 5 with Namespace

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);
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) TransMeta(org.pentaho.di.trans.TransMeta) IDocument(org.pentaho.metaverse.api.IDocument) Namespace(org.pentaho.metaverse.api.Namespace) Before(org.junit.Before)

Aggregations

Namespace (org.pentaho.metaverse.api.Namespace)9 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)8 INamespace (org.pentaho.metaverse.api.INamespace)8 IDocument (org.pentaho.metaverse.api.IDocument)4 MetaverseComponentDescriptor (org.pentaho.metaverse.api.MetaverseComponentDescriptor)4 TransMeta (org.pentaho.di.trans.TransMeta)3 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)3 IMetaverseBuilder (org.pentaho.metaverse.api.IMetaverseBuilder)3 MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)3 MetaverseException (org.pentaho.metaverse.api.MetaverseException)3 Graph (com.tinkerpop.blueprints.Graph)2 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Date (java.util.Date)2 UnknownParamException (org.pentaho.di.core.parameters.UnknownParamException)2 Job (org.pentaho.di.job.Job)2 JobMeta (org.pentaho.di.job.JobMeta)2 AnalysisContext (org.pentaho.metaverse.api.AnalysisContext)2 PropertiesHolder (org.pentaho.metaverse.api.PropertiesHolder)2 IExecutionProfile (org.pentaho.metaverse.api.model.IExecutionProfile)2