Search in sources :

Example 66 with PageRequest

use of org.springframework.data.domain.PageRequest in project ignite by apache.

the class IgniteSpringDataQueriesSelfTest method testSliceOfLists.

/**
 */
public void testSliceOfLists() {
    Slice<List> lists = repo2.querySliceOfList("^[a-z]+$", new PageRequest(0, 3));
    assertEquals(3, lists.getSize());
    for (List list : lists) {
        assertEquals(2, list.size());
        assertTrue(list.get(0) instanceof Integer);
    }
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) List(java.util.List)

Example 67 with PageRequest

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

the class RetryProvisioningTaskExecutor method process.

@Override
public Boolean process() {
    LOG.info("Retry provisioning executor starts for all next attmepts old than [{}]", start);
    counter = 0L;
    boolean canContinue = true;
    while (canContinue) {
        // we process all batches
        Page<SysProvisioningBatchDto> batches = provisioningBatchService.findBatchesToRetry(start, new PageRequest(0, 100));
        // init count
        if (count == null) {
            count = batches.getTotalElements();
        }
        // 
        for (SysProvisioningBatchDto batch : batches) {
            try {
                provisioningExecutor.execute(batch);
                counter++;
                canContinue = updateState();
            } catch (Exception ex) {
                // TODO: stateful task executor with item reselt state
                LOG.error("Batch [{}] execution failed", batch.getId(), ex);
            }
            if (!canContinue) {
                break;
            }
        }
        if (!batches.hasNext()) {
            break;
        }
    }
    LOG.info("Retry provisioning executor ended for all next attempts old than [{}]", start);
    return Boolean.TRUE;
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto)

Example 68 with PageRequest

use of org.springframework.data.domain.PageRequest 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 69 with PageRequest

use of org.springframework.data.domain.PageRequest 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 70 with PageRequest

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

the class DefaultIdmScheduledTaskService method findByQuartzTaskName.

@Transactional(readOnly = true)
@Override
public IdmScheduledTaskDto findByQuartzTaskName(String taskName) {
    IdmScheduledTaskFilter filter = new IdmScheduledTaskFilter();
    filter.setQuartzTaskName(taskName);
    Page<IdmScheduledTaskDto> results = find(filter, new PageRequest(0, 1));
    if (results.getTotalElements() == 0) {
        return null;
    } else if (results.getTotalElements() == 1) {
        return results.iterator().next();
    }
    throw new SchedulerException(CoreResultCode.SEARCH_ERROR, ImmutableMap.of("reason", "Multiple tasks found for " + getClass().getSimpleName() + " task."));
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) SchedulerException(eu.bcvsolutions.idm.core.scheduler.exception.SchedulerException) IdmScheduledTaskFilter(eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmScheduledTaskFilter) IdmScheduledTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmScheduledTaskDto) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

PageRequest (org.springframework.data.domain.PageRequest)106 Sort (org.springframework.data.domain.Sort)29 Pageable (org.springframework.data.domain.Pageable)25 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)14 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)9 Transactional (org.springframework.transaction.annotation.Transactional)9 UUID (java.util.UUID)8 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)7 ApiOperation (io.swagger.annotations.ApiOperation)7 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)6 IdmTreeNode (eu.bcvsolutions.idm.core.model.entity.IdmTreeNode)6 List (java.util.List)6 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)5 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)5 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)5 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)5 PageImpl (org.springframework.data.domain.PageImpl)5