JBoss Community

Re: [Jbpm5]how to get the image showing the current status of a workflow in the web application

created by xiaoxiao long in jBPM - View the full discussion

thank you,but I use the bpmn file ,in JBPM4.4 it is simple to achieve this function:

 

<%@page import="org.jbpm.api.*,java.io.*"%>
<%
ProcessEngine processEngine = Configuration.getProcessEngine();
RepositoryService repositoryService = processEngine
   .getRepositoryService();
ExecutionService executionService = processEngine
   .getExecutionService();
String id = request.getParameter("id");
ProcessInstance processInstance = executionService
   .findProcessInstanceById(id);
String processDefinitionId = processInstance
   .getProcessDefinitionId();
ProcessDefinition processDefinition = repositoryService
   .createProcessDefinitionQuery().processDefinitionId(
     processDefinitionId).uniqueResult();
InputStream inputStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(),"loan.png");
byte[] b = new byte[1024];
int len = -1;
while ((len = inputStream.read(b, 0, 1024)) != -1) {
  response.getOutputStream().write(b, 0, len);
}
%>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="org.jbpm.api.*,java.util.*,org.jbpm.api.model.*" %>
<%
String id = request.getParameter("id");
ProcessEngine processEngine = Configuration.getProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
ExecutionService executionService = processEngine.getExecutionService();
ProcessInstance processInstance = executionService.findProcessInstanceById(id);
Set<String> activityNames = processInstance.findActiveActivityNames();

ActivityCoordinates ac = repositoryService.getActivityCoordinates(processInstance.getProcessDefinitionId(),activityNames.iterator().next());
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<img src="loan.png" style="position:absolute;left:0px;top:0px;">
<div style="position:absolute;border:1px solid red;left:<%=ac.getX()%>px;top:<%=ac.getY()%>px;width:<%=ac.getWidth()%>px;height:<%=ac.getHeight()%>px;"></div>
</body>
</html>



Reply to this message by going to Community

Start a new discussion in jBPM at Community