Search in sources :

Example 1 with PageImpl

use of org.activiti.runtime.api.query.impl.PageImpl in project Activiti by Activiti.

the class TaskAdminRuntimeImpl method tasks.

@Override
public Page<Task> tasks(Pageable pageable, GetTasksPayload getTasksPayload) {
    TaskQuery taskQuery = taskService.createTaskQuery();
    if (getTasksPayload.getProcessInstanceId() != null) {
        taskQuery = taskQuery.processInstanceId(getTasksPayload.getProcessInstanceId());
    }
    if (getTasksPayload.getParentTaskId() != null) {
        taskQuery = taskQuery.taskParentTaskId(getTasksPayload.getParentTaskId());
    }
    List<Task> tasks = taskConverter.from(taskQuery.listPage(pageable.getStartIndex(), pageable.getMaxItems()));
    return new PageImpl<>(tasks, Math.toIntExact(taskQuery.count()));
}
Also used : PageImpl(org.activiti.runtime.api.query.impl.PageImpl) Task(org.activiti.api.task.model.Task) TaskQuery(org.activiti.engine.task.TaskQuery)

Example 2 with PageImpl

use of org.activiti.runtime.api.query.impl.PageImpl in project Activiti by Activiti.

the class TaskRuntimeImpl method tasks.

@Override
public Page<Task> tasks(Pageable pageable, GetTasksPayload getTasksPayload) {
    TaskQuery taskQuery = taskService.createTaskQuery();
    if (getTasksPayload == null) {
        getTasksPayload = TaskPayloadBuilder.tasks().build();
    }
    String authenticatedUserId = securityManager.getAuthenticatedUserId();
    if (authenticatedUserId != null && !authenticatedUserId.isEmpty()) {
        List<String> userGroups = securityManager.getAuthenticatedUserGroups();
        getTasksPayload.setAssigneeId(authenticatedUserId);
        getTasksPayload.setGroups(userGroups);
    } else {
        throw new IllegalStateException("You need an authenticated user to perform a task query");
    }
    taskQuery = taskQuery.or().taskCandidateOrAssigned(getTasksPayload.getAssigneeId(), getTasksPayload.getGroups()).taskOwner(authenticatedUserId).endOr();
    if (getTasksPayload.getProcessInstanceId() != null) {
        taskQuery = taskQuery.processInstanceId(getTasksPayload.getProcessInstanceId());
    }
    if (getTasksPayload.getParentTaskId() != null) {
        taskQuery = taskQuery.taskParentTaskId(getTasksPayload.getParentTaskId());
    }
    List<Task> tasks = taskConverter.from(taskQuery.listPage(pageable.getStartIndex(), pageable.getMaxItems()));
    return new PageImpl<>(tasks, Math.toIntExact(taskQuery.count()));
}
Also used : PageImpl(org.activiti.runtime.api.query.impl.PageImpl) Task(org.activiti.api.task.model.Task) TaskQuery(org.activiti.engine.task.TaskQuery)

Example 3 with PageImpl

use of org.activiti.runtime.api.query.impl.PageImpl in project Activiti by Activiti.

the class ProcessRuntimeImpl method processDefinitions.

@Override
public Page<ProcessDefinition> processDefinitions(Pageable pageable, GetProcessDefinitionsPayload getProcessDefinitionsPayload) {
    if (getProcessDefinitionsPayload == null) {
        throw new IllegalStateException("payload cannot be null");
    }
    GetProcessDefinitionsPayload securityKeysInPayload = securityPoliciesManager.restrictProcessDefQuery(SecurityPolicyAccess.READ);
    // else ignore and use the user provided ones.
    if (!securityKeysInPayload.getProcessDefinitionKeys().isEmpty()) {
        getProcessDefinitionsPayload.setProcessDefinitionKeys(securityKeysInPayload.getProcessDefinitionKeys());
    }
    ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
    if (getProcessDefinitionsPayload.hasDefinitionKeys()) {
        processDefinitionQuery.processDefinitionKeys(getProcessDefinitionsPayload.getProcessDefinitionKeys());
    }
    List<org.activiti.engine.repository.ProcessDefinition> currentVersionDefinitions = filterCurrentVersionDefinitions(processDefinitionQuery.list());
    return new PageImpl<>(processDefinitionConverter.from(currentVersionDefinitions), Math.toIntExact(processDefinitionQuery.count()));
}
Also used : PageImpl(org.activiti.runtime.api.query.impl.PageImpl) ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) GetProcessDefinitionsPayload(org.activiti.api.process.model.payloads.GetProcessDefinitionsPayload)

Example 4 with PageImpl

use of org.activiti.runtime.api.query.impl.PageImpl in project Activiti by Activiti.

the class ProcessRuntimeImpl method processInstances.

@Override
public Page<ProcessInstance> processInstances(Pageable pageable, GetProcessInstancesPayload getProcessInstancesPayload) {
    if (getProcessInstancesPayload == null) {
        throw new IllegalStateException("payload cannot be null");
    }
    GetProcessInstancesPayload securityKeysInPayload = securityPoliciesManager.restrictProcessInstQuery(SecurityPolicyAccess.READ);
    org.activiti.engine.runtime.ProcessInstanceQuery internalQuery = runtimeService.createProcessInstanceQuery();
    if (!securityKeysInPayload.getProcessDefinitionKeys().isEmpty()) {
        getProcessInstancesPayload.setProcessDefinitionKeys(securityKeysInPayload.getProcessDefinitionKeys());
    }
    if (getProcessInstancesPayload.getProcessDefinitionKeys() != null && !getProcessInstancesPayload.getProcessDefinitionKeys().isEmpty()) {
        internalQuery.processDefinitionKeys(getProcessInstancesPayload.getProcessDefinitionKeys());
    }
    if (getProcessInstancesPayload.getBusinessKey() != null && !getProcessInstancesPayload.getBusinessKey().isEmpty()) {
        internalQuery.processInstanceBusinessKey(getProcessInstancesPayload.getBusinessKey());
    }
    if (getProcessInstancesPayload.isSuspendedOnly()) {
        internalQuery.suspended();
    }
    if (getProcessInstancesPayload.isActiveOnly()) {
        internalQuery.active();
    }
    if (getProcessInstancesPayload.getParentProcessInstanceId() != null) {
        internalQuery.superProcessInstanceId(getProcessInstancesPayload.getParentProcessInstanceId());
    }
    return new PageImpl<>(processInstanceConverter.from(internalQuery.listPage(pageable.getStartIndex(), pageable.getMaxItems())), Math.toIntExact(internalQuery.count()));
}
Also used : PageImpl(org.activiti.runtime.api.query.impl.PageImpl) GetProcessInstancesPayload(org.activiti.api.process.model.payloads.GetProcessInstancesPayload)

Aggregations

PageImpl (org.activiti.runtime.api.query.impl.PageImpl)4 Task (org.activiti.api.task.model.Task)2 TaskQuery (org.activiti.engine.task.TaskQuery)2 ProcessDefinition (org.activiti.api.process.model.ProcessDefinition)1 GetProcessDefinitionsPayload (org.activiti.api.process.model.payloads.GetProcessDefinitionsPayload)1 GetProcessInstancesPayload (org.activiti.api.process.model.payloads.GetProcessInstancesPayload)1 ProcessDefinitionQuery (org.activiti.engine.repository.ProcessDefinitionQuery)1