Example usage for org.springframework.data.mapping.context PersistentEntities PersistentEntities

List of usage examples for org.springframework.data.mapping.context PersistentEntities PersistentEntities

Introduction

In this page you can find the example usage for org.springframework.data.mapping.context PersistentEntities PersistentEntities.

Prototype

public PersistentEntities(Iterable<? extends MappingContext<?, ?>> contexts) 

Source Link

Document

Creates a new PersistentEntities for the given MappingContext s.

Usage

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:org.springframework.data.rest.webmvc.json.DomainObjectReaderUnitTests.java

@Before
public void setUp() {

    KeyValueMappingContext mappingContext = new KeyValueMappingContext();
    mappingContext.getPersistentEntity(SampleUser.class);
    mappingContext.getPersistentEntity(Person.class);
    mappingContext.getPersistentEntity(TypeWithGenericMap.class);
    mappingContext.getPersistentEntity(VersionedType.class);
    mappingContext.afterPropertiesSet();

    PersistentEntities entities = new PersistentEntities(Collections.singleton(mappingContext));

    this.reader = new DomainObjectReader(entities,
            new Associations(mappings, mock(RepositoryRestConfiguration.class)));
}

From source file:org.springframework.data.rest.webmvc.json.PersistentEntityJackson2ModuleUnitTests.java

@Before
public void setUp() {

    KeyValueMappingContext mappingContext = new KeyValueMappingContext();
    mappingContext.getPersistentEntity(Sample.class);
    mappingContext.getPersistentEntity(SampleWithAdditionalGetters.class);
    mappingContext.getPersistentEntity(PersistentEntityJackson2ModuleUnitTests.PetOwner.class);

    this.persistentEntities = new PersistentEntities(Arrays.asList(mappingContext));

    ResourceProcessorInvoker invoker = new ResourceProcessorInvoker(
            Collections.<ResourceProcessor<?>>emptyList());

    NestedEntitySerializer nestedEntitySerializer = new NestedEntitySerializer(persistentEntities,
            new EmbeddedResourcesAssembler(persistentEntities, associations, mock(ExcerptProjector.class)),
            invoker);/* www  . j ava  2s . c o  m*/
    OrderAwarePluginRegistry<EntityLookup<?>, Class<?>> lookups = OrderAwarePluginRegistry.create();

    SimpleModule module = new SimpleModule();

    module.setSerializerModifier(new AssociationOmittingSerializerModifier(persistentEntities, associations,
            nestedEntitySerializer, new LookupObjectSerializer(lookups)));
    module.setDeserializerModifier(new AssociationUriResolvingDeserializerModifier(persistentEntities,
            associations, converter, mock(RepositoryInvokerFactory.class)));

    this.mapper = new ObjectMapper();
    this.mapper.registerModule(module);
}

From source file:org.springframework.data.rest.tests.RepositoryTestsConfig.java

@Bean
public PersistentEntities persistentEntities() {
    return new PersistentEntities(mappingContexts);
}

From source file:com._4dconcept.springframework.data.marklogic.config.AbstractMarklogicConfiguration.java

/**
 * @return a {@link MappingContextIsNewStrategyFactory} wrapped into a {@link CachingIsNewStrategyFactory}.
 *//* w w w .j  a v  a 2  s .  com*/
@Bean
public IsNewStrategyFactory isNewStrategyFactory() throws ClassNotFoundException {
    PersistentEntities persistentEntities = new PersistentEntities(
            Collections.singletonList(marklogicMappingContext()));
    return new CachingIsNewStrategyFactory(new MappingContextIsNewStrategyFactory(persistentEntities));
}

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

@Bean
public PersistentEntities persistentEntities() {

    List<MappingContext<?, ?>> arrayList = new ArrayList<MappingContext<?, ?>>();

    for (MappingContext<?, ?> context : BeanFactoryUtils
            .beansOfTypeIncludingAncestors(applicationContext, MappingContext.class).values()) {
        arrayList.add(context);//from   w w w .j  av a 2 s .c o  m
    }

    return new PersistentEntities(arrayList);
}