Search in sources :

Example 1 with DefaultResourceInstanceBuilder

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

Aggregations

ResourceField (io.crnk.core.engine.information.resource.ResourceField)1 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)1 DefaultResourceInstanceBuilder (io.crnk.core.engine.internal.information.resource.DefaultResourceInstanceBuilder)1 TypeParser (io.crnk.core.engine.parser.TypeParser)1 OffsetLimitPagingBehavior (io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior)1 MetaDataObject (io.crnk.meta.model.MetaDataObject)1 MappedSuperclass (javax.persistence.MappedSuperclass)1