cancel
Showing results for 
Search instead for 
Did you mean: 

API to fetch the diagram for Process Instance

mittalabhi86
Champ in-the-making
Champ in-the-making
Hi,

I know I can use
ProcessDiagramGenerator.generateDiagram(BPMNMpdel, ImageType, Activities)
to get the pictorial view of a process instance at any given time. This image indicates the tasks currently in process by outlining them in red. What I want is, how can I get an image which will indicate that the process has completed and all the tasks have finished successfully.

Please suggest if that is possible.

Regards
Abhishek
11 REPLIES 11

jbarrez
Star Contributor
Star Contributor
That isn't in Activiti at the moment. The logic of ProcessDiagramGenerator could be enhanced to show past tasks though.

mittalabhi86
Champ in-the-making
Champ in-the-making
Thanks for your prompt response.

Yes. I feel, this would be a good to have functionality. Showing the status of all the processing & processed activities should be the part of pictorial view of a process instance at any spur of moment. I remember I have worked on a similar tool which used to show diagram in following manner:
<blockcode>
1. For all the pending tasks, background was default.
2. For all the currently running tasks, bg gets turned to yellow.
3. For all successfully completed tasks, bg gets turned to green.
4. For all the tasks ended in error, were turned to red.
</blockcode>
Something on this line shall be very useful. Please suggest, are we already planning to have this functionality in near future?

Regards
Abhishek

jbarrez
Star Contributor
Star Contributor
No, that's not on our roadmap currently (but the cheesy answer would be we welcome any code contribution 😉 )

saig0
Champ in-the-making
Champ in-the-making
Hi Abhishek!

You can use <java>ProcessDiagramGenerator.generateDiagram(bpmnModel, imageType, activityIds, flowIds)</java> to generate an image that shows the current activities and the passed flows / transitions.

Regards,
Philipp

mittalabhi86
Champ in-the-making
Champ in-the-making
Thanks Philipp. Will try that!

Regards
Abhishek

mittalabhi86
Champ in-the-making
Champ in-the-making
Hi Philipp,

Is the ids of incoming transition to the current activity, or is the ids of all the possible transitions?

Regards
Abhishek

saig0
Champ in-the-making
Champ in-the-making
Hi Abhishek,

you assign the ids of all transitions you want to mark on the generated image. If you want to show an image with the current state and the executed path then you have to resolve all passed transitions and assign to the method.
For example:
<java>
        List<String> activeAtivityIds = runtimeService.getActiveActivityIds(processInstanceId);
        List<String> activeAndHistorcActivityIds = // resolve active and historic activitities
       
        List<String> flows =  new LinkedList<String>();
        for (Process process : bpmnModel.getProcesses())  {
            for (FlowElement flowElement : process.getFlowElements()) {
                if (flowElement instanceof SequenceFlow) {
                    SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
                    String from = sequenceFlow.getSourceRef();
                    String to = sequenceFlow.getTargetRef();
                    if (activeAndHistorcActivityIds .contains(from) &&
                                activeAndHistorcActivityIds .contains(to)) {
                        flows.add(sequenceFlow.getId());
                    }
                }
            }

        InputStream in = ProcessDiagramGenerator.generateDiagram(bpmnModel, "png", activeAtivityIds, flows);
</java>

Regards,
Philipp

mittalabhi86
Champ in-the-making
Champ in-the-making
Thanks Philipp!
In the meanwhile after sending you the query, I figured that out. Anyways, are we planning to integrate this feature in api itself to track the activities & flows completed, while preparing the diagram?

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

Process diagram (as a static model) does not cover loops, multiinstances… . I would prefer audit trail.
http://forums.activiti.org/content/audit-trail-diagram

Regards
Martin