Displaying all activities and subprocesses can be done by using the BPMNModel class and it's children. Take a look at the activiti-bpmn-model and activiti-bpmn-converter projects, which allow you to read/write POJO-representations of your process definition. Also, when you deployed the process-definition, you can access the BPMNModel using the repositoryService.getModel(…). Your UI can display all user-tasks, subprocesses, …
For the runtime-selection of assignments, there are 2 approached I can suggest:
1) When your UI has selected all needed users (reviewers, approvers, assignees …) and stored somewhere (e.g. database), you fill a hashmap with those values. Single assignees are just stored as a string in the map, multiple assignees are stored as an arraylist (or any other serializable List) of strings. When you start the process instance using our API, pass in that map of variables. In your process bpmn, you can use expressions in the assignment-fields and in the multi-instance parameters (e.g. activiti:assigne="${manager}"). When the process reaches a task, the expressions will be resolved and the assignment will be done, based on the values you put in the variable-map when the process started.
2) Your UI selects all needed assignees, and stores this in a database. Create a Java service that exposes methods that are capable of fetching these values for each of the required assignee/assignees. Next, wire in that service into the processEngineConfiguration beans (see userguide, Beans section), e.g. called "assignmentService". When starting a process-instance that needs this kind of behaviour, make sure you add a variable that references the set of assignees you want to use that references the set in your DB (e.g. assignmentSetId). In the process bpmn, you use expressions again to resolve the right assignee: activiti:assignee="${assignmentService.getManagerAssignee(assignmentSetId)}". The expression manager will call the assignmentService's getManagerAssignee method, passing in the process variable value for "assignmentSetId".
The differences between the first approach and the second approach:
- The first approach will get all assignees at the start of the process from your DB. Once the process is running, these values are carved in stone, regardless of the values in YOUR DB (unless you do a setVariable(..) call when the process is running). As opposed to the second approach, which will fetch the values from your DB when they are needed.
- The first approach duplicates the data of the assignment in variables, while the 2nd approach only stores a reference, resulting in less DB and memory usage.
I hope this helps…