Search in sources :

Example 1 with DefaultResourceInformationProvider

use of io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider 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 2 with DefaultResourceInformationProvider

use of io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider in project crnk-framework by crnk-project.

the class JacksonModule method setupModule.

@Override
public void setupModule(ModuleContext context) {
    objectMapper.registerModule(createJacksonModule(serializeLinksAsObjects));
    DefaultResourceFieldInformationProvider defaultFieldProvider = new DefaultResourceFieldInformationProvider();
    ResourceFieldInformationProvider jacksonFieldProvider = new JacksonResourceFieldInformationProvider();
    // TODO move somewhere else and make use of a SerializerExtension
    context.addResourceInformationBuilder(new DefaultResourceInformationProvider(context.getPropertiesProvider(), pagingBehaviors, defaultFieldProvider, jacksonFieldProvider));
}
Also used : DefaultResourceFieldInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider) ResourceFieldInformationProvider(io.crnk.core.engine.information.resource.ResourceFieldInformationProvider) DefaultResourceInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider) DefaultResourceFieldInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider)

Example 3 with DefaultResourceInformationProvider

use of io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider in project crnk-framework by crnk-project.

the class DefaultResourceInformationProviderTest method getResourceInformationProviderWithProperty.

private ResourceInformationProvider getResourceInformationProviderWithProperty(String key, String value) {
    PropertiesProvider propertiesProvider = Mockito.mock(PropertiesProvider.class);
    Mockito.when(propertiesProvider.getProperty(Mockito.eq(key))).thenReturn(value);
    ResourceInformationProvider resourceInformationProvider = new DefaultResourceInformationProvider(propertiesProvider, new OffsetLimitPagingBehavior(), new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider());
    resourceInformationProvider.init(context);
    return resourceInformationProvider;
}
Also used : PropertiesProvider(io.crnk.core.engine.properties.PropertiesProvider) NullPropertiesProvider(io.crnk.core.engine.properties.NullPropertiesProvider) OffsetLimitPagingBehavior(io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior) DefaultResourceInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider) ResourceInformationProvider(io.crnk.core.engine.information.resource.ResourceInformationProvider) DefaultResourceInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider) JacksonResourceFieldInformationProvider(io.crnk.core.engine.internal.jackson.JacksonResourceFieldInformationProvider) DefaultResourceFieldInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider)

Example 4 with DefaultResourceInformationProvider

use of io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider in project crnk-framework by crnk-project.

the class AbstractQueryParamsTest method setup.

@Before
public void setup() {
    JsonServiceLocator jsonServiceLocator = new SampleJsonServiceLocator();
    ResourceInformationProvider resourceInformationProvider = new DefaultResourceInformationProvider(new NullPropertiesProvider(), (PagingBehavior) null, new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider());
    SimpleModule testModule = new SimpleModule("test");
    CrnkBoot boot = new CrnkBoot();
    boot.addModule(testModule);
    boot.boot();
    moduleRegistry = boot.getModuleRegistry();
    resourceRegistry = boot.getResourceRegistry();
    converter = new DefaultQueryParamsConverter(resourceRegistry);
    paramsToSpecConverter = new DefaultQuerySpecConverter(moduleRegistry);
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) NullPropertiesProvider(io.crnk.core.engine.properties.NullPropertiesProvider) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) DefaultResourceInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider) JsonServiceLocator(io.crnk.legacy.locator.JsonServiceLocator) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) ResourceInformationProvider(io.crnk.core.engine.information.resource.ResourceInformationProvider) DefaultResourceInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider) JacksonResourceFieldInformationProvider(io.crnk.core.engine.internal.jackson.JacksonResourceFieldInformationProvider) DefaultQuerySpecConverter(io.crnk.legacy.internal.DefaultQuerySpecConverter) SimpleModule(io.crnk.core.module.SimpleModule) DefaultResourceFieldInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider) Before(org.junit.Before)

Example 5 with DefaultResourceInformationProvider

use of io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider 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)

Aggregations

DefaultResourceFieldInformationProvider (io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider)7 DefaultResourceInformationProvider (io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider)7 JacksonResourceFieldInformationProvider (io.crnk.core.engine.internal.jackson.JacksonResourceFieldInformationProvider)6 OffsetLimitPagingBehavior (io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior)5 ResourceInformationProvider (io.crnk.core.engine.information.resource.ResourceInformationProvider)4 DefaultInformationBuilder (io.crnk.core.engine.internal.information.DefaultInformationBuilder)4 NullPropertiesProvider (io.crnk.core.engine.properties.NullPropertiesProvider)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 InformationBuilder (io.crnk.core.engine.information.InformationBuilder)3 DefaultResourceInformationProviderContext (io.crnk.legacy.registry.DefaultResourceInformationProviderContext)3 Before (org.junit.Before)3 CrnkBoot (io.crnk.core.boot.CrnkBoot)2 TypeParser (io.crnk.core.engine.parser.TypeParser)2 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)2 ModuleRegistry (io.crnk.core.module.ModuleRegistry)2 SimpleModule (io.crnk.core.module.SimpleModule)2 DefaultQuerySpecConverter (io.crnk.legacy.internal.DefaultQuerySpecConverter)2 RepositoryInformationProviderContext (io.crnk.core.engine.information.repository.RepositoryInformationProviderContext)1 ResourceField (io.crnk.core.engine.information.resource.ResourceField)1 ResourceFieldAccess (io.crnk.core.engine.information.resource.ResourceFieldAccess)1