public String getActiveProcessImage(String containerId, long procInstId) {
ProcessInstanceDesc instance = dataService.getProcessInstanceById(procInstId);
if (instance == null) {
throw new ProcessInstanceNotFoundException("No instance found for process instance id " + procInstId);
}
String imageSVGString = null;
byte[] imageSVG = getProcessImageAsBytes(instance.getDeploymentId(), instance.getProcessId());
if (imageSVG != null) {
Map<String, String> subProcessLinks = new HashMap<>();
Collection<NodeInstanceDesc> activeLogs = dataService.getProcessInstanceHistoryActive(procInstId, new QueryContext(0, 1000));
Collection<NodeInstanceDesc> completedLogs = dataService.getProcessInstanceHistoryCompleted(procInstId, new QueryContext(0, 1000));
Map<Long, String> active = new HashMap<Long, String>();
List<String> completed = new ArrayList<String>();
for (NodeInstanceDesc activeNode : activeLogs) {
active.put(activeNode.getId(), activeNode.getNodeId());
populateSubProcessLink(containerId, activeNode, subProcessLinks);
}
for (NodeInstanceDesc completeNode : completedLogs) {
completed.add(completeNode.getNodeId());
active.remove(completeNode.getId());
populateSubProcessLink(containerId, completeNode, subProcessLinks);
}
ByteArrayInputStream svgStream = new ByteArrayInputStream(imageSVG);
imageSVGString = SVGImageProcessor.transform(svgStream, completed, new ArrayList<String>(active.values()), subProcessLinks);
return imageSVGString;
}
throw new IllegalArgumentException("No process found for " + instance.getProcessId() + " within container " + containerId);
}