0

I created a project following the steps of the sample project at https://github.com/teiid/teiid-spring-boot/tree/master/samples/mongodb and added org.teiid:spring-odata dependency for OData exposure.

I find out that it exposed all collections in the MongoDB database as OData entities by default. Would it possible to configure it to expose specific collections only?

limcheekin
  • 144
  • 1
  • 12

1 Answers1

0

Updated:

You can add following to application.properties,

spring.teiid.data.mongodb.accounts.remoteServerList=localhost:27017
spring.teiid.data.mongodb.accounts.database=sampledb
spring.teiid.data.mongodb.accounts.user=admin
spring.teiid.data.mongodb.accounts.password=admin
spring.teiid.data.mongodb.accounts.authDatabase=admin

spring.teiid.data.mongodb.accounts.importer.excludeTables=.*

where "accounts" is the bean name. See "importer properties" http://teiid.github.io/teiid-documents/master/content/reference/MongoDB_Translator.html

Then to configure the data source

@Configuration
public class DataSources {
    @Bean
    public MongoDBConnectionFactory accounts(@Qualifier("config") @Autowired MongoDBConfiguration config) {
        return new MongoDBConnectionFactory(new MongoDBTemplate(config));
    }

    @ConfigurationProperties("spring.teiid.data.mongodb.accounts")
    @Bean("config")
    public MongoDBConfiguration mongoConfig() {
        return new MongoDBConfiguration();
    }
}

The above is when strictly talking about exposing MongoDB alone without any other changes.

Ramesh Reddy
  • 554
  • 1
  • 3
  • 8
  • Thanks for quick response. I tried spring.data.mongodb.raasagent.importer.excludeTables=.*, I expect none of the collections of MongoDB is exposed as OData entities, but it seems doesn't work. "raasagent" is the bean I defined in the DataSources class. Any clue? – limcheekin Dec 13 '19 at 08:04
  • Thanks. I adopted the changes to the following repo https://github.com/limcheekin/teiid-spring-boot-mongodb-odata. It seems doesn't works, I still see the `matrix_variable` collection and `headerRow` exposed as OData entities. – limcheekin Jan 03 '20 at 03:38
  • You could see why a check here https://github.com/teiid/teiid/blob/master/connectors/mongodb/translator-mongodb/src/main/java/org/teiid/translator/mongodb/MongoDBMetadataProcessor.java#L81 is failing in a debug – Ramesh Reddy Jan 03 '20 at 14:34
  • Thanks for sharing the line of code on debugging. I will look into it after finished the higher priority tasks. – limcheekin Jan 06 '20 at 06:27