Process diagram highlighting current process

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2013 04:14 AM
Hi,
I am currently a student using Activiti as part of a project. I have noticed from other forum posts that there is definitely a way to show a process diagram that highlights the current process. Activiti Explorer also contains this feature.
Most of the other answers seem to just say "Look at the source code", however due to my inexperience I am struggling to grasp how it works. I was wondering if anyone could point me in the right direction? I am currently using the call:
InputStream image= repo.getProcessDiagram(processInstanceId);
which returns a process diagram, is there any way I can update this so it highlights the current process?
Many thanks
I am currently a student using Activiti as part of a project. I have noticed from other forum posts that there is definitely a way to show a process diagram that highlights the current process. Activiti Explorer also contains this feature.
Most of the other answers seem to just say "Look at the source code", however due to my inexperience I am struggling to grasp how it works. I was wondering if anyone could point me in the right direction? I am currently using the call:
InputStream image= repo.getProcessDiagram(processInstanceId);
which returns a process diagram, is there any way I can update this so it highlights the current process?
Many thanks
Labels:
- Labels:
-
Archive
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2013 05:21 AM
String processInstanceId = (String) getRequest().getAttributes().get("processInstanceId");
if(processInstanceId == null) {
throw new ActivitiIllegalArgumentException("No process instance id provided");
}
ExecutionEntity pi = (ExecutionEntity) ActivitiUtil.getRuntimeService().createProcessInstanceQuery()
.processInstanceId(processInstanceId).singleResult();
if (pi == null) {
throw new ActivitiObjectNotFoundException("Process instance with id" + processInstanceId + " could not be found", ProcessInstance.class);
}
ProcessDefinitionEntity pde = (ProcessDefinitionEntity) ((RepositoryServiceImpl)
ActivitiUtil.getRepositoryService()).getDeployedProcessDefinition(pi.getProcessDefinitionId());
if (pde != null && pde.isGraphicalNotationDefined()) {
BpmnModel bpmnModel = ActivitiUtil.getRepositoryService().getBpmnModel(pde.getId());
InputStream resource = ProcessDiagramGenerator.generateDiagram(bpmnModel, "png", ActivitiUtil.getRuntimeService().getActiveActivityIds(processInstanceId));
InputRepresentation output = new InputRepresentation(resource, MediaType.IMAGE_PNG);
return output;
} else {
throw new ActivitiException("Process instance with id " + processInstanceId + " has no graphic description");
}
Extract from the REST-resource (org.activiti.rest.api.legacy.process.ProcessInstanceDiagramResource). The main idea is that you fetch the model, pass it to the diagram-generator together with the activities that need to be highlighted.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2013 12:34 PM
Hi Frederik,
Thanks for the quick reply. I have been trying to implement this for a few hours. My first point which could be a problem is I don't have the method "getDeployedProcessDefinition" for repository service. I am instead using "getProcessDefinition" which is available to select in my IDE. Could I be using an old version?
The main problem I am is having is that while debugging i noticed that "ExecutionEntity pi" is always null even though the process instanceId is valid. I have a very similar method that just returns the process diagram without highlighting the current process which works fine. I am unsure where I am going wrong here.
Many thanks!
Thanks for the quick reply. I have been trying to implement this for a few hours. My first point which could be a problem is I don't have the method "getDeployedProcessDefinition" for repository service. I am instead using "getProcessDefinition" which is available to select in my IDE. Could I be using an old version?
The main problem I am is having is that while debugging i noticed that "ExecutionEntity pi" is always null even though the process instanceId is valid. I have a very similar method that just returns the process diagram without highlighting the current process which works fine. I am unsure where I am going wrong here.
Many thanks!
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2013 07:54 AM
- Correct. You need to cast to (RepositoryServiceImpl) to get that method.
- It could very well be a case of lazy loading. It could be you need to explicitely fetch the data or execute the code within a custom command in Activiti.
- It could very well be a case of lazy loading. It could be you need to explicitely fetch the data or execute the code within a custom command in Activiti.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2016 04:17 PM
Hi
I have read through many forms. please clarify the below query. I am practicing activiti workflow mgnt. Both the wars activiti rest and activiti explorer deployed in jboss pointing to same port of H2 DB. i trying to fetch the records via activiti rest for the vacation request task (demo process) created via activiti explorer. I am able to retrieve the process without any issues.
http://localhost:8080/activiti-rest/service/query/process-instances - POST
request
——–
{
"processDefinitionKey":"vacationRequest",
"variables": [
{
"name": "employeeName",
"type": "string",
"value": "kermit",
"operation" : "equals"
}
]
}
response
——–
{
"data": [
{
"id": "4143",
"url": "http://localhost:8080/activiti-rest/service/runtime/process-instances/4143",
"businessKey": null,
"suspended": false,
"ended": false,
"processDefinitionId": "vacationRequest:1:31",
"processDefinitionUrl": "http://localhost:8080/activiti-rest/service/repository/process-definitions/vacationRequest:1:31",
"activityId": "handleRequest",
"variables": [],
"tenantId": "",
"completed": false
}
],
"total": 1,
"start": 0,
"sort": "id",
"order": "asc",
"size": 1
}.
When i tried to generate the Process diagram highlighting current process using below api.
http://localhost:8080/activiti-rest/service/runtime/process-instances/4143/diagram
{
"message": "Bad request",
"exception": "Process instance with id '4143' has no graphical notation defined."
}
When i analyse the sample code, will get the exception when pde.isGraphicalNotationDefined() returns false.
if (pde != null && pde.isGraphicalNotationDefined()) {
..
}else {
throw new ActivitiException("Process instance with id " + processInstanceId + " has no graphic description");
}
Not sure how and where to set this variable to true in order to retrieve the Process diagram highlighting current process
Thanks in advance.
-
Pravin
I have read through many forms. please clarify the below query. I am practicing activiti workflow mgnt. Both the wars activiti rest and activiti explorer deployed in jboss pointing to same port of H2 DB. i trying to fetch the records via activiti rest for the vacation request task (demo process) created via activiti explorer. I am able to retrieve the process without any issues.
http://localhost:8080/activiti-rest/service/query/process-instances - POST
request
——–
{
"processDefinitionKey":"vacationRequest",
"variables": [
{
"name": "employeeName",
"type": "string",
"value": "kermit",
"operation" : "equals"
}
]
}
response
——–
{
"data": [
{
"id": "4143",
"url": "http://localhost:8080/activiti-rest/service/runtime/process-instances/4143",
"businessKey": null,
"suspended": false,
"ended": false,
"processDefinitionId": "vacationRequest:1:31",
"processDefinitionUrl": "http://localhost:8080/activiti-rest/service/repository/process-definitions/vacationRequest:1:31",
"activityId": "handleRequest",
"variables": [],
"tenantId": "",
"completed": false
}
],
"total": 1,
"start": 0,
"sort": "id",
"order": "asc",
"size": 1
}.
When i tried to generate the Process diagram highlighting current process using below api.
http://localhost:8080/activiti-rest/service/runtime/process-instances/4143/diagram
{
"message": "Bad request",
"exception": "Process instance with id '4143' has no graphical notation defined."
}
When i analyse the sample code, will get the exception when pde.isGraphicalNotationDefined() returns false.
if (pde != null && pde.isGraphicalNotationDefined()) {
..
}else {
throw new ActivitiException("Process instance with id " + processInstanceId + " has no graphic description");
}
Not sure how and where to set this variable to true in order to retrieve the Process diagram highlighting current process
Thanks in advance.
-
Pravin
