use of io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior in project crnk-framework by crnk-project.
the class CrnkBoot method setupPagingBehavior.
private void setupPagingBehavior() {
if (moduleRegistry.getPagingBehaviors().isEmpty()) {
setupServiceDiscovery();
moduleRegistry.addAllPagingBehaviors(serviceDiscovery.getInstancesByType(PagingBehavior.class));
if (moduleRegistry.getPagingBehaviors().isEmpty()) {
moduleRegistry.addPagingBehavior(new OffsetLimitPagingBehavior());
}
}
for (PagingBehavior pagingBehavior : moduleRegistry.getPagingBehaviors()) {
if (pagingBehavior instanceof OffsetLimitPagingBehavior) {
if (defaultPageLimit != null) {
((OffsetLimitPagingBehavior) pagingBehavior).setDefaultLimit(defaultPageLimit);
}
if (maxPageLimit != null) {
((OffsetLimitPagingBehavior) pagingBehavior).setMaxPageLimit(maxPageLimit);
}
}
}
}
use of io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior 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;
}
use of io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior 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;
}
use of io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior 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());
}
use of io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior 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());
}
Aggregations