Search in sources :

Example 1 with OrderBy

use of org.alfresco.service.cmr.workflow.WorkflowTaskQuery.OrderBy in project alfresco-repository by Alfresco.

the class ActivitiWorkflowEngine method createRuntimeTaskQuery.

private TaskQuery createRuntimeTaskQuery(WorkflowTaskQuery query) {
    // Add task name
    TaskQuery taskQuery = taskService.createTaskQuery();
    if (!activitiUtil.isMultiTenantWorkflowDeploymentEnabled()) {
        // Filter by tenant domain.
        taskQuery.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain());
    } else if (tenantService.isEnabled() && !TenantUtil.isCurrentDomainDefault() && !StringUtils.isEmpty(TenantUtil.getCurrentDomain())) {
        // Process definition keys are prefixed with the tenant ID, in case MT is enabled and
        // deployments are done in tenant-context
        taskQuery.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "@%");
    }
    if (query.getTaskName() != null) {
        // Task 'key' is stored as variable on task
        String formKey = query.getTaskName().toPrefixString(namespaceService);
        taskQuery.taskVariableValueEquals(ActivitiConstants.PROP_TASK_FORM_KEY, formKey);
    }
    if (query.getProcessId() != null) {
        String processInstanceId = createLocalId(query.getProcessId());
        taskQuery.processInstanceId(processInstanceId);
    }
    if (query.getProcessName() != null) {
        String processName = getProcessNameMTSafe(query.getProcessName());
        taskQuery.processDefinitionKey(processName);
    }
    if (query.getWorkflowDefinitionName() != null) {
        String processName = factory.getProcessKey(query.getWorkflowDefinitionName());
        taskQuery.processDefinitionKey(processName);
    }
    if (query.getActorId() != null) {
        taskQuery.taskAssignee(query.getActorId());
    }
    if (query.getTaskId() != null) {
        String taskId = createLocalId(query.getTaskId());
        taskQuery.taskId(taskId);
    }
    // Custom task properties
    if (query.getTaskCustomProps() != null) {
        addTaskPropertiesToQuery(query.getTaskCustomProps(), taskQuery);
    }
    if (query.getProcessCustomProps() != null) {
        addProcessPropertiesToQuery(query.getProcessCustomProps(), taskQuery);
    }
    // Add ordering
    if (query.getOrderBy() != null) {
        WorkflowTaskQuery.OrderBy[] orderBy = query.getOrderBy();
        orderQuery(taskQuery, orderBy);
    }
    return taskQuery;
}
Also used : OrderBy(org.alfresco.service.cmr.workflow.WorkflowTaskQuery.OrderBy) TaskQuery(org.activiti.engine.task.TaskQuery) WorkflowTaskQuery(org.alfresco.service.cmr.workflow.WorkflowTaskQuery)

Aggregations

TaskQuery (org.activiti.engine.task.TaskQuery)1 WorkflowTaskQuery (org.alfresco.service.cmr.workflow.WorkflowTaskQuery)1 OrderBy (org.alfresco.service.cmr.workflow.WorkflowTaskQuery.OrderBy)1