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()));
}
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()));
}
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()));
}
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()));
}
Aggregations