I like to know how to get the process definition diagram and process instance diagram via JAVA API.
I tried getProcessDiagram in RepositoryService, but I got null. The doc says ‘null when the diagram resource name of a ProcessDefinition is null’, but what diagram resource name is? Where I can config the value for it?
I just wanted to display a diagram on the web page, then user can understand the process and current progress. No interaction is needed at this moment.
I also noticed that REST API can get the BPMN xml file and display it via bpmn.io with fully interaction features. But can I use JAVA API instead?
Yes, that is the way to go. In the bpmn-io context, bpmn-js is the library to look at.
You can use RepositoryService#getProcessModel. In general, every REST API method is backed by a Java API method.
There is no single API endpoint for that but you can render the XML returned by RepositoryService#getProcessModel and display process instance state returned by RuntimeService#getActivityInstance by using overlays on the process diagram. That is the way how we do this in Camunda Cockpit. If you have any questions on how to create overlays with bpmn-js, I recommend asking that on the bpmn-io forums