Search in sources :

Example 11 with HistoricTaskInstanceQuery

use of org.activiti.engine.history.HistoricTaskInstanceQuery in project alfresco-remote-api by Alfresco.

the class TasksImpl method getTasks.

@Override
public CollectionWithPagingInfo<Task> getTasks(Parameters parameters) {
    Paging paging = parameters.getPaging();
    MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(TASK_COLLECTION_EQUALS_QUERY_PROPERTIES, TASK_COLLECTION_MATCHES_QUERY_PROPERTIES);
    propertyWalker.setSupportedGreaterThanParameters(TASK_COLLECTION_GREATERTHAN_QUERY_PROPERTIES);
    propertyWalker.setSupportedGreaterThanOrEqualParameters(TASK_COLLECTION_GREATERTHANOREQUAL_QUERY_PROPERTIES);
    propertyWalker.setSupportedLessThanParameters(TASK_COLLECTION_LESSTHAN_QUERY_PROPERTIES);
    propertyWalker.setSupportedLessThanOrEqualParameters(TASK_COLLECTION_LESSTHANOREQUAL_QUERY_PROPERTIES);
    propertyWalker.enableVariablesSupport(namespaceService, dictionaryService);
    if (parameters.getQuery() != null) {
        QueryHelper.walk(parameters.getQuery(), propertyWalker);
    }
    String status = propertyWalker.getProperty("status", WhereClauseParser.EQUALS);
    String assignee = propertyWalker.getProperty("assignee", WhereClauseParser.EQUALS);
    String assigneeLike = propertyWalker.getProperty("assignee", WhereClauseParser.MATCHES);
    String owner = propertyWalker.getProperty("owner", WhereClauseParser.EQUALS);
    String ownerLike = propertyWalker.getProperty("owner", WhereClauseParser.MATCHES);
    String candidateUser = propertyWalker.getProperty("candidateUser", WhereClauseParser.EQUALS);
    String candidateGroup = propertyWalker.getProperty("candidateGroup", WhereClauseParser.EQUALS);
    String name = propertyWalker.getProperty("name", WhereClauseParser.EQUALS);
    String nameLike = propertyWalker.getProperty("name", WhereClauseParser.MATCHES);
    String description = propertyWalker.getProperty("description", WhereClauseParser.EQUALS);
    String descriptionLike = propertyWalker.getProperty("description", WhereClauseParser.MATCHES);
    Integer priority = propertyWalker.getProperty("priority", WhereClauseParser.EQUALS, Integer.class);
    Integer priorityGreaterThanOrEquals = propertyWalker.getProperty("priority", WhereClauseParser.GREATERTHANOREQUALS, Integer.class);
    Integer priorityLessThanOrEquals = propertyWalker.getProperty("priority", WhereClauseParser.LESSTHANOREQUALS, Integer.class);
    String processInstanceId = propertyWalker.getProperty("processId", WhereClauseParser.EQUALS);
    String processInstanceBusinessKey = propertyWalker.getProperty("processBusinessKey", WhereClauseParser.EQUALS);
    String processInstanceBusinessKeyLike = propertyWalker.getProperty("processBusinessKey", WhereClauseParser.MATCHES);
    String activityDefinitionId = propertyWalker.getProperty("activityDefinitionId", WhereClauseParser.EQUALS);
    String activityDefinitionIdLike = propertyWalker.getProperty("activityDefinitionId", WhereClauseParser.MATCHES);
    String processDefinitionId = propertyWalker.getProperty("processDefinitionId", WhereClauseParser.EQUALS);
    String processDefinitionKey = propertyWalker.getProperty("processDefinitionKey", WhereClauseParser.EQUALS);
    String processDefinitionKeyLike = propertyWalker.getProperty("processDefinitionKey", WhereClauseParser.MATCHES);
    String processDefinitionName = propertyWalker.getProperty("processDefinitionName", WhereClauseParser.EQUALS);
    String processDefinitionNameLike = propertyWalker.getProperty("processDefinitionName", WhereClauseParser.MATCHES);
    Date startedAt = propertyWalker.getProperty("startedAt", WhereClauseParser.EQUALS, Date.class);
    Date startedAtGreaterThan = propertyWalker.getProperty("startedAt", WhereClauseParser.GREATERTHAN, Date.class);
    Date startedAtLessThan = propertyWalker.getProperty("startedAt", WhereClauseParser.LESSTHAN, Date.class);
    Date endedAt = propertyWalker.getProperty("endedAt", WhereClauseParser.EQUALS, Date.class);
    Date endedAtGreaterThan = propertyWalker.getProperty("endedAt", WhereClauseParser.GREATERTHAN, Date.class);
    Date endedAtLessThan = propertyWalker.getProperty("endedAt", WhereClauseParser.LESSTHAN, Date.class);
    Date dueAt = propertyWalker.getProperty("dueAt", WhereClauseParser.EQUALS, Date.class);
    Date dueAtGreaterThan = propertyWalker.getProperty("dueAt", WhereClauseParser.GREATERTHAN, Date.class);
    Date dueAtLessThan = propertyWalker.getProperty("dueAt", WhereClauseParser.LESSTHAN, Date.class);
    Boolean includeProcessVariables = propertyWalker.getProperty("includeProcessVariables", WhereClauseParser.EQUALS, Boolean.class);
    Boolean includeTaskVariables = propertyWalker.getProperty("includeTaskVariables", WhereClauseParser.EQUALS, Boolean.class);
    List<SortColumn> sortList = parameters.getSorting();
    SortColumn sortColumn = null;
    if (sortList != null && sortList.size() > 0) {
        if (sortList.size() != 1) {
            throw new InvalidArgumentException("Only one order by parameter is supported");
        }
        sortColumn = sortList.get(0);
    }
    List<Task> page = null;
    int totalCount = 0;
    if (status == null || STATUS_ACTIVE.equals(status)) {
        TaskQuery query = activitiProcessEngine.getTaskService().createTaskQuery();
        if (assignee != null)
            query.taskAssignee(assignee);
        if (assigneeLike != null)
            query.taskAssigneeLike(assigneeLike);
        if (owner != null)
            query.taskOwner(owner);
        if (ownerLike != null)
            query.taskOwner(ownerLike);
        if (candidateUser != null) {
            Set<String> parents = authorityService.getContainingAuthorities(AuthorityType.GROUP, candidateUser, false);
            if (parents != null) {
                List<String> authorities = new ArrayList<String>();
                authorities.addAll(parents);
                // there's a limitation in at least Oracle for using an IN statement with more than 1000 items
                if (parents.size() > 1000) {
                    authorities = authorities.subList(0, 1000);
                }
                if (authorities.size() > 0) {
                    query.taskCandidateGroupIn(authorities);
                } else {
                    query.taskCandidateUser(candidateUser);
                }
            }
        }
        if (candidateGroup != null)
            query.taskCandidateGroup(candidateGroup);
        if (name != null)
            query.taskName(name);
        if (nameLike != null)
            query.taskNameLike(nameLike);
        if (description != null)
            query.taskDescription(description);
        if (descriptionLike != null)
            query.taskDescriptionLike(descriptionLike);
        if (priority != null)
            query.taskPriority(priority);
        if (priorityGreaterThanOrEquals != null)
            query.taskMinPriority(priorityGreaterThanOrEquals);
        if (priorityLessThanOrEquals != null)
            query.taskMaxPriority(priorityLessThanOrEquals);
        if (processInstanceId != null)
            query.processInstanceId(processInstanceId);
        if (processInstanceBusinessKey != null)
            query.processInstanceBusinessKey(processInstanceBusinessKey);
        if (processInstanceBusinessKeyLike != null)
            query.processInstanceBusinessKeyLike(processInstanceBusinessKeyLike);
        if (activityDefinitionId != null)
            query.taskDefinitionKey(activityDefinitionId);
        if (activityDefinitionIdLike != null)
            query.taskDefinitionKey(activityDefinitionIdLike);
        if (processDefinitionId != null)
            query.processDefinitionId(processDefinitionId);
        if (processDefinitionKey != null)
            query.processDefinitionKey(processDefinitionKey);
        if (processDefinitionKeyLike != null)
            query.processDefinitionKeyLike(processDefinitionKeyLike);
        if (processDefinitionName != null)
            query.processDefinitionName(processDefinitionName);
        if (processDefinitionNameLike != null)
            query.processDefinitionNameLike(processDefinitionNameLike);
        if (dueAt != null)
            query.dueDate(dueAt);
        if (dueAtGreaterThan != null)
            query.dueAfter(dueAtGreaterThan);
        if (dueAtLessThan != null)
            query.dueBefore(dueAtLessThan);
        if (startedAt != null)
            query.taskCreatedOn(startedAt);
        if (startedAtGreaterThan != null)
            query.taskCreatedAfter(startedAtGreaterThan);
        if (startedAtLessThan != null)
            query.taskCreatedBefore(startedAtLessThan);
        if (includeProcessVariables != null && includeProcessVariables) {
            query.includeProcessVariables();
        }
        if (includeTaskVariables != null && includeTaskVariables) {
            query.includeTaskLocalVariables();
        }
        // use the limit set in alfresco-global.properties
        query.limitTaskVariables(taskVariablesLimit);
        List<QueryVariableHolder> variableProperties = propertyWalker.getVariableProperties();
        setQueryUsingVariables(query, variableProperties);
        // Add tenant-filtering
        if (tenantService.isEnabled()) {
            query.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain());
        }
        // Add involvement filtering if user is not admin
        if (processInstanceId == null && !authorityService.isAdminAuthority(AuthenticationUtil.getRunAsUser()) && candidateUser == null && candidateGroup == null) {
            query.taskInvolvedUser(AuthenticationUtil.getRunAsUser());
        }
        setSorting(query, sortColumn);
        List<org.activiti.engine.task.Task> tasks = query.listPage(paging.getSkipCount(), paging.getMaxItems());
        totalCount = (int) query.count();
        page = new ArrayList<Task>(tasks.size());
        Map<String, TypeDefinition> definitionTypeMap = new HashMap<String, TypeDefinition>();
        for (org.activiti.engine.task.Task taskInstance : tasks) {
            Task task = new Task(taskInstance);
            task.setFormResourceKey(getFormResourceKey(taskInstance));
            if ((includeProcessVariables != null && includeProcessVariables) || (includeTaskVariables != null && includeTaskVariables)) {
                addVariables(task, includeProcessVariables, includeTaskVariables, taskInstance.getProcessVariables(), taskInstance.getTaskLocalVariables(), definitionTypeMap);
            }
            page.add(task);
        }
    } else if (STATUS_COMPLETED.equals(status) || STATUS_ANY.equals(status)) {
        // Candidate user and group is only supported with STATUS_ACTIVE
        if (candidateUser != null) {
            throw new InvalidArgumentException("Filtering on candidateUser is only allowed in combination with status-parameter 'active'");
        }
        if (candidateGroup != null) {
            throw new InvalidArgumentException("Filtering on candidateGroup is only allowed in combination with status-parameter 'active'");
        }
        HistoricTaskInstanceQuery query = activitiProcessEngine.getHistoryService().createHistoricTaskInstanceQuery();
        if (STATUS_COMPLETED.equals(status))
            query.finished();
        if (assignee != null)
            query.taskAssignee(assignee);
        if (assigneeLike != null)
            query.taskAssigneeLike(assigneeLike);
        if (owner != null)
            query.taskOwner(owner);
        if (ownerLike != null)
            query.taskOwnerLike(ownerLike);
        if (name != null)
            query.taskName(name);
        if (nameLike != null)
            query.taskNameLike(nameLike);
        if (description != null)
            query.taskDescription(description);
        if (descriptionLike != null)
            query.taskDescriptionLike(descriptionLike);
        if (priority != null)
            query.taskPriority(priority);
        if (priorityGreaterThanOrEquals != null)
            query.taskMinPriority(priorityGreaterThanOrEquals);
        if (priorityLessThanOrEquals != null)
            query.taskMaxPriority(priorityLessThanOrEquals);
        if (processInstanceId != null)
            query.processInstanceId(processInstanceId);
        if (processInstanceBusinessKey != null)
            query.processInstanceBusinessKey(processInstanceBusinessKey);
        if (processInstanceBusinessKeyLike != null)
            query.processInstanceBusinessKeyLike(processInstanceBusinessKeyLike);
        if (activityDefinitionId != null)
            query.taskDefinitionKey(activityDefinitionId);
        if (activityDefinitionIdLike != null)
            query.taskDefinitionKey(activityDefinitionIdLike);
        if (processDefinitionId != null)
            query.processDefinitionId(processDefinitionId);
        if (processDefinitionKey != null)
            query.processDefinitionKey(processDefinitionKey);
        if (processDefinitionKeyLike != null)
            query.processDefinitionKeyLike(processDefinitionKeyLike);
        if (processDefinitionName != null)
            query.processDefinitionName(processDefinitionName);
        if (processDefinitionNameLike != null)
            query.processDefinitionNameLike(processDefinitionNameLike);
        if (dueAt != null)
            query.taskDueDate(dueAt);
        if (dueAtGreaterThan != null)
            query.taskDueAfter(dueAtGreaterThan);
        if (dueAtLessThan != null)
            query.taskDueBefore(dueAtLessThan);
        if (startedAt != null)
            query.taskCreatedOn(startedAt);
        if (startedAtGreaterThan != null)
            query.taskCreatedAfter(startedAtGreaterThan);
        if (startedAtLessThan != null)
            query.taskCreatedBefore(startedAtLessThan);
        if (endedAt != null)
            query.taskCompletedOn(endedAt);
        if (endedAtGreaterThan != null)
            query.taskCompletedAfter(endedAtGreaterThan);
        if (endedAtLessThan != null)
            query.taskCompletedBefore(endedAtLessThan);
        if (includeProcessVariables != null && includeProcessVariables) {
            query.includeProcessVariables();
        }
        if (includeTaskVariables != null && includeTaskVariables) {
            query.includeTaskLocalVariables();
        }
        List<QueryVariableHolder> variableProperties = propertyWalker.getVariableProperties();
        setQueryUsingVariables(query, variableProperties);
        // Add tenant filtering
        if (tenantService.isEnabled()) {
            query.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain());
        }
        // Add involvement filtering if user is not admin
        if (processInstanceId == null && !authorityService.isAdminAuthority(AuthenticationUtil.getRunAsUser())) {
            query.taskInvolvedUser(AuthenticationUtil.getRunAsUser());
        }
        setSorting(query, sortColumn);
        List<HistoricTaskInstance> tasks = query.listPage(paging.getSkipCount(), paging.getMaxItems());
        totalCount = (int) query.count();
        page = new ArrayList<Task>(tasks.size());
        Map<String, TypeDefinition> definitionTypeMap = new HashMap<String, TypeDefinition>();
        for (HistoricTaskInstance taskInstance : tasks) {
            Task task = new Task(taskInstance);
            if ((includeProcessVariables != null && includeProcessVariables) || (includeTaskVariables != null && includeTaskVariables)) {
                addVariables(task, includeProcessVariables, includeTaskVariables, taskInstance.getProcessVariables(), taskInstance.getTaskLocalVariables(), definitionTypeMap);
            }
            page.add(task);
        }
    } else {
        throw new InvalidArgumentException("Invalid status parameter: " + status);
    }
    return CollectionWithPagingInfo.asPaged(paging, page, (page.size() + paging.getSkipCount()) < totalCount, totalCount);
}
Also used : Task(org.alfresco.rest.workflow.api.model.Task) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) QueryVariableHolder(org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker.QueryVariableHolder) SortColumn(org.alfresco.rest.framework.resource.parameters.SortColumn) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition) DataTypeDefinition(org.alfresco.service.cmr.dictionary.DataTypeDefinition) InvalidArgumentException(org.alfresco.rest.framework.core.exceptions.InvalidArgumentException) TaskQuery(org.activiti.engine.task.TaskQuery) List(java.util.List) ArrayList(java.util.ArrayList) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) Paging(org.alfresco.rest.framework.resource.parameters.Paging) HistoricTaskInstanceQuery(org.activiti.engine.history.HistoricTaskInstanceQuery) Date(java.util.Date) Map(java.util.Map) HashMap(java.util.HashMap)

Example 12 with HistoricTaskInstanceQuery

use of org.activiti.engine.history.HistoricTaskInstanceQuery in project alfresco-remote-api by Alfresco.

the class TasksImpl method getTasks.

@Override
public CollectionWithPagingInfo<Task> getTasks(String processId, Parameters parameters) {
    Paging paging = parameters.getPaging();
    String status = parameters.getParameter("status");
    List<SortColumn> sortList = parameters.getSorting();
    SortColumn sortColumn = null;
    if (sortList != null && sortList.size() > 0) {
        if (sortList.size() != 1) {
            throw new InvalidArgumentException("Only one order by parameter is supported");
        }
        sortColumn = sortList.get(0);
    }
    validateIfUserAllowedToWorkWithProcess(processId);
    List<Task> page = null;
    int totalCount = 0;
    if (status == null || STATUS_ACTIVE.equals(status)) {
        TaskQuery query = activitiProcessEngine.getTaskService().createTaskQuery();
        query.processInstanceId(processId);
        setSorting(query, sortColumn);
        List<org.activiti.engine.task.Task> tasks = query.listPage(paging.getSkipCount(), paging.getMaxItems());
        totalCount = (int) query.count();
        page = new ArrayList<Task>(tasks.size());
        for (org.activiti.engine.task.Task taskInstance : tasks) {
            Task task = new Task(taskInstance);
            task.setFormResourceKey(getFormResourceKey(taskInstance));
            page.add(task);
        }
    } else if (STATUS_COMPLETED.equals(status) || STATUS_ANY.equals(status)) {
        HistoricTaskInstanceQuery query = activitiProcessEngine.getHistoryService().createHistoricTaskInstanceQuery();
        if (STATUS_COMPLETED.equals(status))
            query.finished();
        query.processInstanceId(processId);
        // Add tenant filtering
        if (tenantService.isEnabled()) {
            query.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain());
        }
        setSorting(query, sortColumn);
        List<HistoricTaskInstance> tasks = query.listPage(paging.getSkipCount(), paging.getMaxItems());
        totalCount = (int) query.count();
        page = new ArrayList<Task>(tasks.size());
        for (HistoricTaskInstance taskInstance : tasks) {
            Task task = new Task(taskInstance);
            page.add(task);
        }
    } else {
        throw new InvalidArgumentException("Invalid status parameter: " + status);
    }
    return CollectionWithPagingInfo.asPaged(paging, page, (page.size() + paging.getSkipCount()) < totalCount, totalCount);
}
Also used : Task(org.alfresco.rest.workflow.api.model.Task) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) Paging(org.alfresco.rest.framework.resource.parameters.Paging) ArrayList(java.util.ArrayList) SortColumn(org.alfresco.rest.framework.resource.parameters.SortColumn) HistoricTaskInstanceQuery(org.activiti.engine.history.HistoricTaskInstanceQuery) InvalidArgumentException(org.alfresco.rest.framework.core.exceptions.InvalidArgumentException) TaskQuery(org.activiti.engine.task.TaskQuery) List(java.util.List) ArrayList(java.util.ArrayList)

Example 13 with HistoricTaskInstanceQuery

use of org.activiti.engine.history.HistoricTaskInstanceQuery in project Activiti by Activiti.

the class HistoryServiceTest method testHistoricTaskInstanceQueryByDeploymentId.

@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceQueryByDeploymentId() {
    org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
    HashSet<String> processInstanceIds = new HashSet<String>();
    for (int i = 0; i < 4; i++) {
        processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
    }
    processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());
    HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentId(deployment.getId());
    assertThat(taskInstanceQuery.count()).isEqualTo(5);
    List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
    assertThat(taskInstances).isNotNull();
    assertThat(taskInstances).hasSize(5);
    taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentId("invalid");
    assertThat(taskInstanceQuery.count()).isEqualTo(0);
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) HistoricTaskInstanceQuery(org.activiti.engine.history.HistoricTaskInstanceQuery) HashSet(java.util.HashSet) Deployment(org.activiti.engine.test.Deployment)

Example 14 with HistoricTaskInstanceQuery

use of org.activiti.engine.history.HistoricTaskInstanceQuery in project Activiti by Activiti.

the class HistoryServiceTest method testHistoricTaskInstanceOrQueryByDeploymentIdIn.

@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceOrQueryByDeploymentIdIn() {
    org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
    HashSet<String> processInstanceIds = new HashSet<String>();
    for (int i = 0; i < 4; i++) {
        processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
    }
    processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());
    List<String> deploymentIds = new ArrayList<String>();
    deploymentIds.add(deployment.getId());
    HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentIdIn(deploymentIds).processDefinitionId("invalid").endOr();
    assertThat(taskInstanceQuery.count()).isEqualTo(5);
    List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
    assertThat(taskInstances).isNotNull();
    assertThat(taskInstances).hasSize(5);
    deploymentIds.add("invalid");
    taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentIdIn(deploymentIds).processDefinitionId("invalid").endOr();
    assertThat(taskInstanceQuery.count()).isEqualTo(5);
    deploymentIds = new ArrayList<String>();
    deploymentIds.add("invalid");
    taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentIdIn(deploymentIds).processDefinitionId("invalid").endOr();
    assertThat(taskInstanceQuery.count()).isEqualTo(0);
    taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().taskDefinitionKey("theTask").deploymentIdIn(deploymentIds).endOr();
    assertThat(taskInstanceQuery.count()).isEqualTo(5);
    taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().taskDefinitionKey("theTask").or().deploymentIdIn(deploymentIds).endOr();
    assertThat(taskInstanceQuery.count()).isEqualTo(0);
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) ArrayList(java.util.ArrayList) HistoricTaskInstanceQuery(org.activiti.engine.history.HistoricTaskInstanceQuery) HashSet(java.util.HashSet) Deployment(org.activiti.engine.test.Deployment)

Example 15 with HistoricTaskInstanceQuery

use of org.activiti.engine.history.HistoricTaskInstanceQuery in project alfresco-repository by Alfresco.

the class ActivitiWorkflowEngine method getAssignedTasks.

/**
 * {@inheritDoc}
 */
public List<WorkflowTask> getAssignedTasks(String authority, WorkflowTaskState state, boolean lazyInitialization) {
    try {
        if (state == WorkflowTaskState.IN_PROGRESS) {
            TaskQuery taskQuery = taskService.createTaskQuery().taskAssignee(authority);
            if (!activitiUtil.isMultiTenantWorkflowDeploymentEnabled()) {
                taskQuery.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain());
            }
            List<Task> tasks = taskQuery.list();
            List<WorkflowTask> resultingTasks = new ArrayList<WorkflowTask>();
            for (Task task : tasks) {
                if (lazyInitialization) {
                    resultingTasks.add(new LazyActivitiWorkflowTask(task, typeConverter, tenantService, typeConverter.getWorkflowDefinitionName(task.getProcessDefinitionId())));
                } else {
                    resultingTasks.add(typeConverter.convert(task));
                }
            }
            return resultingTasks;
        } else {
            HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(authority).finished();
            if (!activitiUtil.isMultiTenantWorkflowDeploymentEnabled()) {
                taskQuery.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain());
            }
            List<HistoricTaskInstance> historicTasks = taskQuery.list();
            List<WorkflowTask> resultingTasks = new ArrayList<WorkflowTask>();
            for (HistoricTaskInstance historicTask : historicTasks) {
                if (lazyInitialization) {
                    resultingTasks.add(new LazyActivitiWorkflowTask(historicTask, typeConverter, tenantService));
                } else {
                    resultingTasks.add(typeConverter.convert(historicTask));
                }
            }
            return resultingTasks;
        }
    } catch (ActivitiException ae) {
        String msg = messageService.getMessage(ERR_GET_ASSIGNED_TASKS);
        if (logger.isDebugEnabled()) {
            logger.debug(msg, ae);
        }
        throw new WorkflowException(msg, ae);
    }
}
Also used : WorkflowTask(org.alfresco.service.cmr.workflow.WorkflowTask) LazyActivitiWorkflowTask(org.alfresco.service.cmr.workflow.LazyActivitiWorkflowTask) Task(org.activiti.engine.task.Task) ActivitiException(org.activiti.engine.ActivitiException) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) LazyActivitiWorkflowTask(org.alfresco.service.cmr.workflow.LazyActivitiWorkflowTask) WorkflowException(org.alfresco.service.cmr.workflow.WorkflowException) ArrayList(java.util.ArrayList) WorkflowTask(org.alfresco.service.cmr.workflow.WorkflowTask) LazyActivitiWorkflowTask(org.alfresco.service.cmr.workflow.LazyActivitiWorkflowTask) HistoricTaskInstanceQuery(org.activiti.engine.history.HistoricTaskInstanceQuery) TaskQuery(org.activiti.engine.task.TaskQuery) WorkflowTaskQuery(org.alfresco.service.cmr.workflow.WorkflowTaskQuery)

Aggregations

HistoricTaskInstanceQuery (org.activiti.engine.history.HistoricTaskInstanceQuery)17 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)14 ArrayList (java.util.ArrayList)7 Deployment (org.activiti.engine.test.Deployment)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 TaskQuery (org.activiti.engine.task.TaskQuery)3 List (java.util.List)2 Map (java.util.Map)2 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)2 HistoryService (org.activiti.engine.HistoryService)2 Task (org.activiti.engine.task.Task)2 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)2 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)2 PermissionDeniedException (org.alfresco.rest.framework.core.exceptions.PermissionDeniedException)2 Paging (org.alfresco.rest.framework.resource.parameters.Paging)2 SortColumn (org.alfresco.rest.framework.resource.parameters.SortColumn)2 Task (org.alfresco.rest.workflow.api.model.Task)2 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)2 WorkflowHistoricTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricTaskInstanceDto)1