Search in sources :

Example 1 with DefaultResourceInformationProviderContext

use of io.crnk.legacy.registry.DefaultResourceInformationProviderContext in project crnk-framework by crnk-project.

the class ModuleRegistry method getResourceInformationBuilder.

/**
 * Returns a {@link ResourceInformationProvider} instance that combines all
 * instances registered by modules.
 *
 * @return resource information builder
 */
public ResourceInformationProvider getResourceInformationBuilder() {
    if (resourceInformationProvider == null) {
        resourceInformationProvider = new CombinedResourceInformationProvider(aggregatedModule.getResourceInformationProviders());
        InformationBuilder informationBuilder = new DefaultInformationBuilder(typeParser);
        DefaultResourceInformationProviderContext context = new DefaultResourceInformationProviderContext(resourceInformationProvider, informationBuilder, typeParser, objectMapper);
        resourceInformationProvider.init(context);
    }
    return resourceInformationProvider;
}
Also used : InformationBuilder(io.crnk.core.engine.information.InformationBuilder) DefaultInformationBuilder(io.crnk.core.engine.internal.information.DefaultInformationBuilder) DefaultInformationBuilder(io.crnk.core.engine.internal.information.DefaultInformationBuilder) DefaultResourceInformationProviderContext(io.crnk.legacy.registry.DefaultResourceInformationProviderContext)

Example 2 with DefaultResourceInformationProviderContext

use of io.crnk.legacy.registry.DefaultResourceInformationProviderContext in project crnk-framework by crnk-project.

the class MetaModule method registerInformationBuilder.

protected DefaultResourceInformationProvider registerInformationBuilder(PropertiesProvider propertiesProvider) {
    InformationBuilder informationBuilder = new DefaultInformationBuilder(context.getTypeParser());
    DefaultResourceInformationProvider informationProvider = new DefaultResourceInformationProvider(propertiesProvider, new OffsetLimitPagingBehavior(), new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider());
    informationProvider.init(new DefaultResourceInformationProviderContext(informationProvider, informationBuilder, context.getTypeParser(), null) {

        @Override
        public ObjectMapper getObjectMapper() {
            return context.getObjectMapper();
        }
    });
    return informationProvider;
}
Also used : InformationBuilder(io.crnk.core.engine.information.InformationBuilder) DefaultInformationBuilder(io.crnk.core.engine.internal.information.DefaultInformationBuilder) OffsetLimitPagingBehavior(io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior) DefaultInformationBuilder(io.crnk.core.engine.internal.information.DefaultInformationBuilder) DefaultResourceInformationProviderContext(io.crnk.legacy.registry.DefaultResourceInformationProviderContext) DefaultResourceInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider) JacksonResourceFieldInformationProvider(io.crnk.core.engine.internal.jackson.JacksonResourceFieldInformationProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultResourceFieldInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider)

Example 3 with DefaultResourceInformationProviderContext

use of io.crnk.legacy.registry.DefaultResourceInformationProviderContext in project crnk-framework by crnk-project.

the class QueryParamsAdapterTest method test.

@Test
public void test() {
    ModuleRegistry moduleRegistry = new ModuleRegistry();
    moduleRegistry.getHttpRequestContextProvider().setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
    ResourceRegistry resourceRegistry = new ResourceRegistryImpl(new DefaultResourceRegistryPart(), moduleRegistry);
    QueryParams params = new QueryParams();
    DefaultResourceInformationProvider builder = new DefaultResourceInformationProvider(new NullPropertiesProvider(), new OffsetLimitPagingBehavior(), new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider());
    builder.init(new DefaultResourceInformationProviderContext(builder, new DefaultInformationBuilder(moduleRegistry.getTypeParser()), moduleRegistry.getTypeParser(), new ObjectMapper()));
    ResourceInformation info = builder.build(Task.class);
    QueryParamsAdapter adapter = new QueryParamsAdapter(info, params, moduleRegistry);
    Assert.assertEquals(Task.class, adapter.getResourceInformation().getResourceClass());
    Assert.assertEquals(resourceRegistry, adapter.getResourceRegistry());
}
Also used : OffsetLimitPagingBehavior(io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior) ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) ModuleRegistry(io.crnk.core.module.ModuleRegistry) ResourceRegistryImpl(io.crnk.core.engine.internal.registry.ResourceRegistryImpl) NullPropertiesProvider(io.crnk.core.engine.properties.NullPropertiesProvider) DefaultResourceInformationProviderContext(io.crnk.legacy.registry.DefaultResourceInformationProviderContext) DefaultResourceInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider) ResourceRegistry(io.crnk.core.engine.registry.ResourceRegistry) JacksonResourceFieldInformationProvider(io.crnk.core.engine.internal.jackson.JacksonResourceFieldInformationProvider) DefaultInformationBuilder(io.crnk.core.engine.internal.information.DefaultInformationBuilder) DefaultResourceRegistryPart(io.crnk.core.engine.registry.DefaultResourceRegistryPart) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) QueryParamsAdapter(io.crnk.legacy.internal.QueryParamsAdapter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultResourceFieldInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider) Test(org.junit.Test)

Example 4 with DefaultResourceInformationProviderContext

use of io.crnk.legacy.registry.DefaultResourceInformationProviderContext in project crnk-framework by crnk-project.

the class JpaResourceInformationProviderTest method setup.

@Before
public void setup() {
    jpaMetaProvider = new JpaMetaProvider(Collections.<Class>emptySet());
    lookup = new MetaLookup();
    lookup.addProvider(jpaMetaProvider);
    builder = new JpaResourceInformationProvider(new NullPropertiesProvider());
    builder.init(new DefaultResourceInformationProviderContext(builder, new DefaultInformationBuilder(new TypeParser()), new TypeParser(), new ObjectMapper()));
}
Also used : JpaResourceInformationProvider(io.crnk.jpa.internal.JpaResourceInformationProvider) MetaLookup(io.crnk.meta.MetaLookup) DefaultInformationBuilder(io.crnk.core.engine.internal.information.DefaultInformationBuilder) TypeParser(io.crnk.core.engine.parser.TypeParser) JpaMetaProvider(io.crnk.jpa.meta.JpaMetaProvider) NullPropertiesProvider(io.crnk.core.engine.properties.NullPropertiesProvider) DefaultResourceInformationProviderContext(io.crnk.legacy.registry.DefaultResourceInformationProviderContext) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 5 with DefaultResourceInformationProviderContext

use of io.crnk.legacy.registry.DefaultResourceInformationProviderContext in project crnk-framework by crnk-project.

the class JaxrsModuleTest method setup.

@Before
public void setup() {
    final ModuleRegistry moduleRegistry = new ModuleRegistry();
    builder = new JaxrsModule.JaxrsResourceRepositoryInformationProvider();
    final ResourceInformationProvider resourceInformationProvider = new DefaultResourceInformationProvider(moduleRegistry.getPropertiesProvider(), ImmutableList.<PagingBehavior>of(new OffsetLimitPagingBehavior()), new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider());
    resourceInformationProvider.init(new DefaultResourceInformationProviderContext(resourceInformationProvider, new DefaultInformationBuilder(moduleRegistry.getTypeParser()), moduleRegistry.getTypeParser(), new ObjectMapper()));
    context = new RepositoryInformationProviderContext() {

        @Override
        public ResourceInformationProvider getResourceInformationBuilder() {
            return resourceInformationProvider;
        }

        @Override
        public TypeParser getTypeParser() {
            return moduleRegistry.getTypeParser();
        }

        @Override
        public InformationBuilder builder() {
            return new DefaultInformationBuilder(moduleRegistry.getTypeParser());
        }
    };
}
Also used : OffsetLimitPagingBehavior(io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior) TypeParser(io.crnk.core.engine.parser.TypeParser) ModuleRegistry(io.crnk.core.module.ModuleRegistry) JaxrsModule(io.crnk.rs.internal.JaxrsModule) DefaultResourceInformationProviderContext(io.crnk.legacy.registry.DefaultResourceInformationProviderContext) RepositoryInformationProviderContext(io.crnk.core.engine.information.repository.RepositoryInformationProviderContext) DefaultResourceInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider) JacksonResourceFieldInformationProvider(io.crnk.core.engine.internal.jackson.JacksonResourceFieldInformationProvider) InformationBuilder(io.crnk.core.engine.information.InformationBuilder) DefaultInformationBuilder(io.crnk.core.engine.internal.information.DefaultInformationBuilder) DefaultInformationBuilder(io.crnk.core.engine.internal.information.DefaultInformationBuilder) ResourceInformationProvider(io.crnk.core.engine.information.resource.ResourceInformationProvider) DefaultResourceInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultResourceFieldInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider) Before(org.junit.Before)

Aggregations

DefaultInformationBuilder (io.crnk.core.engine.internal.information.DefaultInformationBuilder)5 DefaultResourceInformationProviderContext (io.crnk.legacy.registry.DefaultResourceInformationProviderContext)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 InformationBuilder (io.crnk.core.engine.information.InformationBuilder)3 DefaultResourceFieldInformationProvider (io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider)3 DefaultResourceInformationProvider (io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider)3 JacksonResourceFieldInformationProvider (io.crnk.core.engine.internal.jackson.JacksonResourceFieldInformationProvider)3 OffsetLimitPagingBehavior (io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior)3 TypeParser (io.crnk.core.engine.parser.TypeParser)2 NullPropertiesProvider (io.crnk.core.engine.properties.NullPropertiesProvider)2 ModuleRegistry (io.crnk.core.module.ModuleRegistry)2 Before (org.junit.Before)2 RepositoryInformationProviderContext (io.crnk.core.engine.information.repository.RepositoryInformationProviderContext)1 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)1 ResourceInformationProvider (io.crnk.core.engine.information.resource.ResourceInformationProvider)1 ResourceRegistryImpl (io.crnk.core.engine.internal.registry.ResourceRegistryImpl)1 DefaultResourceRegistryPart (io.crnk.core.engine.registry.DefaultResourceRegistryPart)1 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)1 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)1 JpaResourceInformationProvider (io.crnk.jpa.internal.JpaResourceInformationProvider)1