use of org.flowable.bpmn.model.BpmnModel in project plumdo-work by wengwh.
the class ModelValidationResource method validate.
@PostMapping(value = "/models/validate", name = "模型检查")
public List<ValidationError> validate(@RequestBody JsonNode body) {
BpmnModel bpmnModel = new BpmnJsonConverter().convertToBpmnModel(body);
ProcessValidator validator = new ProcessValidatorFactory().createDefaultProcessValidator();
return validator.validate(bpmnModel);
}
use of org.flowable.bpmn.model.BpmnModel in project plumdo-work by wengwh.
the class ProcessInstanceImageResource method getProcessInstanceImage.
@GetMapping(value = "/process-instances/{processInstanceId}/image", name = "流程实例流程图")
public ResponseEntity<byte[]> getProcessInstanceImage(@PathVariable String processInstanceId) {
HistoricProcessInstance processInstance = getHistoricProcessInstanceFromRequest(processInstanceId);
ProcessDefinition pde = repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId());
if (pde == null || !pde.hasGraphicalNotation()) {
exceptionFactory.throwObjectNotFound(ErrorConstant.INSTANCE_IMAGE_NOT_FOUND, processInstance.getId());
}
List<String> highLightedActivities;
if (processInstance.getEndTime() == null) {
highLightedActivities = runtimeService.getActiveActivityIds(processInstance.getId());
} else {
highLightedActivities = Collections.emptyList();
}
BpmnModel bpmnModel = repositoryService.getBpmnModel(pde.getId());
ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
InputStream resource = diagramGenerator.generateDiagram(bpmnModel, "png", highLightedActivities, Collections.emptyList(), processEngineConfiguration.getActivityFontName(), processEngineConfiguration.getLabelFontName(), processEngineConfiguration.getAnnotationFontName(), processEngineConfiguration.getClassLoader(), 1.0);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentType(MediaType.IMAGE_PNG);
try {
return new ResponseEntity<>(IOUtils.toByteArray(resource), responseHeaders, HttpStatus.OK);
} catch (Exception e) {
exceptionFactory.throwDefinedException(ErrorConstant.INSTANCE_IMAGE_READ_ERROR, e.getMessage());
}
return null;
}
Aggregations