Hi everyone,
I will explain what I want. I want to get a User Task of a BpmnModel and set a list of CandidateGroups using
userTask.setCandidateGroups(candidateGroupList);
This works fine, because in the flowable tasks, the tasks appear to the candidate groups, but the problem occurs when server will be restarted, in other words, this information is not persisted. So … I am doubting if my code is okey or not.
The summary is that I want to manipulate the properties of the user tasks defined on the “Modeler” App of Flowable via Java
...
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
// Get the process
ProcessDefinitionQuery query = processEngine.getRepositoryService()
.createProcessDefinitionQuery().latestVersion();
List<ProcessDefinition> processDefinitions = query
.processDefinitionKey("example").list();
// Get the tasks
if (processDefinitions.size() != 0) {
BpmnModel bpmModel = repositoryService.getBpmnModel(processDefinitions.get(0).getId());
List<UserTask> userTaskList = bpmModel.getMainProcess()
.findFlowElementsOfType(UserTask.class);
for (UserTask userTask : userTaskList) {
List<String> candidateUserList = userTask.getCandidateGroups();
if (observerApproval.getRole() != null) {
List<String> candidateGroupList = userTask.getCandidateGroups();
if (!candidateGroupList.contains(observerApproval.getRole().getId()))
candidateGroupList.add(observerApproval.getRole().getId());
userTask.setCandidateGroups(candidateGroupList);
}
...
Thanks a lot!