首页 > 代码库 > ssh2+jbpm4.4项目 审批流转:审批流程管理的思路

ssh2+jbpm4.4项目 审批流转:审批流程管理的思路

1.创建一个ProcessDefinitionAction.java

   

package cn.itcast.oa.view.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;
import java.util.zip.ZipInputStream;

import org.jbpm.api.ProcessDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.itcast.oa.service.ProcessDefinitionService;

import com.opensymphony.xwork2.ActionContext;

@Controller
@Scope("prototype")
public class ProcessDefinitionAction extends BaseAction{
	
	private String key;
    private File upload; //上传
    private String id;
	private InputStream inputStream;  //下载用的
	
	/**列表*/
	public String list() throws Exception {
		List<ProcessDefinition> processDefinitionList=processDefinitionService.findAllLatestVersions();
		ActionContext.getContext().put("processDefinitionList", processDefinitionList);
		return "list";
	}
	
	/**部署流程定义页面*/
	public String addUI() throws Exception {
		return "addUI";
	}
	
	/**部署流程定义*/
	public String add() throws Exception {
		ZipInputStream zipInputStream=new ZipInputStream(new FileInputStream(upload));
		processDefinitionService.deploy(zipInputStream);
		return "toList";
	}
	
	/**删除流程定义*/
	public String delete() throws Exception {
		processDefinitionService.deleteByKey(key);
		return "toList";
	}
	
	/**列表*/
	public String downloadProcessInmage() throws Exception {
		inputStream=processDefinitionService.getProcessImageResourceAsStream(id);
		return "downloadProcessInmage";
	}

	
	
	//----------------------
	public InputStream getInputStream() {
		return inputStream;
	}

	public void setInputStream(InputStream inputStream) {
		this.inputStream = inputStream;
	}

	public String getKey() {
		return key;
		
		
	}

	public File getUpload() {
		return upload;
	}

	public void setUpload(File upload) {
		this.upload = upload;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	
	
}
2.实现相应的service层的方法
3.配置Strutsxml文件

<!-- 审批流转:审批流程管理 -->
		<action name="processDefinitionAction_*" class="processDefinitionAction" method="{1}">
			<result name="list">/WEB-INF/jsp/processDefinitionAction/list.jsp</result>
			<result name="addUI">/WEB-INF/jsp/processDefinitionAction/addUI.jsp</result>
			<result name="toList" type="redirectAction">processDefinitionAction_list</result>
			<!-- 下载专用的结果配置 -->
			<result name="downloadProcessImage" type="stream">
			 <param name="contentType">image/png</param>
			 <param name="inputName">inputStream</param>
			</result>
		</action>

4.添加相应的页面即可


ssh2+jbpm4.4项目 审批流转:审批流程管理的思路