本文整理汇总了Java中org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator类的典型用法代码示例。如果您正苦于以下问题:Java ProcessDiagramGenerator类的具体用法?Java ProcessDiagramGenerator怎么用?Java ProcessDiagramGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProcessDiagramGenerator类属于org.activiti.engine.impl.bpmn.diagram包,在下文中一共展示了ProcessDiagramGenerator类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tracePhoto
import org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator; //导入依赖的package包/类
/**
* 读取带跟踪的图片
* @param executionId 环节ID
* @return 封装了各种节点信息
*/
public InputStream tracePhoto(String processDefinitionId, String executionId) {
// ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(executionId).singleResult();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
List<String> activeActivityIds = Lists.newArrayList();
if (runtimeService.createExecutionQuery().executionId(executionId).count() > 0){
activeActivityIds = runtimeService.getActiveActivityIds(executionId);
}
// 不使用spring请使用下面的两行代码
// ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl)ProcessEngines.getDefaultProcessEngine();
// Context.setProcessEngineConfiguration(defaultProcessEngine.getProcessEngineConfiguration());
// 使用spring注入引擎请使用下面的这行代码
Context.setProcessEngineConfiguration(processEngine.getProcessEngineConfiguration());
return ProcessDiagramGenerator.generateDiagram(bpmnModel, "png", activeActivityIds);
}
示例2: testBuildWF
import org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator; //导入依赖的package包/类
@Test
public void testBuildWF() throws IOException {
List<Approval> approvals = Lists.newArrayList();
Approval approval = new Approval();
approval.getCandidateGroups().add("engineering");
approvals.add(approval);
Approval approval2 = new Approval();
approval2.getCandidateUsers().add("kermit");
approvals.add(approval2);
BpmnModel model = workflowBldr.documentApprove(approvals, "engineering");
InputStream in = ProcessDiagramGenerator.generatePngDiagram(model);
FileUtils.copyInputStreamToFile(in, new File("target/some_group_diagram.png"));
IOUtils.closeQuietly(in);
}
示例3: viewPic
import org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator; //导入依赖的package包/类
/**
* 显示图片
* @return
*/
@RequestMapping(value = "/viewPic.do")
public void viewPic(HttpServletRequest request,
HttpServletResponse response,
@RequestParam("executionId") String executionId) throws Exception{
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(executionId).singleResult();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);
// 使用spring注入引擎请使用下面的这行代码
Context.setProcessEngineConfiguration(processEngine.getProcessEngineConfiguration());
InputStream imageStream = ProcessDiagramGenerator.generateDiagram(bpmnModel, "png", activeActivityIds);
// 输出资源内容到相应对象
byte[] b = new byte[1024];
int len;
while ((len = imageStream.read(b, 0, 1024)) != -1) {
response.getOutputStream().write(b, 0, len);
}
}
示例4: getInstanceDiagram
import org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator; //导入依赖的package包/类
@Get
public InputRepresentation getInstanceDiagram() {
if(authenticate() == false) return null;
String processInstanceId = (String) getRequest().getAttributes().get("processInstanceId");
if(processInstanceId == null) {
throw new ActivitiException("No process instance id provided");
}
ExecutionEntity pi =
(ExecutionEntity) ActivitiUtil.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
if (pi == null) {
throw new ActivitiException("Process instance with id" + processInstanceId + " could not be found");
}
ProcessDefinitionEntity pde = (ProcessDefinitionEntity) ((RepositoryServiceImpl) ActivitiUtil.getRepositoryService())
.getDeployedProcessDefinition(pi.getProcessDefinitionId());
if (pde != null && pde.isGraphicalNotationDefined()) {
InputStream resource = ProcessDiagramGenerator.generateDiagram(pde, "png", ActivitiUtil.getRuntimeService().getActiveActivityIds(processInstanceId));
InputRepresentation output = new InputRepresentation(resource);
return output;
} else {
throw new ActivitiException("Process instance with id " + processInstanceId + " has no graphic description");
}
}
示例5: getProcessDefinitionDiagram
import org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator; //导入依赖的package包/类
/**
*
* @param processId the process <strong>Definition</strong> Id - NOT the process Instance Id.
* @return png image of diagram - nothing highlighted since this is the process definition - not a specific instance.
*/
byte[] getProcessDefinitionDiagram(String processId) throws IOException {
ProcessDefinition pd =
this.repoSrvc.createProcessDefinitionQuery().processDefinitionKey(processId).latestVersion().singleResult();
log.debug("Getting process diagram for processId: " + pd.getId());
BpmnModel model = repoSrvc.getBpmnModel(pd.getId());
InputStream in = ProcessDiagramGenerator.generatePngDiagram(model);
byte[] bytes = IOUtils.toByteArray(in);
IOUtils.closeQuietly(in);
log.debug("Got bytes of size: " + bytes.length);
return bytes;
}
示例6: getActiveDocumentDiagram
import org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator; //导入依赖的package包/类
byte[] getActiveDocumentDiagram(String docId) throws IOException {
log.debug("getting active diagram for doc: " + docId);
//http://forums.activiti.org/content/process-diagram-highlighting-current-process
ProcessInstance pi =
runtimeService.createProcessInstanceQuery().processInstanceBusinessKey(docId).singleResult();
RepositoryServiceImpl impl = (RepositoryServiceImpl)repoSrvc;
ProcessDefinitionEntity pde = (ProcessDefinitionEntity) impl.getDeployedProcessDefinition(pi.getProcessDefinitionId());
BpmnModel bpmnModel = repoSrvc.getBpmnModel(pde.getId());
InputStream in = ProcessDiagramGenerator.generateDiagram(bpmnModel, "png", runtimeService.getActiveActivityIds(pi.getProcessInstanceId()));
byte[] bytes = IOUtils.toByteArray(in);
IOUtils.closeQuietly(in);
log.debug("Got bytes of size: " + bytes.length);
return bytes;
}
示例7: testRepoService
import org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator; //导入依赖的package包/类
@Test
public void testRepoService() throws IOException {
List<ProcessDefinition> pds = this.repositoryService.createProcessDefinitionQuery().list();
log.debug("Number of pds: " + pds.size());
for (ProcessDefinition pd : pds) {
BpmnModel model = repositoryService.getBpmnModel(pd.getId());
InputStream in = ProcessDiagramGenerator.generatePngDiagram(model);
FileUtils.copyInputStreamToFile(in, new File("target/" + pd.getName() + "_diagram.png"));
IOUtils.closeQuietly(in);
}
}
示例8: testBuildDefaultWF
import org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator; //导入依赖的package包/类
@Test
public void testBuildDefaultWF() throws IOException {
BpmnModel model = workflowBldr.defaultDocumentApprove();
InputStream in = ProcessDiagramGenerator.generatePngDiagram(model);
FileUtils.copyInputStreamToFile(in, new File("target/default_diagram.png"));
IOUtils.closeQuietly(in);
}
示例9: getImageStream
import org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator; //导入依赖的package包/类
public static InputStream getImageStream(String taskId) throws Exception{
ProcessDefinitionEntity pde = findProcessDefinitionEntityByTaskId(taskId);
InputStream imageStream = ProcessDiagramGenerator.generateDiagram(
pde, "png",
runtimeService.getActiveActivityIds(findProcessInstanceByTaskId(taskId).getId()));
return imageStream;
}
示例10: testDocApprovalFlow
import org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator; //导入依赖的package包/类
@Test
public void testDocApprovalFlow() throws InterruptedException, IOException {
setSpringSecurity("kermit");
Document doc = new Document();
doc.setGroupId("engineering");
doc.setCreatedDate(new Date());
doc.setTitle("title");
doc.setSummary("Summary");
doc.setContent("content");
doc.setAuthor("kermit");
String docId;
docId = documentService.createDocument(doc);
log.debug("new doc id: " + docId);
this.documentService.submitForApproval(docId);
setSpringSecurity("fozzie");
List<TaskForm> tasks = this.localTaskService.getTasks("fozzie");
assertTrue(tasks.size() == 1);
TaskForm currentTask = tasks.get(0);
log.debug("got task: " + tasks.get(0).getName());
//http://forums.activiti.org/content/process-diagram-highlighting-current-process
RepositoryServiceImpl impl = (RepositoryServiceImpl)repoSrvc;
ProcessDefinitionEntity pde = (ProcessDefinitionEntity) impl.getDeployedProcessDefinition(currentTask.getProcessDefinitionId());
BpmnModel bpmnModel = repoSrvc.getBpmnModel(pde.getId());
InputStream in = ProcessDiagramGenerator.generateDiagram(bpmnModel, "png", runtimeService.getActiveActivityIds(currentTask.getProcessInstanceId()));
FileUtils.copyInputStreamToFile(in, new File("target/current-diagram.png"));
localTaskService.approveTask(true, "task approved blah blah blah", tasks.get(0).getId());
HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().
includeProcessVariables().processInstanceBusinessKey(docId).singleResult();
assertNotNull(pi);
log.debug("Duration time in millis: " + pi.getDurationInMillis());
List<HistoricTaskInstance> hTasks;
hTasks = historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().processInstanceBusinessKey(docId).list();
assertTrue(hTasks.size() == 2);
HistoricTaskInstance approval = hTasks.get(1);
Map<String, Object> vars = approval.getTaskLocalVariables();
List<Comment> comments = taskService.getTaskComments(approval.getId());
}
示例11: getImageStream
import org.activiti.engine.impl.bpmn.diagram.ProcessDiagramGenerator; //导入依赖的package包/类
public InputStream getImageStream(String taskId) throws Exception{
ProcessDefinitionEntity pde = findProcessDefinitionEntityByTaskId(taskId);
InputStream imageStream = ProcessDiagramGenerator.generateDiagram(pde, "png",
runtimeService.getActiveActivityIds(findProcessInstanceByTaskId(taskId).getId()));
return imageStream;
}