Hi,
I am using activiti in my spring web application. I would like to show to the end user, where current status of process in process. Is any other way to show like this?
Solved! Go to Solution.
You can generating diagram for process or diagram por instance in process, in my case I have a test unit to generate a image of instance process diagram:
@Test
@Deployment(resources = {"org/activiti/test/BoundaryTimerTest.bpmn20.xml"})
public void testGetProcessInstanceDiagram() throws IOException {
logger.info("Test of instance diagram process...");
RuntimeService runtimeService = activitiRule.getRuntimeService();
RepositoryService repositoryService = activitiRule.getRepositoryService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("BoundaryTimerTest");
assertNotNull(processInstance);
String processInstanceId = processInstance.getId();
logger.info("Process Id = " + processInstanceId);
ExecutionEntity pi = (ExecutionEntity) runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
ProcessDefinitionEntity pde = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(pi.getProcessDefinitionId());
if (pde != null && pde.isGraphicalNotationDefined()) {
BpmnModel bpmnModel = repositoryService.getBpmnModel(pde.getId());
ProcessDiagramGenerator processDiagramGenerator = new DefaultProcessDiagramGenerator();
InputStream is = processDiagramGenerator.generateDiagram(bpmnModel, "png", runtimeService.getActiveActivityIds(processInstanceId));
byte[] buffer = new byte[is.available()];
is.read(buffer);
File imageFile = new File("D:/diagram-" + processInstanceId + ".png");
FileOutputStream fileOutputStream = new FileOutputStream(imageFile);
fileOutputStream.write(buffer);
fileOutputStream.close();
}
assertNotNull(processInstance.getProcessInstanceId());
}
You can need this dependency:
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-image-generator</artifactId>
<version>5.16.1</version>
</dependency>
Regards.
Hi there, which version of Activiti are you using? without that is very difficult to help you. This is a very common requirement, so it is definitely possible, but you need to find what is the best way based on which version are you using.
I am using 5.17.0
I'm sure that there is a way in 5.22 but not sure if that was present in 5.17, is there any chance for you to upgrade to 5.22?
ya.. but how can i display it?
You can generating diagram for process or diagram por instance in process, in my case I have a test unit to generate a image of instance process diagram:
@Test
@Deployment(resources = {"org/activiti/test/BoundaryTimerTest.bpmn20.xml"})
public void testGetProcessInstanceDiagram() throws IOException {
logger.info("Test of instance diagram process...");
RuntimeService runtimeService = activitiRule.getRuntimeService();
RepositoryService repositoryService = activitiRule.getRepositoryService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("BoundaryTimerTest");
assertNotNull(processInstance);
String processInstanceId = processInstance.getId();
logger.info("Process Id = " + processInstanceId);
ExecutionEntity pi = (ExecutionEntity) runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
ProcessDefinitionEntity pde = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(pi.getProcessDefinitionId());
if (pde != null && pde.isGraphicalNotationDefined()) {
BpmnModel bpmnModel = repositoryService.getBpmnModel(pde.getId());
ProcessDiagramGenerator processDiagramGenerator = new DefaultProcessDiagramGenerator();
InputStream is = processDiagramGenerator.generateDiagram(bpmnModel, "png", runtimeService.getActiveActivityIds(processInstanceId));
byte[] buffer = new byte[is.available()];
is.read(buffer);
File imageFile = new File("D:/diagram-" + processInstanceId + ".png");
FileOutputStream fileOutputStream = new FileOutputStream(imageFile);
fileOutputStream.write(buffer);
fileOutputStream.close();
}
assertNotNull(processInstance.getProcessInstanceId());
}
You can need this dependency:
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-image-generator</artifactId>
<version>5.16.1</version>
</dependency>
Regards.
In my execution, repositoryService not have method like getDeployedProcessDefinition
How can i resolve it?
Hi!
How has initialize your getFormService(), getRepository() and getRuntime()?
In my case I create a ActivitiRule, for example:
@Rule
public ActivitiRule activitiRule = new ActivitiRule();
And now in my method testListFields():
RuntimeService runtimeService = activitiRule.getRuntimeService();
RepositoryService repositoryService = activitiRule.getRepositoryService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("BoundaryTimerTest");
Regards.
Ya. those are not an issue. It is showing error at RepositoryServiceImpl. How can i import that file?
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.