cancel
Showing results for 
Search instead for 
Did you mean: 

UserTask names

mitziuro
Champ in-the-making
Champ in-the-making
Is there a way to list all userTask nodes (the definition: id, name) within a process definition (with activiti service classes).
I am currently using a parser to parse the xml with the process definition.

BR
4 REPLIES 4

rsoika
Champ in-the-making
Champ in-the-making
I have a similar problem.
Which parser did you use to parse your file? Did you have written your own parsing process?

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
just read it as string/bytearray and convert it to a w3c dom…  Nothing special

frederikherema1
Star Contributor
Star Contributor
You can always use the RepositoryServiceImpl.getDeployedProcessDefinition() and recessively inspect all activities (following sequence flows) in your code, starting from the initial Ativity. Getting out all user-tasks this way is possible.

mitziuro
Champ in-the-making
Champ in-the-making
The answer:


/* Get the usertasks */
UserTaskActivityBehavior utab = null;
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("process1").latestVersion().singleResult();
ReadOnlyProcessDefinition procDef = ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinition.getId());
  
for(PvmActivity activity : procDef.getActivities()) {
    if(((ActivityImpl)activity).getActivityBehavior() instanceof UserTaskActivityBehavior) {
        utab = (UserTaskActivityBehavior) ((ActivityImpl)activity).getActivityBehavior();
        utab.getTaskDefinition().getNameExpression().getExpressionText(); //name
        utab.getTaskDefinition().getKey(); //id  
    }
  
}