11-27-2017 02:54 AM
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?
11-27-2017 07:43 AM
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.
11-27-2017 03:37 AM
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.
11-27-2017 03:49 AM
I am using 5.17.0
11-27-2017 03:54 AM
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?
11-27-2017 04:04 AM
ya.. but how can i display it?
11-27-2017 07:43 AM
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.
11-29-2017 02:44 AM
In my execution, repositoryService not have method like getDeployedProcessDefinition
How can i resolve it?
11-29-2017 03:40 AM
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.
11-29-2017 03:44 AM
Ya. those are not an issue. It is showing error at RepositoryServiceImpl. How can i import that file?
11-29-2017 03:47 AM
Explore our Alfresco products with the links below. Use labels to filter content by product module.