Search in sources :

Example 6 with KeysetPageRequest

use of com.blazebit.persistence.deltaspike.data.KeysetPageRequest in project blaze-persistence by Blazebit.

the class KeysetPageableParamConverterProvider method resolveKeysetPageableConfiguration.

private KeysetPageableConfiguration resolveKeysetPageableConfiguration(KeysetConfig keysetConfig, PageableDefault pageableDefault, List<SortDefault> sortDefaults) {
    if (pageableDefault == null && sortDefaults.isEmpty()) {
        return keysetPageableConfiguration;
    }
    KeysetPageableConfigurationImpl keysetPageableConfiguration = new KeysetPageableConfigurationImpl(this.keysetPageableConfiguration);
    apply(keysetPageableConfiguration, pageableDefault, sortDefaults);
    if (keysetConfig != null) {
        if (!keysetConfig.highestName().isEmpty()) {
            keysetPageableConfiguration.setHighestParameterName(keysetConfig.highestName());
        }
        if (!keysetConfig.lowestName().isEmpty()) {
            keysetPageableConfiguration.setLowestParameterName(keysetConfig.lowestName());
        }
        if (!keysetConfig.previousOffsetName().isEmpty()) {
            keysetPageableConfiguration.setPreviousOffsetParameterName(keysetConfig.previousOffsetName());
        }
        if (!keysetConfig.previousPageName().isEmpty()) {
            keysetPageableConfiguration.setPreviousPageParameterName(keysetConfig.previousPageName());
        }
        if (!keysetConfig.previousPageSizeName().isEmpty()) {
            keysetPageableConfiguration.setPreviousSizeParameterName(keysetConfig.previousPageSizeName());
        }
    }
    keysetPageableConfiguration.setFallbackPageable(new KeysetPageRequest(null, keysetPageableConfiguration.getFallbackPageable()));
    return keysetPageableConfiguration;
}
Also used : KeysetPageRequest(com.blazebit.persistence.deltaspike.data.KeysetPageRequest)

Example 7 with KeysetPageRequest

use of com.blazebit.persistence.deltaspike.data.KeysetPageRequest in project blaze-persistence by Blazebit.

the class FullEntityViewRepositoryTest method testFindAllWithKeysetExtraction.

@Test
public void testFindAllWithKeysetExtraction() {
    Pageable pageable = new KeysetPageRequest(null, new Sort("id"), 0, 5, true, true);
    Page<PersonView> page = personViewRepository.findAll(pageable);
    KeysetAwarePage<PersonView> keysetAwarePage = (KeysetAwarePage<PersonView>) page;
    assertEquals(5, keysetAwarePage.getKeysetPage().getKeysets().size());
}
Also used : KeysetAwarePage(com.blazebit.persistence.deltaspike.data.KeysetAwarePage) Pageable(com.blazebit.persistence.deltaspike.data.Pageable) KeysetPageable(com.blazebit.persistence.deltaspike.data.KeysetPageable) KeysetPageRequest(com.blazebit.persistence.deltaspike.data.KeysetPageRequest) Sort(com.blazebit.persistence.deltaspike.data.Sort) PersonView(com.blazebit.persistence.deltaspike.data.testsuite.view.PersonView) Test(org.junit.Test)

Aggregations

KeysetPageRequest (com.blazebit.persistence.deltaspike.data.KeysetPageRequest)7 PageRequest (com.blazebit.persistence.deltaspike.data.PageRequest)5 Test (org.junit.Test)5 KeysetPageable (com.blazebit.persistence.deltaspike.data.KeysetPageable)3 PersonView (com.blazebit.persistence.deltaspike.data.testsuite.view.PersonView)3 Pageable (com.blazebit.persistence.deltaspike.data.Pageable)2 Sort (com.blazebit.persistence.deltaspike.data.Sort)2 Person (com.blazebit.persistence.deltaspike.data.testsuite.entity.Person)2 Category (org.junit.experimental.categories.Category)2 DefaultKeyset (com.blazebit.persistence.DefaultKeyset)1 DefaultKeysetPage (com.blazebit.persistence.DefaultKeysetPage)1 KeysetPage (com.blazebit.persistence.KeysetPage)1 KeysetAwarePage (com.blazebit.persistence.deltaspike.data.KeysetAwarePage)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1