Search in sources :

Example 96 with Pageable

use of org.springframework.data.domain.Pageable in project goci by EBISPOT.

the class SolrIndexer method mapTraits.

Integer mapTraits() {
    Sort sort = new Sort(new Sort.Order("trait"));
    Pageable pager = new PageRequest(0, pageSize, sort);
    Page<DiseaseTrait> diseaseTraitPage = diseaseTraitRepository.findAll(pager);
    traitMapper.map(diseaseTraitPage.getContent());
    while (diseaseTraitPage.hasNext()) {
        if (maxPages != -1 && diseaseTraitPage.getNumber() >= maxPages - 1) {
            break;
        }
        pager = pager.next();
        diseaseTraitPage = diseaseTraitRepository.findAll(pager);
        traitMapper.map(diseaseTraitPage.getContent());
        if (sysOutLogging) {
            System.out.print(".");
        }
    }
    return (int) diseaseTraitPage.getTotalElements();
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) DiseaseTrait(uk.ac.ebi.spot.goci.model.DiseaseTrait) Sort(org.springframework.data.domain.Sort)

Example 97 with Pageable

use of org.springframework.data.domain.Pageable in project CzechIdMng by bcvsolutions.

the class DefaultWorkflowHistoricProcessInstanceService method search.

/**
 * Search process history. Process variables will be included only for get
 * specific process history. It means filter.processInstanceId is filled.
 *
 * @param filter
 * @return
 */
@Override
public ResourcesWrapper<WorkflowHistoricProcessInstanceDto> search(WorkflowFilterDto filter) {
    Pageable pageable = null;
    // get pageable setting from filter - backward compatibility
    if (StringUtils.isNotEmpty(filter.getSortByFields())) {
        Sort sort = null;
        if (filter.isSortAsc()) {
            sort = new Sort(Direction.ASC, filter.getSortByFields());
        } else {
            sort = new Sort(Direction.DESC, filter.getSortByFields());
        }
        pageable = new PageRequest(filter.getPageNumber(), filter.getPageSize(), sort);
    } else {
        pageable = new PageRequest(filter.getPageNumber(), filter.getPageSize());
    }
    Page<WorkflowHistoricProcessInstanceDto> page = this.find(filter, pageable);
    return new ResourcesWrapper<>(page.getContent(), page.getTotalElements(), page.getTotalPages(), filter.getPageNumber(), filter.getPageSize());
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) ResourcesWrapper(eu.bcvsolutions.idm.core.api.rest.domain.ResourcesWrapper) WorkflowHistoricProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto)

Example 98 with Pageable

use of org.springframework.data.domain.Pageable in project CzechIdMng by bcvsolutions.

the class DefaultWorkflowHistoricTaskInstanceService method search.

@Override
public ResourcesWrapper<WorkflowHistoricTaskInstanceDto> search(WorkflowFilterDto filter) {
    Pageable pageable = null;
    // get pageable setting from filter - backward compatibility
    if (StringUtils.isNotEmpty(filter.getSortByFields())) {
        Sort sort = null;
        if (filter.isSortAsc()) {
            sort = new Sort(Direction.ASC, filter.getSortByFields());
        } else {
            sort = new Sort(Direction.DESC, filter.getSortByFields());
        }
        pageable = new PageRequest(filter.getPageNumber(), filter.getPageSize(), sort);
    } else {
        pageable = new PageRequest(filter.getPageNumber(), filter.getPageSize());
    }
    Page<WorkflowHistoricTaskInstanceDto> page = this.find(filter, pageable);
    return new ResourcesWrapper<>(page.getContent(), page.getTotalElements(), page.getTotalPages(), filter.getPageNumber(), filter.getPageSize());
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) WorkflowHistoricTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricTaskInstanceDto) ResourcesWrapper(eu.bcvsolutions.idm.core.api.rest.domain.ResourcesWrapper)

Example 99 with Pageable

use of org.springframework.data.domain.Pageable in project CzechIdMng by bcvsolutions.

the class DefaultAuditServiceTest method auditQuickSearch.

@Test
public void auditQuickSearch() {
    IdmAuditFilter filter = new IdmAuditFilter();
    filter.setModifier("admin");
    filter.setType(IdmRole.class.getSimpleName());
    Pageable pageable = new PageRequest(0, 10);
    List<IdmAuditDto> result = auditService.find(filter, pageable).getContent();
    for (IdmAuditDto idmAudit : result) {
        assertEquals("admin", idmAudit.getModifier());
        assertEquals(IdmRole.class.getName(), idmAudit.getType());
    }
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) IdmAuditDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmAuditDto) IdmAuditFilter(eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmAuditFilter) IdmRole(eu.bcvsolutions.idm.core.model.entity.IdmRole) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 100 with Pageable

use of org.springframework.data.domain.Pageable in project judge by zjnu-acm.

the class Pageables method buggy.

private Pageable buggy() {
    Sort.Order order = new Sort.Order(Sort.Direction.DESC, "dummy");
    ArrayList<Sort.Order> list = new ArrayList<>(1);
    list.add(order);
    Pageable pageable = new PageRequest(0, 50, new Sort(list));
    list.clear();
    return pageable;
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) ArrayList(java.util.ArrayList) Sort(org.springframework.data.domain.Sort)

Aggregations

Pageable (org.springframework.data.domain.Pageable)172 PageRequest (org.springframework.data.domain.PageRequest)91 Sort (org.springframework.data.domain.Sort)79 Test (org.junit.Test)39 PageImpl (org.springframework.data.domain.PageImpl)24 Collectors (java.util.stream.Collectors)17 Page (org.springframework.data.domain.Page)16 ArrayList (java.util.ArrayList)14 Autowired (org.springframework.beans.factory.annotation.Autowired)14 GetMapping (org.springframework.web.bind.annotation.GetMapping)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 List (java.util.List)11 UUID (java.util.UUID)10 ApiOperation (io.swagger.annotations.ApiOperation)9 Calendar (java.util.Calendar)9 Test (org.junit.jupiter.api.Test)9 java.util (java.util)8 Lists (com.google.common.collect.Lists)7 Map (java.util.Map)6 Transactional (org.springframework.transaction.annotation.Transactional)6