Search in sources :

Example 16 with Order

use of org.springframework.data.domain.Sort.Order in project danyuan-application by 514840279.

the class SysSeedServiceImpl method findAll.

/**
 * 方法名 : findAll
 * 功 能 : TODO(这里用一句话描述这个方法的作用)
 * 参 数 : @return
 * 参 考 : @see tk.ainiyue.admin.roles.service.SysRolesService#findAll()
 * 作 者 : Tenghui.Wang
 */
@Override
public Page<SysSeedInfo> findAll(int pageNumber, int pageSize, String searchText) {
    Sort sort = new Sort(new Order(Direction.DESC, "seedName"));
    PageRequest request = this.buildPageRequest(pageNumber, pageSize, sort);
    Page<SysSeedInfo> sourceCodes = null;
    if (searchText == null || "".equals(searchText)) {
        sourceCodes = sysSeedDao.findAll(request);
    } else {
        SysSeedInfo info = new SysSeedInfo();
        info.setSeedName(searchText);
        Example<SysSeedInfo> example = Example.of(info);
        sourceCodes = sysSeedDao.findAll(example, request);
    }
    return sourceCodes;
}
Also used : Order(org.springframework.data.domain.Sort.Order) PageRequest(org.springframework.data.domain.PageRequest) SysSeedInfo(tk.ainiyue.danyuan.application.crawler.seed.po.SysSeedInfo) Sort(org.springframework.data.domain.Sort)

Example 17 with Order

use of org.springframework.data.domain.Sort.Order in project danyuan-application by 514840279.

the class SysDepartmentServiceImpl method findAllBySearchText.

/**
 * 方法名 : findAllBySearchText
 * 功 能 : TODO(这里用一句话描述这个方法的作用)
 * 参 数 : @param pageNumber
 * 参 数 : @param pageSize
 * 参 数 : @param info
 * 参 数 : @return
 * 参 考 : @see
 * tk.ainiyue.danyuan.application.crm.department.service.SysDepartmentService#findAllBySearchText(int,
 * int, tk.ainiyue.danyuan.application.crm.department.po.SysDepartmentInfo)
 * 作 者 : Administrator
 */
@Override
public Page<SysDepartmentInfo> findAllBySearchText(int pageNumber, int pageSize, SysDepartmentInfo info) {
    Example<SysDepartmentInfo> example = Example.of(info);
    Sort sort = new Sort(new Order(Direction.DESC, "createTime"));
    PageRequest request = new PageRequest(pageNumber - 1, pageSize, sort);
    Page<SysDepartmentInfo> sourceCodes = sysDepartmentDao.findAll(example, request);
    return sourceCodes;
}
Also used : Order(org.springframework.data.domain.Sort.Order) PageRequest(org.springframework.data.domain.PageRequest) Sort(org.springframework.data.domain.Sort) SysDepartmentInfo(tk.ainiyue.danyuan.application.crm.department.po.SysDepartmentInfo)

Example 18 with Order

use of org.springframework.data.domain.Sort.Order in project danyuan-application by 514840279.

the class SysOrganizationServiceImpl method findAllBySearchText.

/**
 * 方法名 : findAllBySearchText
 * 功 能 : TODO(这里用一句话描述这个方法的作用)
 * 参 数 : @param pageNumber
 * 参 数 : @param pageSize
 * 参 数 : @param info
 * 参 数 : @return
 * 参 考 : @see
 * tk.ainiyue.danyuan.application.crm.organization.service.SysOrganizationService#findAllBySearchText(int,
 * int,
 * tk.ainiyue.danyuan.application.crm.organization.po.SysOrganizationInfo)
 * 作 者 : Administrator
 */
@Override
public Page<SysOrganizationInfo> findAllBySearchText(int pageNumber, int pageSize, SysOrganizationInfo info) {
    Example<SysOrganizationInfo> example = Example.of(info);
    Sort sort = new Sort(new Order(Direction.DESC, "createTime"));
    PageRequest request = new PageRequest(pageNumber - 1, pageSize, sort);
    Page<SysOrganizationInfo> sourceCodes = sysOrganizationDao.findAll(example, request);
    return sourceCodes;
}
Also used : Order(org.springframework.data.domain.Sort.Order) SysOrganizationInfo(tk.ainiyue.danyuan.application.crm.organization.po.SysOrganizationInfo) PageRequest(org.springframework.data.domain.PageRequest) Sort(org.springframework.data.domain.Sort)

Example 19 with Order

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

the class DefaultWorkflowHistoricProcessInstanceService method find.

@Override
public Page<WorkflowHistoricProcessInstanceDto> find(WorkflowFilterDto filter, Pageable pageable, BasePermission... permission) {
    String processDefinitionId = filter.getProcessDefinitionId();
    String processInstanceId = filter.getProcessInstanceId();
    Map<String, Object> equalsVariables = filter.getEqualsVariables();
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
    boolean trimmed = true;
    if (processInstanceId != null) {
        // Process variables will be included only for get by instance ID
        trimmed = false;
        query.includeProcessVariables();
        query.processInstanceId(processInstanceId);
    }
    if (processDefinitionId != null) {
        query.processDefinitionId(processDefinitionId);
    }
    if (filter.getSuperProcessInstanceId() != null) {
        query.superProcessInstanceId(filter.getSuperProcessInstanceId());
    }
    if (filter.getProcessDefinitionKey() != null) {
        // For case when we have only process id, we will convert him to key
        query.processDefinitionKey(convertProcessIdToKey(filter.getProcessDefinitionKey()));
    }
    if (filter.getName() != null) {
        // with case sensitive
        query.variableValueLike(WorkflowHistoricProcessInstanceService.PROCESS_INSTANCE_NAME, "%" + filter.getName() + "%");
    }
    if (equalsVariables != null) {
        for (Entry<String, Object> entry : equalsVariables.entrySet()) {
            query.variableValueEquals(entry.getKey(), entry.getValue());
        }
    }
    // TODO: refactor and use username/id from filter
    if (!securityService.isAdmin()) {
        // Applicant and Implementer is added to involved user after process
        // (subprocess) started. This modification allow not use OR clause.
        query.involvedUser(securityService.getCurrentId().toString());
    }
    String fieldForSort = null;
    boolean ascSort = false;
    boolean descSort = false;
    if (pageable != null) {
        Sort sort = pageable.getSort();
        if (sort != null) {
            for (Order order : sort) {
                if (!StringUtils.isEmpty(order.getProperty())) {
                    // TODO: now is implemented only one property sort
                    fieldForSort = order.getProperty();
                    if (order.getDirection() == Direction.ASC) {
                        ascSort = true;
                    } else if (order.getDirection() == Direction.DESC) {
                        descSort = true;
                    }
                    break;
                }
            }
        }
    }
    if (WorkflowHistoricProcessInstanceService.SORT_BY_START_TIME.equals(fieldForSort)) {
        query.orderByProcessInstanceStartTime();
    } else if (WorkflowHistoricProcessInstanceService.SORT_BY_END_TIME.equals(fieldForSort)) {
        query.orderByProcessInstanceEndTime();
    } else {
        query.orderByProcessDefinitionId();
        // there must be default order
        query.asc();
    }
    if (ascSort) {
        query.asc();
    }
    if (descSort) {
        query.desc();
    }
    long count = query.count();
    // it's possible that pageable is null
    List<HistoricProcessInstance> processInstances = null;
    if (pageable == null) {
        processInstances = query.list();
    } else {
        processInstances = query.listPage((pageable.getPageNumber()) * pageable.getPageSize(), pageable.getPageSize());
    }
    List<WorkflowHistoricProcessInstanceDto> dtos = new ArrayList<>();
    if (processInstances != null) {
        for (HistoricProcessInstance instance : processInstances) {
            dtos.add(toResource(instance, trimmed));
        }
    }
    return new PageImpl<WorkflowHistoricProcessInstanceDto>(dtos, pageable, count);
}
Also used : Order(org.springframework.data.domain.Sort.Order) PageImpl(org.springframework.data.domain.PageImpl) HistoricProcessInstanceQuery(org.activiti.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ArrayList(java.util.ArrayList) Sort(org.springframework.data.domain.Sort) WorkflowHistoricProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto)

Example 20 with Order

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

the class DefaultWorkflowHistoricTaskInstanceService method find.

@Override
public Page<WorkflowHistoricTaskInstanceDto> find(WorkflowFilterDto filter, Pageable pageable, BasePermission... permission) {
    String processDefinitionId = filter.getProcessDefinitionId();
    String processInstanceId = filter.getProcessInstanceId();
    HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
    query.includeProcessVariables();
    if (filter.getId() != null) {
        query.taskId(filter.getId().toString());
    }
    if (processInstanceId != null) {
        query.processInstanceId(processInstanceId);
    }
    if (processDefinitionId != null) {
        query.processDefinitionId(processDefinitionId);
    }
    if (filter.getProcessDefinitionKey() != null) {
        query.processDefinitionKey(filter.getProcessDefinitionKey());
    }
    // historic task instance ... admin can see all historic tasks every time
    if (!securityService.isAdmin()) {
        // TODO Now we don't have detail for historic task. When we need detail, then we will need create different projection (detail can't be read by applicant)
        String loggedUserId = securityService.getCurrentId().toString();
        query.taskInvolvedUser(loggedUserId);
    }
    String fieldForSort = null;
    boolean ascSort = false;
    boolean descSort = false;
    if (pageable != null) {
        Sort sort = pageable.getSort();
        if (sort != null) {
            for (Order order : sort) {
                if (!StringUtils.isEmpty(order.getProperty())) {
                    // TODO: now is implemented only one property sort
                    fieldForSort = order.getProperty();
                    if (order.getDirection() == Direction.ASC) {
                        ascSort = true;
                    } else if (order.getDirection() == Direction.DESC) {
                        descSort = true;
                    }
                    break;
                }
            }
        }
    }
    if (WorkflowHistoricTaskInstanceService.SORT_BY_CREATE_TIME.equals(fieldForSort)) {
        query.orderByTaskCreateTime();
    } else if (WorkflowHistoricTaskInstanceService.SORT_BY_END_TIME.equals(fieldForSort)) {
        query.orderByHistoricTaskInstanceEndTime();
    } else {
        query.orderByProcessDefinitionId();
        // there must be default order
        query.asc();
    }
    if (ascSort) {
        query.asc();
    }
    if (descSort) {
        query.desc();
    }
    long count = query.count();
    List<HistoricTaskInstance> processInstances = null;
    if (pageable == null) {
        processInstances = query.list();
    } else {
        processInstances = query.listPage((pageable.getPageNumber()) * pageable.getPageSize(), pageable.getPageSize());
    }
    List<WorkflowHistoricTaskInstanceDto> dtos = new ArrayList<>();
    if (processInstances != null) {
        for (HistoricTaskInstance instance : processInstances) {
            dtos.add(toResource(instance));
        }
    }
    return new PageImpl<WorkflowHistoricTaskInstanceDto>(dtos, pageable, count);
}
Also used : Order(org.springframework.data.domain.Sort.Order) PageImpl(org.springframework.data.domain.PageImpl) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) ArrayList(java.util.ArrayList) Sort(org.springframework.data.domain.Sort) HistoricTaskInstanceQuery(org.activiti.engine.history.HistoricTaskInstanceQuery) WorkflowHistoricTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricTaskInstanceDto)

Aggregations

Order (org.springframework.data.domain.Sort.Order)38 Sort (org.springframework.data.domain.Sort)20 PageRequest (org.springframework.data.domain.PageRequest)14 Test (org.junit.Test)13 Direction (org.springframework.data.domain.Sort.Direction)9 PageImpl (org.springframework.data.domain.PageImpl)8 ArrayList (java.util.ArrayList)6 IdentifiableTestEntity (ca.corefacility.bioinformatics.irida.utils.model.IdentifiableTestEntity)4 IdentifiableTestEntitySpecification (ca.corefacility.bioinformatics.irida.utils.model.IdentifiableTestEntitySpecification)4 Pageable (org.springframework.data.domain.Pageable)4 Specification (org.springframework.data.jpa.domain.Specification)4 Document (org.bson.Document)2 OrderSpecifier (com.querydsl.core.types.OrderSpecifier)1 PathBuilderFactory (com.querydsl.core.types.dsl.PathBuilderFactory)1 StringPath (com.querydsl.core.types.dsl.StringPath)1 ResourcePage (eu.bcvsolutions.idm.core.api.rest.domain.ResourcePage)1 WorkflowHistoricProcessInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto)1 WorkflowHistoricTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricTaskInstanceDto)1 WorkflowProcessInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto)1 Comparator (java.util.Comparator)1