Search in sources :

Example 1 with MongoDbResourceInfo

use of org.pentaho.metaverse.impl.model.MongoDbResourceInfo in project pentaho-metaverse by pentaho.

the class MongoDbInputExternalResourceConsumer method getResourcesFromMeta.

@Override
public Collection<IExternalResourceInfo> getResourcesFromMeta(MongoDbInputMeta meta, IAnalysisContext context) {
    Set<IExternalResourceInfo> resources = new HashSet<IExternalResourceInfo>();
    MongoDbResourceInfo mongoDbResourceInfo = new MongoDbResourceInfo(meta);
    mongoDbResourceInfo.setInput(true);
    resources.add(mongoDbResourceInfo);
    return resources;
}
Also used : IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) MongoDbResourceInfo(org.pentaho.metaverse.impl.model.MongoDbResourceInfo) HashSet(java.util.HashSet)

Example 2 with MongoDbResourceInfo

use of org.pentaho.metaverse.impl.model.MongoDbResourceInfo in project pentaho-metaverse by pentaho.

the class MongoDbInputStepAnalyzer method createTableNode.

@Override
protected IMetaverseNode createTableNode(IExternalResourceInfo resource) throws MetaverseAnalyzerException {
    MongoDbResourceInfo resourceInfo = (MongoDbResourceInfo) resource;
    // create a node for the collection
    MetaverseComponentDescriptor componentDescriptor = new MetaverseComponentDescriptor(resourceInfo.getCollection(), DictionaryConst.NODE_TYPE_MONGODB_COLLECTION, getConnectionNode(), getDescriptor().getContext());
    // set the namespace to be the id of the connection node.
    IMetaverseNode node = createNodeFromDescriptor(componentDescriptor);
    node.setProperty(DictionaryConst.PROPERTY_NAMESPACE, componentDescriptor.getNamespace().getNamespaceId());
    node.setProperty(COLLECTION, resourceInfo.getCollection());
    node.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DEFAULT);
    return node;
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MongoDbResourceInfo(org.pentaho.metaverse.impl.model.MongoDbResourceInfo) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor)

Example 3 with MongoDbResourceInfo

use of org.pentaho.metaverse.impl.model.MongoDbResourceInfo in project pentaho-metaverse by pentaho.

the class MongoDbInputStepAnalyzerTest method testCreateTableNode.

@Test
public void testCreateTableNode() throws Exception {
    IConnectionAnalyzer connectionAnalyzer = mock(IConnectionAnalyzer.class);
    doReturn(connectionAnalyzer).when(analyzer).getConnectionAnalyzer();
    IMetaverseNode connNode = mock(IMetaverseNode.class);
    when(connectionAnalyzer.analyze(any(IComponentDescriptor.class), anyObject())).thenReturn(connNode);
    MongoDbResourceInfo resourceInfo = mock(MongoDbResourceInfo.class);
    when(resourceInfo.getCollection()).thenReturn("myCollection");
    IMetaverseNode connectionNode = mock(IMetaverseNode.class);
    doReturn(connectionNode).when(analyzer).getConnectionNode();
    when(connectionNode.getLogicalId()).thenReturn("CONNECTION_ID");
    IMetaverseNode resourceNode = analyzer.createTableNode(resourceInfo);
    assertEquals("myCollection", resourceNode.getProperty(MongoDbInputStepAnalyzer.COLLECTION));
    assertEquals("myCollection", resourceNode.getName());
    assertEquals("CONNECTION_ID", resourceNode.getProperty(DictionaryConst.PROPERTY_NAMESPACE));
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) IConnectionAnalyzer(org.pentaho.metaverse.api.IConnectionAnalyzer) MongoDbResourceInfo(org.pentaho.metaverse.impl.model.MongoDbResourceInfo) Test(org.junit.Test)

Aggregations

MongoDbResourceInfo (org.pentaho.metaverse.impl.model.MongoDbResourceInfo)3 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)2 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)1 IConnectionAnalyzer (org.pentaho.metaverse.api.IConnectionAnalyzer)1 MetaverseComponentDescriptor (org.pentaho.metaverse.api.MetaverseComponentDescriptor)1 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)1