Search in sources :

Example 1 with DefaultProcessDiagramGenerator

use of org.activiti.image.impl.DefaultProcessDiagramGenerator in project Activiti by Activiti.

the class ProcessEngineMvcEndpoint method processDefinitionDiagram.

/**
     * Look up the process definition by key. For example,
     * this is <A href="http://localhost:8080/activiti/processes/fulfillmentProcess">process-diagram for</A>
     * a process definition named {@code fulfillmentProcess}.
     */
@RequestMapping(value = "/processes/{processDefinitionKey:.*}", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE)
@ResponseBody
public ResponseEntity processDefinitionDiagram(@PathVariable String processDefinitionKey) {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(processDefinitionKey).latestVersion().singleResult();
    if (processDefinition == null) {
        return ResponseEntity.status(NOT_FOUND).body(null);
    }
    ProcessDiagramGenerator processDiagramGenerator = new DefaultProcessDiagramGenerator();
    BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
    if (bpmnModel.getLocationMap().size() == 0) {
        BpmnAutoLayout autoLayout = new BpmnAutoLayout(bpmnModel);
        autoLayout.execute();
    }
    InputStream is = processDiagramGenerator.generateJpgDiagram(bpmnModel);
    return ResponseEntity.ok(new InputStreamResource(is));
}
Also used : DefaultProcessDiagramGenerator(org.activiti.image.impl.DefaultProcessDiagramGenerator) ProcessDiagramGenerator(org.activiti.image.ProcessDiagramGenerator) InputStream(java.io.InputStream) BpmnAutoLayout(org.activiti.bpmn.BpmnAutoLayout) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) DefaultProcessDiagramGenerator(org.activiti.image.impl.DefaultProcessDiagramGenerator) BpmnModel(org.activiti.bpmn.model.BpmnModel) InputStreamResource(org.springframework.core.io.InputStreamResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with DefaultProcessDiagramGenerator

use of org.activiti.image.impl.DefaultProcessDiagramGenerator in project bamboobsc by billchen198318.

the class BusinessProcessManagementUtils method getDiagramByte.

private static byte[] getDiagramByte(ProcessInstance pi) throws Exception {
    byte[] data = null;
    ProcessDiagramGenerator processDiagramGenerator = new DefaultProcessDiagramGenerator();
    BpmnModel model = repositoryService.getBpmnModel(pi.getProcessDefinitionId());
    InputStream is = processDiagramGenerator.generateDiagram(model, "png", runtimeService.getActiveActivityIds(pi.getId()));
    data = IOUtils.toByteArray(is);
    is.close();
    is = null;
    return data;
}
Also used : DefaultProcessDiagramGenerator(org.activiti.image.impl.DefaultProcessDiagramGenerator) ProcessDiagramGenerator(org.activiti.image.ProcessDiagramGenerator) ZipInputStream(java.util.zip.ZipInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DefaultProcessDiagramGenerator(org.activiti.image.impl.DefaultProcessDiagramGenerator) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Aggregations

InputStream (java.io.InputStream)2 BpmnModel (org.activiti.bpmn.model.BpmnModel)2 ProcessDiagramGenerator (org.activiti.image.ProcessDiagramGenerator)2 DefaultProcessDiagramGenerator (org.activiti.image.impl.DefaultProcessDiagramGenerator)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ZipInputStream (java.util.zip.ZipInputStream)1 BpmnAutoLayout (org.activiti.bpmn.BpmnAutoLayout)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1 InputStreamResource (org.springframework.core.io.InputStreamResource)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1