Example usage for org.springframework.data.mongodb.core.mapping MongoMappingContext MongoMappingContext

List of usage examples for org.springframework.data.mongodb.core.mapping MongoMappingContext MongoMappingContext

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core.mapping MongoMappingContext MongoMappingContext.

Prototype

public MongoMappingContext() 

Source Link

Document

Creates a new MongoMappingContext .

Usage

From source file:com.avanza.ymer.TestSpaceMongoConverterFactory.java

public MongoConverter createMongoConverter() {
    return new MappingMongoConverter(new DefaultDbRefResolver(mongoDbFactory), new MongoMappingContext());
}

From source file:example.mirror.ExampleMirrorFactory.java

static MongoConverter createMongoConverter(MongoDbFactory mongoDbFactory) {
    DbRefResolver dbRef = new DefaultDbRefResolver(mongoDbFactory);
    MappingMongoConverter converter = new MappingMongoConverter(dbRef, new MongoMappingContext());
    List<Converter<?, ?>> converters = new ArrayList<>();
    converters.add(new FruitToBson());
    converters.add(new BsonToFruit());
    converter.setCustomConversions(new CustomConversions(converters));
    converter.afterPropertiesSet();/*  w  ww .  j  a  va  2s.co m*/
    return converter;
}

From source file:proposal.MongoDbConfiguration.java

@Bean
public MongoMappingContext mongoMappingContext() throws IOException {
    MongoMappingContext mongoContext = new MongoMappingContext();
    mongoContext.setApplicationContext(appContext);
    return mongoContext;
}

From source file:com.trenako.repositories.mongo.AbstractMongoRepositoryTests.java

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);

    this.converter = new MappingMongoConverter(mock(MongoDbFactory.class), new MongoMappingContext());
    initRepository(mongo);//from  ww  w.ja v a  2s .  c o  m
}

From source file:org.springframework.data.rest.webmvc.config.JsonPatchHandlerUnitTests.java

@Before
public void setUp() {

    MongoMappingContext context = new MongoMappingContext();
    context.getPersistentEntity(User.class);

    PersistentEntities entities = new PersistentEntities(Arrays.asList(context));

    Associations associations = new Associations(mappings, mock(RepositoryRestConfiguration.class));

    this.handler = new JsonPatchHandler(new ObjectMapper(), new DomainObjectReader(entities, associations));

    Address address = new Address();
    address.street = "Foo";
    address.zipCode = "Bar";

    this.user = new User();
    this.user.firstname = "Oliver";
    this.user.lastname = "Gierke";
    this.user.address = address;
}

From source file:com.tlantic.integration.authentication.AuthServerMain.java

@Bean
public MappingMongoConverter mongoConverter() throws Exception {
    MongoMappingContext mappingContext = new MongoMappingContext();
    DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoDbFactory);
    MappingMongoConverter mongoConverter = new MappingMongoConverter(dbRefResolver, mappingContext);
    mongoConverter.setCustomConversions(customConversions());
    return mongoConverter;
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.common.config.mongo.MongoConfiguration.java

public @Bean MongoTemplate mongoTemplate() throws Exception {
    MappingMongoConverter converter = new MappingMongoConverter(new DefaultDbRefResolver(mongoDbFactory()),
            new MongoMappingContext());
    // remove _class
    converter.setTypeMapper(new DefaultMongoTypeMapper(null));

    return new MongoTemplate(mongoDbFactory(), converter);
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.common.config.mongo.MongoConfiguration.java

public

@Bean MongoTemplate categoriesMongoTemplate() throws Exception {
    MongoClient client;//from w  ww  .  j ava2 s  . co  m
    client = getMongoClientForCategoriesDatabase();

    MongoDbFactory categoriesMongoDbFactory = new SimpleMongoDbFactory(client, database);
    MappingMongoConverter converter = new MappingMongoConverter(
            new DefaultDbRefResolver(categoriesMongoDbFactory), new MongoMappingContext());
    // remove _class
    converter.setTypeMapper(new DefaultMongoTypeMapper(null));

    return new MongoTemplate(categoriesMongoDbFactory, converter);
}

From source file:com.epam.ta.reportportal.config.MongodbConfiguration.java

@Bean
MongoMappingContext mongoMappingContext() {
    return new MongoMappingContext();
}

From source file:org.springframework.data.mongodb.core.MongoTemplate.java

private static final MongoConverter getDefaultMongoConverter(MongoDbFactory factory) {
    MappingMongoConverter converter = new MappingMongoConverter(factory, new MongoMappingContext());
    converter.afterPropertiesSet();/*from  w ww.j  a  v  a2s .  com*/
    return converter;
}