cancel
Showing results for 
Search instead for 
Did you mean: 

Visualization of running process instance

jvanhent
Champ in-the-making
Champ in-the-making
Hi,

I'm new to Activiti, so sorry if this question has been answered/asked before.
Is there a way of visualizing a process instance that is running?

Before claiming a user task, it would help to see 'where' the process currently is, graphically I mean.

Thanks for helping.

John
9 REPLIES 9

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Welcome, great choice to use activiti. I'd suggest to use the webapps a little and you'll soon encounter the functionality you describe. If you want it right before e.g. Claiming a task, you have to develop a custom webapp.

heymjo
Champ on-the-rise
Champ on-the-rise
the probe tool has such functionality where it generates an image and highlights in red the current state of the workflow. It would be great if the RuntimeService had a method like "InputStream generateCurrentStateAsImage(String processInstance)" that returns this image Smiley Happy

jvanhent
Champ in-the-making
Champ in-the-making
the probe tool has such functionality where it generates an image and highlights in red the current state of the workflow. It would be great if the RuntimeService had a method like "InputStream generateCurrentStateAsImage(String processInstance)" that returns this image Smiley Happy

Thanks a lot.
I found it in the actions of probes Active process instances.
This is exactly what I needed.

heymjo
Champ on-the-rise
Champ on-the-rise
so you're saying there is something we can reuse to extract the image ? Can you be more precise where to find the relevant code, very much interested in this as well !

Jorg

frederikherema1
Star Contributor
Star Contributor
see org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator
and org.activiti.rest.api.process.ProcessInstanceDiagramGet for example usage

gant
Champ in-the-making
Champ in-the-making
Hi,

I try to visualize a process as described above. But get the following exception:
Caused by: java.awt.image.RasterFormatException: (x + width) is outside raster
        at sun.awt.image.IntegerInterleavedRaster.createWritableChild(IntegerInterleavedRaster.java:450)
        at java.awt.image.BufferedImage.getSubimage(BufferedImage.java:1156)
        at org.activiti.engine.impl.bpmn.diagram.ProcessDiagramCanvas.generateImage(ProcessDiagramCanvas.java:164)
        at org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator.generateDiagram(ProcessDiagramGenerator.java:220)
        at ch.itartis.taskmanagement.visualization.ProcessVisualizerServiceImpl.generateImage(ProcessVisualizerServiceImpl.java:25)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:69)
        at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:104)
        at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
        at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
        at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:97)
        at org.springframework.binding.expression.spel.SpringELExpression.getValue(SpringELExpression.java:78)
        at org.springframework.webflow.action.EvaluateAction.doExecute(EvaluateAction.java:75)
        at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188)
        at org.springframework.webflow.execution.AnnotatedAction.execute(AnnotatedAction.java:145)
        at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51)

The code to generate is:

public class ProcessVisualizerServiceImpl implements ProcessVisualizerService {

private RuntimeService runtimeService;

private RepositoryService repositoryService;

public InputStream generateImage(String processInstanceId) {

  ExecutionEntity pi = (ExecutionEntity) runtimeService.createProcessInstanceQuery()
    .processInstanceId(processInstanceId).singleResult();

  ProcessDefinitionEntity pde = (ProcessDefinitionEntity) repositoryService.createProcessDefinitionQuery()
    .processDefinitionId(pi.getProcessDefinitionId()).singleResult();

  return (InputStream) ProcessDiagramGenerator.generateDiagram(pde, "png",
    runtimeService.getActiveActivityIds(processInstanceId));

}

The image of the process looks quite normal in Activiti Designer…

Any ideas, what I'm doing wrong?

Regards,

frederikherema1
Star Contributor
Star Contributor

ProcessDefinitionEntity pde = (ProcessDefinitionEntity) repositoryService.createProcessDefinitionQuery()
            .processDefinitionId(pi.getProcessDefinitionId()).singleResult();
The above returns an unitiatialized definition, use this instead (see org.activiti.rest.api.process.ProcessInstanceDiagramGet).


ProcessDefinitionEntity pde = (ProcessDefinitionEntity) ((RepositoryServiceImpl) getRepositoryService())
        .getDeployedProcessDefinition(pi.getProcessDefinitionId());

Not sure this is causing the issue, but you can try…

gant
Champ in-the-making
Champ in-the-making
This no works. Thx.

frederikherema1
Star Contributor
Star Contributor
Do you mean it 'now' works, or 'not' working?