Package org.springframework.data.mongodb.core.convert

Examples of org.springframework.data.mongodb.core.convert.CustomConversions


    @Bean
    public CustomConversions customConversions() {
        List<Converter<?, ?>> converterList = new ArrayList<>();
        OAuth2AuthenticationReadConverter converter = new OAuth2AuthenticationReadConverter();
        converterList.add(converter);
        return new CustomConversions(converterList);
    }<% } %>
View Full Code Here


    @Bean
    public CustomConversions customConversions() {
        List<Converter<?, ?>> converterList = new ArrayList<>();
        OAuth2AuthenticationReadConverter converter = new OAuth2AuthenticationReadConverter();
        converterList.add(converter);
        return new CustomConversions(converterList);
    }<% } %>
View Full Code Here

        converters.add(new UserIdReadConverter());
        converters.add(new UserIdWriteConverter());
        converters.add(new EmailAddressReadConverter());
        converters.add(new EmailAddressWriteConverter());

        mappingMongoConverter.setCustomConversions(new CustomConversions(converters));
        return mappingMongoConverter;
    }
View Full Code Here

  public CustomConversions customConversions() {

    List<Converter<?, ?>> converters = new ArrayList<Converter<?, ?>>();
    converters.add(new org.springframework.data.mongodb.core.PersonReadConverter());
    converters.add(new org.springframework.data.mongodb.core.PersonWriteConverter());
    return new CustomConversions(converters);
  }
View Full Code Here

   *
   * @return must not be {@literal null}.
   */
  @Bean
  public CustomConversions customConversions() {
    return new CustomConversions(Collections.emptyList());
  }
View Full Code Here

  @Autowired
  @SuppressWarnings("unchecked")
  public void setMongo(Mongo mongo) throws Exception {

    CustomConversions conversions = new CustomConversions(Arrays.asList(DateToDateTimeConverter.INSTANCE,
        DateTimeToDateConverter.INSTANCE));

    MongoMappingContext mappingContext = new MongoMappingContext();
    mappingContext.setInitialEntitySet(new HashSet<Class<?>>(Arrays.asList(PersonWith_idPropertyOfTypeObjectId.class,
        PersonWith_idPropertyOfTypeString.class, PersonWithIdPropertyOfTypeObjectId.class,
        PersonWithIdPropertyOfTypeString.class, PersonWithIdPropertyOfTypeInteger.class,
        PersonWithIdPropertyOfTypeBigInteger.class, PersonWithIdPropertyOfPrimitiveInt.class,
        PersonWithIdPropertyOfTypeLong.class, PersonWithIdPropertyOfPrimitiveLong.class)));
    mappingContext.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
    mappingContext.initialize();

    DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
    MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver, mappingContext);
    mappingConverter.setCustomConversions(conversions);
View Full Code Here

   */
  @Test
  public void scansForConverterAndSetsUpCustomConversionsAccordingly() {

    loadValidConfiguration();
    CustomConversions conversions = factory.getBean(CustomConversions.class);
    assertThat(conversions.hasCustomWriteTarget(Person.class), is(true));
    assertThat(conversions.hasCustomWriteTarget(Account.class), is(true));
  }
View Full Code Here

   * @see DATAMONGO-912
   */
  @Test
  public void shouldUseCustomConversionIfPresentAndConversionIsRequiredInFirstStage() {

    CustomConversions customConversions = customAgeConversions();
    converter.setCustomConversions(customConversions);
    customConversions.registerConvertersIn((GenericConversionService) converter.getConversionService());

    AggregationOperationContext context = getContext(FooPerson.class);

    MatchOperation matchStage = match(Criteria.where("age").is(new Age(10)));
    ProjectionOperation projectStage = project("age", "name");
View Full Code Here

   * @see DATAMONGO-912
   */
  @Test
  public void shouldUseCustomConversionIfPresentAndConversionIsRequiredInLaterStage() {

    CustomConversions customConversions = customAgeConversions();
    converter.setCustomConversions(customConversions);
    customConversions.registerConvertersIn((GenericConversionService) converter.getConversionService());

    AggregationOperationContext context = getContext(FooPerson.class);

    MatchOperation matchStage = match(Criteria.where("age").is(new Age(10)));
    ProjectionOperation projectStage = project("age", "name");
View Full Code Here

      this.value = value;
    }
  }

  public CustomConversions customAgeConversions() {
    return new CustomConversions(Arrays.<Converter<?, ?>> asList(ageWriteConverter(), ageReadConverter()));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.mongodb.core.convert.CustomConversions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.