JBPM4整理001
4.编写流程发布及控制的类
package zzg;import java.io.IOException;import java.lang.reflect.Method;import java.util.ArrayList;import java.util.HashMap;import java.util.Iterator;import java.util.LinkedHashMap;import java.util.List;import java.util.Map;import java.util.Set;import java.util.zip.ZipInputStream;import javax.servlet.ServletConfig;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.commons.fileupload.DiskFileUpload;import org.apache.commons.fileupload.FileItem;import org.jbpm.api.Configuration;import org.jbpm.api.Execution;import org.jbpm.api.ExecutionService;import org.jbpm.api.ProcessDefinition;import org.jbpm.api.ProcessDefinitionQuery;import org.jbpm.api.ProcessEngine;import org.jbpm.api.ProcessInstance;import org.jbpm.api.RepositoryService;import org.jbpm.api.TaskService;import org.jbpm.api.task.Task;/** * Servlet implementation class LeaveServlet */public class LeaveServlet extends HttpServlet {private static final long serialVersionUID = 1L;private ProcessEngine processEngine = null;private RepositoryService repositoryService = null;private ExecutionService executionService = null;private ProcessInstance processInstance = null;private TaskService taskService = null;private Task task = null;private Execution execution = null;private String url = null;private List list = null;private List<Task> taskList = null;/* 初始化ProcessEngine. */public void init(ServletConfig config) throws ServletException {super.init(config);// 获取流程引擎processEngine = new Configuration().buildProcessEngine();repositoryService = processEngine.getRepositoryService();executionService = processEngine.getExecutionService();taskService = processEngine.getTaskService();}protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {process(request, response);}protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {process(request, response);}protected void process(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {String zzg = request.getParameter("zzg");if (zzg.equals("deploy")) {try {deploy(request, response);} catch (Exception e) {e.printStackTrace();}list = getLatestProcessDefinition(request, response);request.setAttribute("process", list);request.getRequestDispatcher("/index.jsp").forward(request,response);} else if (zzg.equals("leave")) {url = leave(request, response);request.getRequestDispatcher(url).forward(request, response);} else if (zzg.equals("query")) {list = getProcessInstanceById(request, response);request.setAttribute("pi", list);request.getRequestDispatcher("/index.jsp").forward(request,response);} else if (zzg.equals("apply")) {apply(request, response);list = getProcessInstanceById(request, response);request.setAttribute("pi", list);request.getRequestDispatcher("/index.jsp").forward(request,response);} else if (zzg.equals("getTask")) {list = getTask(request, response);request.setAttribute("taskList", list);request.getRequestDispatcher("/check.jsp").forward(request,response);} else if (zzg.equals("view")) {Map<String, Object> map = view(request, response);request.setAttribute("map", map);request.getRequestDispatcher("/view.jsp").forward(request, response);} else if (zzg.equals("confirm")) {confirm(request, response);list = getTask(request, response);request.setAttribute("taskList", list);request.getRequestDispatcher("/check.jsp").forward(request,response);} else if (zzg.equals("dissent")) {dissent(request, response);list = getTask(request, response);request.setAttribute("taskList", list);request.getRequestDispatcher("/check.jsp").forward(request,response);}/* * try { Class clz = this.getClass(); Method method = * clz.getDeclaredMethod(action, HttpServletRequest.class, * HttpServletResponse.class); method.invoke(this, request, response); } * catch (Exception ex) { ex.printStackTrace(); } */}protected void deploy(HttpServletRequest request,HttpServletRespon