use of org.springframework.data.mongodb.core.convert.MappingMongoConverter in project oc-explorer by devgateway.
the class MongoTemplateConfig method shadowMongoTemplate.
/**
* Creates a shadow template configuration by adding "-shadow" as postfix of database name.
* This is used to replicate the entire database structure in a shadow/temporary database location
*
* @return
* @throws Exception
*/
@Bean(autowire = Autowire.BY_NAME, name = "shadowMongoTemplate")
public MongoTemplate shadowMongoTemplate() throws Exception {
MongoTemplate template = new MongoTemplate(new SimpleMongoDbFactory(new MongoClientURI(properties.getUri() + SHADOW_POSTFIX)));
((MappingMongoConverter) template.getConverter()).setCustomConversions(customConversions);
return template;
}
use of org.springframework.data.mongodb.core.convert.MappingMongoConverter in project oc-explorer by devgateway.
the class MongoTemplateConfig method mongoTemplate.
@Bean(autowire = Autowire.BY_NAME, name = "mongoTemplate")
public MongoTemplate mongoTemplate() throws Exception {
MongoTemplate template = new MongoTemplate(new SimpleMongoDbFactory(new MongoClientURI(properties.getUri())));
((MappingMongoConverter) template.getConverter()).setCustomConversions(customConversions);
return template;
}
use of org.springframework.data.mongodb.core.convert.MappingMongoConverter in project oc-explorer by devgateway.
the class MongoTemplateTestConfig method shadowMongoTemplate.
/**
* Creates a shadow template configuration by adding "-shadow" as postfix of database name.
* This is used to replicate the entire database structure in a shadow/temporary database location
*
* @return
* @throws Exception
*/
@Bean(name = "shadowMongoTemplate")
public MongoTemplate shadowMongoTemplate(MongodProcess mongodProcess) throws Exception {
Net net = mongodProcess.getConfig().net();
properties.setHost(net.getServerAddress().getHostName());
properties.setPort(net.getPort());
properties.setDatabase(originalUri + MongoTemplateConfig.SHADOW_POSTFIX);
properties.setUri(null);
MongoTemplate template = new MongoTemplate(new SimpleMongoDbFactory(properties.createMongoClient(this.options, environment), properties.getDatabase()));
((MappingMongoConverter) template.getConverter()).setCustomConversions(customConversions);
return template;
}
use of org.springframework.data.mongodb.core.convert.MappingMongoConverter in project oc-explorer by devgateway.
the class MongoTemplateTestConfig method mongoTemplate.
@Bean(name = "mongoTemplate")
public MongoTemplate mongoTemplate(MongodProcess mongodProcess) throws Exception {
Net net = mongodProcess.getConfig().net();
properties.setHost(net.getServerAddress().getHostName());
properties.setPort(net.getPort());
properties.setDatabase(originalUri);
properties.setUri(null);
MongoTemplate template = new MongoTemplate(new SimpleMongoDbFactory(properties.createMongoClient(this.options, environment), properties.getDatabase()));
((MappingMongoConverter) template.getConverter()).setCustomConversions(customConversions);
return template;
}
use of org.springframework.data.mongodb.core.convert.MappingMongoConverter in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method setUp.
@Before
public void setUp() throws SecurityException, NoSuchMethodException {
context = new MongoMappingContext();
DbRefResolver resolver = new DefaultDbRefResolver(mock(MongoDbFactory.class));
converter = new MappingMongoConverter(resolver, context);
}
Aggregations