`
fatedgar
  • 浏览: 135149 次
  • 性别: Icon_minigender_1
  • 来自: 安徽
社区版块
存档分类
最新评论
阅读更多


在spring中设置ProcessEngineConfiguration中的属性
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
	    <property name="databaseType" value="postgres" />
	    <property name="dataSource" ref="dataSource" />
	    <property name="transactionManager" ref="transactionManager" />
	    <property name="databaseSchemaUpdate" value="true" />
	    <property name="jobExecutorActivate" value="true" />
	    <property name="history" value="full" />
	     <!-- 生成流程图的字体 -->
        <property name="activityFontName" value="宋体"/>
        <property name="labelFontName" value="宋体"/>
		<property name="customSessionFactories">
		    <list>
      			<bean class="com.searchingsoft.platform.activiti.ActivitiUserManagerFactory" />
      			<bean class="com.searchingsoft.platform.activiti.ActivitiGroupManagerFactory" />
		    </list>
		</property>
	</bean>


在调用的方法(拷贝咖啡兔的方法)如下:
@RequestMapping("/~{custId}/workflow/trace/auto**")
    public void readResource(@RequestParam("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);
        InputStream imageStream = processEngine.getProcessEngineConfiguration().getProcessDiagramGenerator()
        .generateDiagram(bpmnModel, "png", activeActivityIds, Collections.<String>emptyList(),
                         processEngine.getProcessEngineConfiguration().getActivityFontName(),
                         processEngine.getProcessEngineConfiguration().getLabelFontName(), 
                         processEngine.getProcessEngineConfiguration().getClassLoader(),1.0);

        
        
        // 输出资源内容到相应对象
        byte[] b = new byte[1024];
        int len;
        while ((len = imageStream.read(b, 0, 1024)) != -1) {
            response.getOutputStream().write(b, 0, len);
        }
    }




启发于
http://www.mossle.com/ask/question.do?id=4
http://my.oschina.net/u/1241965/blog/294917
我去看了diagramGenerator.generateDiagram有哪些参数

  • 大小: 7.9 KB
  • 大小: 5.1 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics