Search in sources :

Example 1 with TypeParser

use of io.crnk.core.engine.parser.TypeParser in project crnk-framework by crnk-project.

the class JpaResourceInformationProvider method build.

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public ResourceInformation build(final Class<?> resourceClass) {
    String resourceType = getResourceType(resourceClass);
    MetaDataObject meta = metaProvider.discoverMeta(resourceClass).asDataObject();
    DefaultResourceInstanceBuilder instanceBuilder = new DefaultResourceInstanceBuilder(resourceClass);
    List<ResourceField> fields = getResourceFields(resourceClass);
    Class<?> superclass = resourceClass.getSuperclass();
    String superResourceType = superclass != Object.class && superclass.getAnnotation(MappedSuperclass.class) == null ? context.getResourceType(superclass) : null;
    TypeParser typeParser = context.getTypeParser();
    ResourceInformation info = new ResourceInformation(typeParser, resourceClass, resourceType, superResourceType, instanceBuilder, fields, new OffsetLimitPagingBehavior());
    info.setValidator(new JpaOptimisticLockingValidator(meta));
    info.setIdStringMapper(new JpaIdMapper(meta));
    return info;
}
Also used : ResourceField(io.crnk.core.engine.information.resource.ResourceField) ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) OffsetLimitPagingBehavior(io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior) TypeParser(io.crnk.core.engine.parser.TypeParser) MetaDataObject(io.crnk.meta.model.MetaDataObject) MappedSuperclass(javax.persistence.MappedSuperclass) DefaultResourceInstanceBuilder(io.crnk.core.engine.internal.information.resource.DefaultResourceInstanceBuilder)

Example 2 with TypeParser

use of io.crnk.core.engine.parser.TypeParser in project crnk-framework by crnk-project.

the class RegistryEntryTest method newRepositoryInformation.

private <T> ResourceRepositoryInformation newRepositoryInformation(Class<T> repositoryClass, String path) {
    ModuleRegistry moduleRegistry = new ModuleRegistry();
    TypeParser typeParser = moduleRegistry.getTypeParser();
    return new ResourceRepositoryInformationImpl(path, new ResourceInformation(typeParser, Task.class, path, null, null, null, null), RepositoryMethodAccess.ALL);
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Task(io.crnk.core.mock.models.Task) TypeParser(io.crnk.core.engine.parser.TypeParser) ResourceRepositoryInformationImpl(io.crnk.core.engine.internal.information.repository.ResourceRepositoryInformationImpl) ModuleRegistry(io.crnk.core.module.ModuleRegistry)

Example 3 with TypeParser

use of io.crnk.core.engine.parser.TypeParser in project crnk-framework by crnk-project.

the class DefaultInformationBuilderTest method setup.

@Before
public void setup() {
    TypeParser parser = new TypeParser();
    builder = new DefaultInformationBuilder(parser);
}
Also used : TypeParser(io.crnk.core.engine.parser.TypeParser) Before(org.junit.Before)

Example 4 with TypeParser

use of io.crnk.core.engine.parser.TypeParser in project crnk-framework by crnk-project.

the class TestResourceInformationProvider method build.

@Override
public ResourceInformation build(Class<?> resourceClass) {
    ResourceField idField = new ResourceFieldImpl("testId", "id", ResourceFieldType.ID, Integer.class, null, null);
    List<ResourceField> fields = Arrays.asList(idField);
    TypeParser typeParser = context.getTypeParser();
    ResourceInformation info = new ResourceInformation(typeParser, resourceClass, resourceClass.getSimpleName(), null, fields, new OffsetLimitPagingBehavior());
    return info;
}
Also used : ResourceField(io.crnk.core.engine.information.resource.ResourceField) ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) OffsetLimitPagingBehavior(io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior) ResourceFieldImpl(io.crnk.core.engine.internal.information.resource.ResourceFieldImpl) TypeParser(io.crnk.core.engine.parser.TypeParser)

Example 5 with TypeParser

use of io.crnk.core.engine.parser.TypeParser in project crnk-framework by crnk-project.

the class ResourceInformationTest method setup.

@Before
public void setup() throws NoSuchFieldException {
    ResourceField idField = new ResourceFieldImpl("id", "id", ResourceFieldType.ID, Long.class, Long.class, null);
    ResourceField valueField = new ResourceFieldImpl("value", "value", ResourceFieldType.RELATIONSHIP, String.class, String.class, "projects");
    TypeParser typeParser = new TypeParser();
    sut = new ResourceInformation(typeParser, Task.class, "tasks", null, Arrays.asList(idField, valueField), new OffsetLimitPagingBehavior());
}
Also used : ResourceField(io.crnk.core.engine.information.resource.ResourceField) ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Task(io.crnk.core.mock.models.Task) OffsetLimitPagingBehavior(io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior) ResourceFieldImpl(io.crnk.core.engine.internal.information.resource.ResourceFieldImpl) TypeParser(io.crnk.core.engine.parser.TypeParser) Before(org.junit.Before)

Aggregations

TypeParser (io.crnk.core.engine.parser.TypeParser)13 Before (org.junit.Before)7 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)5 OffsetLimitPagingBehavior (io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 InformationBuilder (io.crnk.core.engine.information.InformationBuilder)4 ResourceField (io.crnk.core.engine.information.resource.ResourceField)4 DefaultInformationBuilder (io.crnk.core.engine.internal.information.DefaultInformationBuilder)3 ModuleRegistry (io.crnk.core.module.ModuleRegistry)3 ResourceInformationProvider (io.crnk.core.engine.information.resource.ResourceInformationProvider)2 ResourceInformationProviderContext (io.crnk.core.engine.information.resource.ResourceInformationProviderContext)2 DefaultResourceFieldInformationProvider (io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider)2 DefaultResourceInformationProvider (io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider)2 ResourceFieldImpl (io.crnk.core.engine.internal.information.resource.ResourceFieldImpl)2 JacksonResourceFieldInformationProvider (io.crnk.core.engine.internal.jackson.JacksonResourceFieldInformationProvider)2 NullPropertiesProvider (io.crnk.core.engine.properties.NullPropertiesProvider)2 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)2 Task (io.crnk.core.mock.models.Task)2 TestResourceInformationProvider (io.crnk.core.module.TestResourceInformationProvider)2 SimpleQueryParamsParserContext (io.crnk.legacy.queryParams.context.SimpleQueryParamsParserContext)2