Search in sources :

Example 1 with IMetaverseObjectFactory

use of org.pentaho.metaverse.api.IMetaverseObjectFactory 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 2 with IMetaverseObjectFactory

use of org.pentaho.metaverse.api.IMetaverseObjectFactory in project pentaho-metaverse by pentaho.

the class MetaverseDocumentAnalyzerTest method setUp.

/**
 * @throws Exception
 */
@Before
public void setUp() throws Exception {
    builder = mock(IMetaverseBuilder.class);
    transDoc = mock(IDocument.class);
    namespace = mock(INamespace.class);
    descriptor = new MetaverseComponentDescriptor("name", DictionaryConst.NODE_TYPE_TRANS, namespace);
    IMetaverseObjectFactory factory = MetaverseTestUtils.getMetaverseObjectFactory();
    when(builder.getMetaverseObjectFactory()).thenReturn(factory);
    analyzer.setMetaverseBuilder(builder);
    when(namespace.getParentNamespace()).thenReturn(namespace);
    when(transDoc.getType()).thenReturn(type);
    when(transDoc.getContent()).thenReturn(content);
    when(transDoc.getNamespace()).thenReturn(namespace);
}
Also used : INamespace(org.pentaho.metaverse.api.INamespace) IMetaverseObjectFactory(org.pentaho.metaverse.api.IMetaverseObjectFactory) IMetaverseBuilder(org.pentaho.metaverse.api.IMetaverseBuilder) IDocument(org.pentaho.metaverse.api.IDocument) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor) Before(org.junit.Before)

Example 3 with IMetaverseObjectFactory

use of org.pentaho.metaverse.api.IMetaverseObjectFactory in project pentaho-metaverse by pentaho.

the class TransExtensionPointUtilTest method testAddLineageGraphNullFilename.

@Test
public void testAddLineageGraphNullFilename() throws Exception {
    IDocumentController mockDoc = mock(IDocumentController.class);
    IMetaverseObjectFactory factory = MetaverseTestUtils.getMetaverseObjectFactory();
    when(mockDoc.getMetaverseObjectFactory()).thenReturn(factory);
    MetaverseUtil.setDocumentController(mockDoc);
    when(transMeta.getFilename()).thenReturn(null);
    when(transMeta.getPathAndName()).thenReturn("/Transformation 1");
    TransExtensionPointUtil.addLineageGraph(transMeta);
}
Also used : IDocumentController(org.pentaho.metaverse.api.IDocumentController) IMetaverseObjectFactory(org.pentaho.metaverse.api.IMetaverseObjectFactory) Test(org.junit.Test)

Example 4 with IMetaverseObjectFactory

use of org.pentaho.metaverse.api.IMetaverseObjectFactory in project pentaho-metaverse by pentaho.

the class TableInputStepAnalyzerTest method setUp.

@Before
public void setUp() throws Exception {
    analyzer = spy(new TableInputStepAnalyzer());
    when(mockNamespace.getParentNamespace()).thenReturn(mockNamespace);
    descriptor = new MetaverseComponentDescriptor("test", DictionaryConst.NODE_TYPE_TRANS_STEP, mockNamespace);
    analyzer.setDescriptor(descriptor);
    analyzer.setBaseStepMeta(meta);
    IMetaverseObjectFactory factory = MetaverseTestUtils.getMetaverseObjectFactory();
    when(builder.getMetaverseObjectFactory()).thenReturn(factory);
    analyzer.setMetaverseBuilder(builder);
}
Also used : IMetaverseObjectFactory(org.pentaho.metaverse.api.IMetaverseObjectFactory) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor) Before(org.junit.Before)

Example 5 with IMetaverseObjectFactory

use of org.pentaho.metaverse.api.IMetaverseObjectFactory in project pentaho-metaverse by pentaho.

the class TableOutputStepAnalyzerTest method setUp.

@Before
public void setUp() throws Exception {
    IMetaverseObjectFactory factory = MetaverseTestUtils.getMetaverseObjectFactory();
    when(mockBuilder.getMetaverseObjectFactory()).thenReturn(factory);
    analyzer = spy(new TableOutputStepAnalyzer());
    analyzer.setConnectionAnalyzer(mock(IConnectionAnalyzer.class));
    analyzer.setMetaverseBuilder(mockBuilder);
    analyzer.setBaseStepMeta(meta);
    analyzer.setRootNode(node);
    analyzer.setParentTransMeta(parentTransMeta);
    analyzer.setParentStepMeta(parentStepMeta);
    when(mockNamespace.getParentNamespace()).thenReturn(mockNamespace);
    descriptor = new MetaverseComponentDescriptor("test", DictionaryConst.NODE_TYPE_TRANS_STEP, mockNamespace);
    analyzer.setDescriptor(descriptor);
    when(meta.getParentStepMeta()).thenReturn(parentStepMeta);
    when(parentStepMeta.getParentTransMeta()).thenReturn(parentTransMeta);
    when(parentStepMeta.getName()).thenReturn("test");
    when(parentStepMeta.getStepID()).thenReturn("TableOutputStep");
}
Also used : IMetaverseObjectFactory(org.pentaho.metaverse.api.IMetaverseObjectFactory) IConnectionAnalyzer(org.pentaho.metaverse.api.IConnectionAnalyzer) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor) Before(org.junit.Before)

Aggregations

IMetaverseObjectFactory (org.pentaho.metaverse.api.IMetaverseObjectFactory)18 Before (org.junit.Before)10 Test (org.junit.Test)7 MetaverseComponentDescriptor (org.pentaho.metaverse.api.MetaverseComponentDescriptor)6 IDocument (org.pentaho.metaverse.api.IDocument)3 IMetaverseBuilder (org.pentaho.metaverse.api.IMetaverseBuilder)3 INamespace (org.pentaho.metaverse.api.INamespace)3 Matchers.anyString (org.mockito.Matchers.anyString)2 IConnectionAnalyzer (org.pentaho.metaverse.api.IConnectionAnalyzer)2 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)2 Graph (com.tinkerpop.blueprints.Graph)1 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)1 AfterClass (org.junit.AfterClass)1 BeforeClass (org.junit.BeforeClass)1 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)1 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)1 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)1 IDocumentAnalyzer (org.pentaho.metaverse.api.IDocumentAnalyzer)1 IDocumentController (org.pentaho.metaverse.api.IDocumentController)1 MetaverseException (org.pentaho.metaverse.api.MetaverseException)1