本文整理汇总了Java中org.activiti.image.ProcessDiagramGenerator类的典型用法代码示例。如果您正苦于以下问题:Java ProcessDiagramGenerator类的具体用法?Java ProcessDiagramGenerator怎么用?Java ProcessDiagramGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProcessDiagramGenerator类属于org.activiti.image包,在下文中一共展示了ProcessDiagramGenerator类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWorkflowImage
import org.activiti.image.ProcessDiagramGenerator; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public InputStream getWorkflowImage(String workflowInstanceId)
{
String processInstanceId = createLocalId(workflowInstanceId);
ExecutionEntity pi = (ExecutionEntity) runtimeService.createProcessInstanceQuery()
.processInstanceId(processInstanceId).singleResult();
// If the process is finished, there is no diagram available
if (pi != null)
{
// Fetch the bpmn model
BpmnModel model = repoService.getBpmnModel(pi.getProcessDefinitionId());
if (model != null && model.getLocationMap().size() > 0)
{
ProcessDiagramGenerator generator = new DefaultProcessDiagramGenerator();
return generator.generateDiagram(model,
ActivitiConstants.PROCESS_INSTANCE_IMAGE_FORMAT,
runtimeService.getActiveActivityIds(processInstanceId));
}
}
return null;
}
示例2: readResource
import org.activiti.image.ProcessDiagramGenerator; //导入依赖的package包/类
/**
* 读取带跟踪的图片
*/
@RequestMapping(value = "/process/trace/auto/{executionId}")
public void readResource(@PathVariable("executionId") String executionId, HttpServletResponse response)
throws Exception {
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(executionId).singleResult();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);
// 不使用spring请使用下面的两行代码
// ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
// Context.setProcessEngineConfiguration(defaultProcessEngine.getProcessEngineConfiguration());
// 使用spring注入引擎请使用下面的这行代码
processEngineConfiguration = processEngine.getProcessEngineConfiguration();
Context.setProcessEngineConfiguration((ProcessEngineConfigurationImpl) processEngineConfiguration);
ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
InputStream imageStream = diagramGenerator.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);
}
}
示例3: readResource
import org.activiti.image.ProcessDiagramGenerator; //导入依赖的package包/类
/**
* 读取流程资源
*/
@RequestMapping(value = "trace/data/auto/{executionId}")
public void readResource(@PathVariable("executionId") String executionId, HttpServletResponse response)
throws Exception {
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(executionId).singleResult();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);
List<String> highLightedFlows = getHighLightedFlows(processDefinition, processInstance.getId());
ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
InputStream imageStream =diagramGenerator.generateDiagram(bpmnModel, "png", activeActivityIds, highLightedFlows);
// 输出资源内容到相应对象
byte[] b = new byte[1024];
int len;
while ((len = imageStream.read(b, 0, 1024)) != -1) {
response.getOutputStream().write(b, 0, len);
}
}
示例4: readResource
import org.activiti.image.ProcessDiagramGenerator; //导入依赖的package包/类
/**
* 读取流程资源
*/
@RequestMapping(value = "trace/data/auto/{executionId}")
public void readResource(@PathVariable("executionId") String executionId, HttpServletResponse response)
throws Exception {
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(executionId).singleResult();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);
ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
List<String> highLightedFlows = getHighLightedFlows(processDefinition, processInstance.getId());
InputStream imageStream =diagramGenerator.generateDiagram(bpmnModel, "png", activeActivityIds, highLightedFlows);
// 输出资源内容到相应对象
byte[] b = new byte[1024];
int len;
while ((len = imageStream.read(b, 0, 1024)) != -1) {
response.getOutputStream().write(b, 0, len);
}
}
示例5: getDiagramByte
import org.activiti.image.ProcessDiagramGenerator; //导入依赖的package包/类
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;
}
示例6: getProcessImage
import org.activiti.image.ProcessDiagramGenerator; //导入依赖的package包/类
@Override
public BinaryResource getProcessImage(String processId)
{
validateIfUserAllowedToWorkWithProcess(processId);
ProcessInstance processInstance = activitiProcessEngine.getRuntimeService()
.createProcessInstanceQuery()
.processInstanceId(processId)
.singleResult();
if (processInstance == null)
{
throw new EntityNotFoundException(processId);
}
try
{
BpmnModel model = activitiProcessEngine.getRepositoryService().getBpmnModel(processInstance.getProcessDefinitionId());
if(model != null && model.getLocationMap().size() > 0)
{
List<String> activeActivities = activitiProcessEngine.getRuntimeService().getActiveActivityIds(processId);
ProcessDiagramGenerator generator = new DefaultProcessDiagramGenerator();
InputStream generateDiagram = generator.generateDiagram(model, "png", activeActivities);
File file = TempFileProvider.createTempFile(processId + UUID.randomUUID(), ".png");
FileOutputStream fos = new FileOutputStream(file);
IOUtils.copy(generateDiagram, fos);
fos.close();
return new FileBinaryResource(file);
}
else
{
throw new EntityNotFoundException(processId + "/image");
}
}
catch (IOException error)
{
throw new ApiException("Error while getting process image.");
}
}
示例7: generateImage
import org.activiti.image.ProcessDiagramGenerator; //导入依赖的package包/类
/**
* 生成流程实例的流程图片,并重点高亮当前节点,高亮已经执行的链路
*
* @param instanceId 流程实例
* @param request
* @return 第二个参数为生成的图片路径
*/
@RequestMapping(value = "/processinstance/generate/{instanceId}", method = RequestMethod.POST)
@ResponseBody
public Result generateImage(@PathVariable("instanceId") String instanceId, HttpServletRequest request) {
try {
String dirPath = request.getRealPath("/");
ProcessInstance processInstance=runtimeService.createProcessInstanceQuery().processInstanceId(instanceId)
.singleResult();
BpmnModel bpmnModel;
List<String> activeActivityIds=new ArrayList<>();
String processDefinitionId;
//存在活动节点,流程正在进行中
if(processInstance!=null) {
processDefinitionId=processInstance.getProcessDefinitionId();
//task = taskService.createTaskQuery().processInstanceId(instanceId).singleResult();
//流程定义
//正在活动的节点
activeActivityIds = runtimeService.getActiveActivityIds(instanceId);//(task.getExecutionId());
}else {
//流程已经结束
HistoricProcessInstance instance=historyService.createHistoricProcessInstanceQuery()
.processInstanceId(instanceId).singleResult();
processDefinitionId=instance.getProcessDefinitionId();
}
bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
ProcessDiagramGenerator pdg = processEngine.getProcessEngineConfiguration().getProcessDiagramGenerator();
//-------------------------------executedActivityIdList已经执行的节点------------------------------------
List<HistoricActivityInstance> historicActivityInstanceList = historyService
.createHistoricActivityInstanceQuery()
.processInstanceId(instanceId).orderByHistoricActivityInstanceStartTime().asc().list();
// 已执行的节点ID集合
List<String> executedActivityIdList = new ArrayList<>();
for (HistoricActivityInstance activityInstance : historicActivityInstanceList) {
executedActivityIdList.add(activityInstance.getActivityId());
}
ProcessDefinition processDefinition = repositoryService.getProcessDefinition(processDefinitionId);
String resourceName = instanceId + "_" + processDefinition.getDiagramResourceName();
List<String> highLightedFlows = getHighLightedFlows((ProcessDefinitionEntity) processDefinition,
historicActivityInstanceList);
//生成流图片 所有走过的节点高亮 第三个参数 activeActivityIds=当前活动节点点高亮;executedActivityIdList=已经执行过的节点高亮
InputStream inputStream = pdg.generateDiagram(bpmnModel, "PNG", activeActivityIds, highLightedFlows,
processEngine.getProcessEngineConfiguration().getActivityFontName(),
processEngine.getProcessEngineConfiguration().getLabelFontName(),
processEngine.getProcessEngineConfiguration().getActivityFontName(),
processEngine.getProcessEngineConfiguration().getProcessEngineConfiguration().getClassLoader(), 1);
resourceName=DateUtil.format(new Date(),"yyyyMMddHHmmss")+"_"+resourceName;
//生成本地图片
String realPath = dirPath + File.separator + DIR_PATH + File.separator + resourceName;
realPath=realPath.replaceAll("\\\\", "/");
File file = new File(realPath);
if (file.exists()) {
file.delete();
}
FileUtil.copyInputStreamToFile(inputStream, file);
String realName = (DIR_PATH + File.separator + resourceName).replaceAll("\\\\", "/");
inputStream.close();
return new Result(true, realName, "成功生成png");
} catch (Exception e) {
LOGGER.error("生成图像文件异常,instanceId={}", instanceId, e);
return new Result(false);
}
}