Easy way to visualize a process instance history?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2013 06:00 AM
I would like to draw the diagram of a process instance with the history highlighted. My ideal would be to highlight past activities and flows in one color, and current activities in another colors, but just being able to highlight the whole path "from start event to current state" would already be great.
I imagine that I should use
ProcessDiagramGenerator.generateDiagram(processDefinitionEntity, "png", highLightedActivities, highLightedFlows)
-> for the historical activities, I use
historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).finished().list();
-> for the current activities , I use : runtimeService.getActiveActivityIds(processInstanceId);
-> but I have no idea on how to find the flows that I should get highlighted (I have several flows that end up to the same task so it is not absolutely obvious from the highlighted tasks which path led to them…)Any idea?
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2013 07:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2013 05:58 AM
Declare variables for passing thru methods
private List<String> historicActivityInstanceList = new ArrayList<String>();
private List<String> highLightedFlows = new ArrayList<String>();
What you need here is processDefinition and processInstanceId
…
List<String> highLightedFlows = getHighLightedFlows(processDefinition, processInstanceId);
…
And here you need in activiti-services
private List<String> getHighLightedFlows(ProcessDefinitionEntity processDefinition,
String processInstanceId) {
List<HistoricActivityInstance> historicActivityInstances = historyService.
createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).
orderByHistoricActivityInstanceStartTime().asc().list();
for (HistoricActivityInstance hai : historicActivityInstances) {
historicActivityInstanceList.add(hai.getActivityId());
}
// add current activities to list
List<String> highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId);
historicActivityInstanceList.addAll(highLightedActivities);
// activities and their sequence-flows
getHighLightedFlows(processDefinition.getActivities());
return highLightedFlows;
}
private void getHighLightedFlows (List<ActivityImpl> activityList) {
for (ActivityImpl activity : activityList) {
if (activity.getProperty("type").equals("subProcess")) {
// get flows for the subProcess
getHighLightedFlows(activity.getActivities());
}
if (historicActivityInstanceList.contains(activity.getId())) {
List<PvmTransition> pvmTransitionList = activity.getOutgoingTransitions();
for (PvmTransition pvmTransition: pvmTransitionList) {
String destinationFlowId = pvmTransition.getDestination().getId();
if (historicActivityInstanceList.contains(destinationFlowId)) {
highLightedFlows.add(pvmTransition.getId());
}
}
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2013 03:44 AM
They seem to mean I do have to recompute the flows from the activities, which is not what I intended to do as there are several paths that lead to the same activity… Perhaps I'd better place execution listeners on the sequenceFlows so as to register each flow taken…
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2013 04:33 AM
to register each flow taken…Do you want to register and then store it on runtime? Or do you want to create additional table to store registered sequence flows?
Without that table it looks like storing in memory on runtime. And what about completed(ended) process instances?
The really easy way to visualize it is to parse outgoing transitions of the activities I think.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2013 05:16 AM
Ok, it might sound obvious that I should look at the times of execution too, but with a complicated process that has tasks taking place in parallel and so on, it can become quite complicated.
That's why I wondered if there was a history of the sequenceFlows the same way as there is a history of executions. And if there's not, my idea to use listeners actually was to populate a custom history table for flows…

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2014 10:08 PM
Regards!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2014 02:46 AM
Here is one example how to do it :
- 5.11 -> Audit trail diagram
- 5.15-SNAPSHOT -> jUnit test with SVG generator
Regards
Martin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2016 06:20 PM
The latest activiti-crystalball maven build does not have the same code as the 5.15-SNAPSHOT JUnit link. Do you know where it got moved to now that we are in the 5.19.x version? Did it go to a different maven artifact/jar?
Jason

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2014 10:50 PM
ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processInstance
.getProcessDefinitionId());
and the repositoryService query processDefinition will return empty tasks.
Regards!
