本文整理汇总了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;
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:26,代码来源:ActivitiWorkflowEngine.java
示例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);
}
}
开发者ID:batizhao,项目名称:microservice,代码行数:28,代码来源:ActivitiController.java
示例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);
}
}
开发者ID:shawn-gogh,项目名称:myjavacode,代码行数:22,代码来源:TraceProcessController.java
示例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);
}
}
开发者ID:shawn-gogh,项目名称:myjavacode,代码行数:22,代码来源:TraceProcessController.java
示例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;
}
开发者ID:billchen198318,项目名称:bamboobsc,代码行数:14,代码来源:BusinessProcessManagementUtils.java
示例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.");
}
}
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:43,代码来源:ProcessesImpl.java
示例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);
}
}
开发者ID:bill1012,项目名称:AdminEAP,代码行数:77,代码来源:ProcessInstanceController.java
注:本文中的org.activiti.image.ProcessDiagramGenerator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论