Search in sources :

Example 1 with IMetaverseReader

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

the class IntegrationTestUtil method buildMetaverseGraph.

public static synchronized Graph buildMetaverseGraph(IDocumentLocatorProvider provider) throws Exception {
    IDocumentLocatorProvider documentLocatorProvider = provider;
    IMetaverseReader reader = PentahoSystem.get(IMetaverseReader.class);
    Set<IDocumentLocator> locators = documentLocatorProvider.getDocumentLocators();
    MetaverseCompletionService mcs = MetaverseCompletionService.getInstance();
    // Run a scan for each locator
    for (IDocumentLocator locator : locators) {
        locator.startScan();
    }
    mcs.waitTillEmpty();
    return reader.getMetaverse();
}
Also used : IMetaverseReader(org.pentaho.metaverse.api.IMetaverseReader) IDocumentLocatorProvider(org.pentaho.metaverse.api.IDocumentLocatorProvider) IDocumentLocator(org.pentaho.metaverse.api.IDocumentLocator) MetaverseCompletionService(org.pentaho.metaverse.impl.MetaverseCompletionService)

Example 2 with IMetaverseReader

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

the class BlueprintsGraphMetaverseReaderTest method testFindNodes.

@Test
public void testFindNodes() throws Exception {
    IMetaverseReader metaverseReader = new BlueprintsGraphMetaverseReader(graph);
    List<IMetaverseNode> nodes = metaverseReader.findNodes(DictionaryConst.PROPERTY_TYPE, DictionaryConst.NODE_TYPE_DATA_COLUMN);
    assertNotNull("Node is null", nodes);
    assertEquals("Node count is wrong", 7, nodes.size());
    Set<String> ids = new HashSet<String>();
    for (IMetaverseNode node : nodes) {
        ids.add(node.getStringID());
    }
    assertTrue("Id is missing", ids.contains("datasource1.table1.field1"));
    assertTrue("Id is missing", ids.contains("datasource1.table1.field2"));
    assertTrue("Id is missing", ids.contains("datasource1.table1.field3"));
    assertTrue("Id is missing", ids.contains("datasource1.table2.field1"));
    assertTrue("Id is missing", ids.contains("datasource1.table2.field2"));
    assertTrue("Id is missing", ids.contains("datasource1.table2.field3"));
    assertTrue("Id is missing", ids.contains("datasource1.table2.field4"));
    nodes = metaverseReader.findNodes(DictionaryConst.PROPERTY_NAME, "Transformation: trans1.ktr");
    assertNotNull("Node is null", nodes);
    assertEquals("Node count is wrong", 1, nodes.size());
    assertEquals("Id is missing", "Transformation: trans1.ktr", nodes.get(0).getProperty(DictionaryConst.PROPERTY_NAME));
}
Also used : IMetaverseReader(org.pentaho.metaverse.api.IMetaverseReader) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with IMetaverseReader

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

the class BlueprintsGraphMetaverseReaderTest method testFindNode.

@Test
public void testFindNode() throws Exception {
    IMetaverseReader metaverseReader = new BlueprintsGraphMetaverseReader(graph);
    IMetaverseNode node = metaverseReader.findNode("data.txt");
    assertNotNull("Node is null", node);
    assertEquals("Id is wrong", "data.txt", node.getStringID());
    assertEquals("Type is wrong", DictionaryConst.NODE_TYPE_FILE, node.getType());
    assertEquals("Name is wrong", "Text file: data.txt", node.getName());
    assertNull(node.getProperty(DictionaryConst.PROPERTY_TYPE_LOCALIZED));
    node = metaverseReader.findNode("bogus");
    assertNull("Node is not null", node);
    node = metaverseReader.findNode("trans1.ktr");
    assertNotNull("Node is null", node);
    assertEquals("Id is wrong", "trans1.ktr", node.getStringID());
    assertEquals("Type is wrong", DictionaryConst.NODE_TYPE_TRANS, node.getType());
    assertEquals("Localized type is wrong", "Transformation", node.getProperty(DictionaryConst.PROPERTY_TYPE_LOCALIZED));
    assertEquals("Localized type is wrong", "Document", node.getProperty(DictionaryConst.PROPERTY_CATEGORY_LOCALIZED));
}
Also used : IMetaverseReader(org.pentaho.metaverse.api.IMetaverseReader) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) Test(org.junit.Test)

Aggregations

IMetaverseReader (org.pentaho.metaverse.api.IMetaverseReader)3 Test (org.junit.Test)2 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)2 HashSet (java.util.HashSet)1 IDocumentLocator (org.pentaho.metaverse.api.IDocumentLocator)1 IDocumentLocatorProvider (org.pentaho.metaverse.api.IDocumentLocatorProvider)1 MetaverseCompletionService (org.pentaho.metaverse.impl.MetaverseCompletionService)1