cancel
Showing results for 
Search instead for 
Did you mean: 

The way that the diagram-viewer deal with processIntance which finished itself.

jin1
Champ in-the-making
Champ in-the-making
When I integrate with the  diagram-viewer to tracing the flow going,there is a demand that user want to know how the process finished,especially when the task can cause the end event by "rejected" or "approved" with a Exclusive Gateway(For example).
But the diagram-viewer can not deal with the finished process instance,because the
ProcessInstanceHighlightsResource
class (ps: in the
org.activiti.rest.diagram.services
package.) has that code snippet:

ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
         ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId());

the above code will throw out a
NullPointException
because the
processInstance = null
.
I extended it by add this

if (processInstance == null) {
            HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
                  .processInstanceId(processInstanceId).singleResult();
            ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService
                  .getProcessDefinition(historicProcessInstance.getProcessDefinitionId());

            responseJSON.put("processDefinitionId", historicProcessInstance.getProcessDefinitionId());
            
            highLightedActivities = Collections.emptyList();
            highLightedFlows = getHighLightedFlows(processDefinition, processInstanceId);
         } else {//TODO
}

now,we can get the red-wat sequence flow.
But there is still a puzzle , whether this extension broken The Design Concept?
Is process tracking only occurring at run time?
1 REPLY 1

jbarrez
Star Contributor
Star Contributor
>  whether this extension broken The Design Concept?

Not 100% sure what you mean, but I think this was not done on purpose.
Feel free to create a PR with your fixes.