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));
}
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;
}
Aggregations