Hello. I need help. I have a lot of started processes. And in every process i have several tasks like this:
…
<userTask id="submit" name="Submit vacation request" …>
<extensionElements>
…
<activiti:formProperty id="actions" name="actions" type="enum" variable="action" required="true">
<activiti:value id="submit" name="Submit request"></activiti:value>
<activiti:value id="update" name="Update request"></activiti:value>
<activiti:value id="delete" name="Delete request"></activiti:value>
</activiti:formProperty>
…
I need to get all values of formProperty "actions" for every task where some user is assignee or candidate for several processes (maximum 50)
I need something like
process_instance_id1 :
-task1:
-value1 (of formProperty with id = 'actions')
-value2
-task2:
-value1
…
process_instance_id2 :
-task1:
-value1
-value2
-task2:
-value1
…
For input i have only ids of processes.
I know that for one process I can do this:
List<Task> tasks = createTaskQueryForAssigneeOrCandidate(userId, processInstanceId).list();
for (Task task: tasks) {
List<FormProperty> formProperties = formService.getTaskFormData(task.getId()).getFormProperties();
….
private NativeTaskQuery createTaskQueryForAssigneeOrCandidate(final String userId, final String processInstanceId) {
final StringBuilder query = new StringBuilder();
query.append("SELECT * FROM ( SELECT DISTINCT ON (TASK.name_) * FROM ");
query.append(managementService.getTableName(Task.class));
query.append(" TASK left join ");
query.append(managementService.getTableName(IdentityLinkEntity.class));
query.append(" IDENTITY_LINK on IDENTITY_LINK.TASK_ID_ = TASK.ID_");
query.append(" WHERE (TASK.ASSIGNEE_ = #{userName} OR (IDENTITY_LINK.TYPE_ = 'candidate' and IDENTITY_LINK.USER_ID_ = # {userName})) ");
query.append("AND TASK.proc_inst_id_ = #{processInstanceId}) result ORDER BY result.priority_ DESC");
final NativeTaskQuery taskQuery = taskService.createNativeTaskQuery();
taskQuery.sql(query.toString());
taskQuery.parameter(USER_PARAMETER_NAME, userId);
taskQuery.parameter("processInstanceId", processInstanceId);
return taskQuery;
}