Java Code Examples for org.activiti.engine.task.TaskQuery#processVariableValueEquals()
The following examples show how to use
org.activiti.engine.task.TaskQuery#processVariableValueEquals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskAndVariablesQueryTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testOrQueryMultipleVariableValues() { Map<String, Object> startMap = new HashMap<String, Object>(); startMap.put("aProcessVar", 1); startMap.put("anotherProcessVar", 123); runtimeService.startProcessInstanceByKey("oneTaskProcess", startMap); TaskQuery query0 = taskService.createTaskQuery().includeProcessVariables().or(); for (int i = 0; i < 20; i++) { query0 = query0.processVariableValueEquals("anotherProcessVar", i); } query0 = query0.endOr(); assertNull(query0.singleResult()); TaskQuery query1 = taskService.createTaskQuery().includeProcessVariables().or().processVariableValueEquals("anotherProcessVar", 123); for (int i = 0; i < 20; i++) { query1 = query1.processVariableValueEquals("anotherProcessVar", i); } query1 = query1.endOr(); Task task = query1.singleResult(); assertEquals(2, task.getProcessVariables().size()); assertEquals(123, task.getProcessVariables().get("anotherProcessVar")); }
Example 2
Source File: ActivitiWorkflowEngine.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private void addTasksForCandidateGroups(List<String> groupNames, Map<String, Task> resultingTasks) { if(groupNames != null && groupNames.size() > 0) { TaskQuery query = taskService.createTaskQuery().taskCandidateGroupIn(groupNames); // Additional filtering on the tenant-property in case workflow-definitions are shared across tenants if(!activitiUtil.isMultiTenantWorkflowDeploymentEnabled() && tenantService.isEnabled()) { query.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain()); } List<Task> tasks =query.list(); for(Task task : tasks) { resultingTasks.put(task.getId(), task); } } }
Example 3
Source File: ActivitiWorkflowEngine.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private void addProcessPropertiesToQuery( Map<QName, Object> processCustomProps, TaskQuery taskQuery) { for(Entry<QName, Object> customProperty : processCustomProps.entrySet()) { String name =factory.mapQNameToName(customProperty.getKey()); // Exclude the special "VAR_TENANT_DOMAIN" variable, this cannot be queried by users if(name != ActivitiConstants.VAR_TENANT_DOMAIN) { // Perform minimal property conversions Object converted = propertyConverter.convertPropertyToValue(customProperty.getValue()); taskQuery.processVariableValueEquals(name, converted); } } }
Example 4
Source File: ActivitiUtil.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public Task getTaskInstance(String taskId) { TaskQuery taskQuery = taskService.createTaskQuery().taskId(taskId); if(!deployWorkflowsInTenant) { taskQuery.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain()); } return taskQuery.singleResult(); }
Example 5
Source File: ActivitiWorkflowEngine.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private void addTasksForCandidateUser(String userName, Map<String, Task> resultingTasks) { TaskQuery query = taskService.createTaskQuery().taskCandidateUser(userName); // Additional filtering on the tenant-property in case workflow-definitions are shared across tenants if(!activitiUtil.isMultiTenantWorkflowDeploymentEnabled() && tenantService.isEnabled()) { query.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain()); } List<Task> tasks = query.list(); for(Task task : tasks) { resultingTasks.put(task.getId(), task); } }
Example 6
Source File: TaskBaseResource.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
protected void addProcessvariables(TaskQuery taskQuery, List<QueryVariable> variables) { for (QueryVariable variable : variables) { if (variable.getVariableOperation() == null) { throw new ActivitiIllegalArgumentException("Variable operation is missing for variable: " + variable.getName()); } if (variable.getValue() == null) { throw new ActivitiIllegalArgumentException("Variable value is missing for variable: " + variable.getName()); } boolean nameLess = variable.getName() == null; Object actualValue = restResponseFactory.getVariableValue(variable); // A value-only query is only possible using equals-operator if (nameLess && variable.getVariableOperation() != QueryVariableOperation.EQUALS) { throw new ActivitiIllegalArgumentException("Value-only query (without a variable-name) is only supported when using 'equals' operation."); } switch (variable.getVariableOperation()) { case EQUALS: if (nameLess) { taskQuery.processVariableValueEquals(actualValue); } else { taskQuery.processVariableValueEquals(variable.getName(), actualValue); } break; case EQUALS_IGNORE_CASE: if (actualValue instanceof String) { taskQuery.processVariableValueEqualsIgnoreCase(variable.getName(), (String) actualValue); } else { throw new ActivitiIllegalArgumentException("Only string variable values are supported when ignoring casing, but was: " + actualValue.getClass().getName()); } break; case NOT_EQUALS: taskQuery.processVariableValueNotEquals(variable.getName(), actualValue); break; case NOT_EQUALS_IGNORE_CASE: if (actualValue instanceof String) { taskQuery.processVariableValueNotEqualsIgnoreCase(variable.getName(), (String) actualValue); } else { throw new ActivitiIllegalArgumentException("Only string variable values are supported when ignoring casing, but was: " + actualValue.getClass().getName()); } break; case GREATER_THAN: taskQuery.processVariableValueGreaterThan(variable.getName(), actualValue); break; case GREATER_THAN_OR_EQUALS: taskQuery.processVariableValueGreaterThanOrEqual(variable.getName(), actualValue); break; case LESS_THAN: taskQuery.processVariableValueLessThan(variable.getName(), actualValue); break; case LESS_THAN_OR_EQUALS: taskQuery.processVariableValueLessThanOrEqual(variable.getName(), actualValue); break; case LIKE: if (actualValue instanceof String) { taskQuery.processVariableValueLike(variable.getName(), (String) actualValue); } else { throw new ActivitiIllegalArgumentException("Only string variable values are supported using like, but was: " + actualValue.getClass().getName()); } break; default: throw new ActivitiIllegalArgumentException("Unsupported variable query operation: " + variable.getVariableOperation()); } } }
Example 7
Source File: TasksImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
/** * Get a valid {@link org.activiti.engine.task.Task} based on the given task id. Checks if current logged * in user is assignee/owner/involved with the task. In case true was passed for "validIfClaimable", * the task is also valid if the current logged in user is a candidate for claiming the task. * * @throws EntityNotFoundException when the task was not found * @throws PermissionDeniedException when the current logged in user isn't allowed to access task. */ protected org.activiti.engine.task.Task getValidTask(String taskId) { if (taskId == null) { throw new InvalidArgumentException("Task id is required."); } TaskQuery query = activitiProcessEngine.getTaskService() .createTaskQuery() .taskId(taskId); if (authorityService.isAdminAuthority(AuthenticationUtil.getRunAsUser())) { // Admin is allowed to read all tasks in the current tenant if (tenantService.isEnabled()) { query.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain()); } } else { // If non-admin user, involvement in the task is required (either owner, assignee or externally involved). query.taskInvolvedUser(AuthenticationUtil.getRunAsUser()); } org.activiti.engine.task.Task taskInstance = query.singleResult(); if (taskInstance == null) { // Either the task doesn't exist or the user is not involved directly. We can differentiate by // checking if the task exists without applying the additional filtering taskInstance = activitiProcessEngine.getTaskService() .createTaskQuery() .taskId(taskId) .singleResult(); if (taskInstance == null) { // Full error message will be "Task with id: 'id' was not found" throw new EntityNotFoundException(taskId); } else { // Task is not yet finished, so potentially claimable. If user is part of a "candidateGroup", the task is accessible to the // user regardless of not being involved/owner/assignee boolean isTaskClaimable = activitiProcessEngine.getTaskService() .createTaskQuery() .taskCandidateGroupIn(new ArrayList<String>(authorityService.getAuthoritiesForUser(AuthenticationUtil.getRunAsUser()))) .taskId(taskId) .count() == 1; if (isTaskClaimable == false) { throw new PermissionDeniedException(); } } } return taskInstance; }