jbpm分页

获取jbpm的待办列表,比如用户admin的共有100条待办数据,调用jbpm的API如下:
  1. 获取待办列表:
  2. JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
  3. TaskMgmtSession taskMgmtSession = jbpmContext.getTaskMgmtSession();
  4. //只能获取尚未完成的任务列表(待办任务)
  5. List list = taskMgmtSession.findTaskInstances(userId);

下面的jbpm的源码

 

  1.   public List findTaskInstances(String actorId) {
  2.     List result = null;
  3.     try {
  4.       Query query = session.getNamedQuery("TaskMgmtSession.findTaskInstancesByActorId");
  5.       query.setString("actorId", actorId);
  6.       result = query.list();
  7.     } catch (Exception e) {
  8.       log.error(e);
  9.       jbpmSession.handleException();
  10.       throw new JbpmException("couldn't get task instances list for actor '"+actorId+"'", e);
  11.     }
  12.     return result;
  13.   }

TaskMgmtSession.findTaskInstancesByActorId所对应的sql语句如下:

  1. <query name="TaskMgmtSession.findTaskInstancesByActorId">
  2.     <![CDATA[
  3.       select ti
  4.       from org.jbpm.taskmgmt.exe.TaskInstance as ti
  5.       where ti.actorId = :actorId
  6.         and ti.isOpen = true
  7.     ]]>
  8.   </query>

可以看到jbpm并没有实现分页的处理

仅仅是把所有的记录都查询出来了

所以下面,进行了封装,实现了分页。

 

首先建立Page.java

 

 

 

  1. package com.eway.framework.basecomponent.services.jbpm.util;
  2. /**
  3.  * Created by IntelliJ IDEA.
  4.  * User: yuchen
  5.  * Date: 2008-11-24
  6.  * Time: 17:26:31
  7.  * To change this template use File | Settings | File Templates.
  8.  */
  9. public class Page {
  10.     private int pageSize ;//每页显示的条数
  11.     private int recordCount;//总共的条数
  12.     private int currentPage;//当前页面
  13.     public Page() {
  14.     }
  15.     public Page(int pageSize, int recordCount, int currentPage) {
  16.         this.pageSize = pageSize;
  17.         this.recordCount = recordCount;
  18.         this.setCurrentPage(currentPage,"");
  19.     }
  20.     //构造方法
  21.     public Page(int pageSize, int recordCount) {
  22.         this(pageSize, recordCount, 1);
  23.     }
  24.     //总页数
  25.     public int getPageCount() {
  26.         int size = recordCount / pageSize;//总条数/每页显示的条数=总页数
  27.         int mod = recordCount % pageSize;//最后一页的条数
  28.         if (mod != 0)
  29.             size++;
  30.         return recordCount == 0 ? 1 : size;
  31.     }
  32.     //包含,起始索引为0
  33.     public int getFromIndex() {
  34.         //System.out.println("from index:"+(currentPage-1) * pageSize);
  35.         return (currentPage - 1) * pageSize+1;
  36.     }
  37.     //不包含
  38.     public int getToIndex() {
  39.         //System.out.println("to index:"+Math.min(recordCount, currentPage * pageSize));
  40.         return Math.min(recordCount, currentPage * pageSize);
  41.     }
  42.     //得到当前页
  43.     public int getCurrentPage() {
  44.         return currentPage;
  45.     }//设置当前页
  46.     /**
  47.      *
  48.      * @param currentPage
  49.      * @param inner
  50.      */
  51.     public void setCurrentPage(int currentPage,String inner) {
  52.         int validPage = currentPage <= 0 ? 1 : currentPage;
  53.         validPage = validPage > getPageCount() ? getPageCount() : validPage;
  54.         this.currentPage = validPage;
  55.     }//得到每页显示的条数
  56.     /**
  57.      * 
  58.      * @param currentPage
  59.      */
  60.     public void setCurrentPage(int currentPage) {
  61.         this.currentPage = currentPage;
  62.     }
  63.     //得到每页显示的条数
  64.     public int getPageSize() {
  65.         return pageSize;
  66.     }//设置每页显示的条数
  67.     public void setPageSize(int pageSize) {
  68.         this.pageSize = pageSize;
  69.     }//得到总共的条数
  70.     public int getRecordCount() {
  71.         return recordCount;
  72.     }//设置总共的条数
  73.     public void setRecordCount(int recordCount) {
  74.         this.recordCount = recordCount;
  75.     }
  76. }

为了统一管理hibernate的session,笔者写了HibernateUtil.java

  1. package com.eway.framework.basecomponent.services.jbpm.util;
  2. import org.hibernate.HibernateException;
  3. import org.hibernate.Session;
  4. import org.hibernate.SessionFactory;
  5. import org.hibernate.Transaction;
  6. import org.hibernate.cfg.Configuration;
  7. /**
  8.  * Created by IntelliJ IDEA.
  9.  * User: yuchen
  10.  * Date: 2008-11-26
  11.  * Time: 12:23:03
  12.  * To change this template use File | Settings | File Templates.
  13.  */
  14. //定义一个HibernateUtil类来初始化hinernate 创建SessionFactory实例,并提供创建Session实例,关闭Session实例
  15. //以及打开/关闭事务  和从新创建SessionFactory实例的使用方法(所以方法都为静态)
  16. public class HibernateUtil {
  17.     private static final SessionFactory sessionFactory;
  18.     static {
  19.         try {
  20.             sessionFactory = new Configuration().configure().buildSessionFactory();
  21.         } catch (Throwable ex) {
  22.             ex.printStackTrace();
  23.             throw new ExceptionInInitializerError(ex);
  24.         }
  25.     }
  26.     public static final ThreadLocal<Session> tLocalsess = new ThreadLocal<Session>();
  27.     public static final ThreadLocal<Transaction> tLocaltx = new ThreadLocal<Transaction>();
  28.     /*
  29.       getting the thread-safe session for using  取得session
  30.     */
  31.     public static Session currentSession() {
  32.         Session session = (Session) tLocalsess.get();
  33.         try {
  34.             if (session == null || !session.isOpen()) {
  35.                 session = openSession();
  36.                 tLocalsess.set(session);
  37.             }
  38.            System.out.println("session.isOpen()===="+session.isOpen());
  39.         } catch (HibernateException e) {
  40.             e.printStackTrace();
  41.         }
  42.         return session;
  43.     }
  44.     /*
  45.     * closing the thread-safe session 关闭session
  46.     */
  47.     public static void closeSession() {
  48.         Session session = (Session) tLocalsess.get();
  49.         tLocalsess.set(null);
  50.         try {
  51.             if (session != null && session.isOpen()) {
  52.                 session.close();
  53.             }
  54.         } catch (HibernateException e) {
  55.         }
  56.     }
  57.     /*
  58.     * begin the transaction 开始事务
  59.     */
  60.     public static void beginTransaction() {
  61.         Transaction tx = (Transaction) tLocaltx.get();
  62.         try {
  63.             if (tx == null) {
  64.                 tx = currentSession().beginTransaction();
  65.                 tLocaltx.set(tx);
  66.             }
  67.         } catch (HibernateException e) {
  68.         }
  69.     }
  70.     // close the transaction 关闭事务
  71.     public static void commitTransaction() {
  72.         Transaction tx = (Transaction) tLocaltx.get();
  73.         try {
  74.             if (tx != null && !tx.wasCommitted() && !tx.wasRolledBack())
  75.                 tx.commit();
  76.             tLocaltx.set(null);
  77.         } catch (HibernateException e) {
  78.         }
  79.     }
  80. //  for rollbacking 事务回滚
  81.     public static void rollbackTransaction() {
  82.         Transaction tx = (Transaction) tLocaltx.get();
  83.         try {
  84.             tLocaltx.set(null);
  85.             if (tx != null && !tx.wasCommitted() && !tx.wasRolledBack()) {
  86.                 tx.rollback();
  87.             }
  88.         } catch (HibernateException e) {
  89.         }
  90.     }
  91.     private static Session openSession() throws HibernateException {
  92.         return getSessionFactory().openSession();
  93.     }
  94.     private static SessionFactory getSessionFactory() throws HibernateException {
  95.         return sessionFactory;
  96.     }
  97. }

用于获取hibernate的session和事务处理,同时写了一个filter类,用于关闭session

笔者用的web服务器是tomcat,采用webwork+spring+hibernate+jbpm(如果你不是这样的,也具体不影响什么)

 

CloseSessionFilter.java

  1. package com.eway.framework.basecomponent.services.jbpm.util;
  2. import java.io.IOException;
  3. import javax.servlet.Filter;
  4. import javax.servlet.FilterChain;
  5. import javax.servlet.FilterConfig;
  6. import javax.servlet.ServletException;
  7. import javax.servlet.ServletRequest;
  8. import javax.servlet.ServletResponse;
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11. import org.apache.commons.logging.Log;
  12. import org.apache.commons.logging.LogFactory;
  13. /**
  14.  * Created by IntelliJ IDEA.
  15.  * User: yuchen
  16.  * Date: 2008-11-26
  17.  * Time: 13:10:04
  18.  * To change this template use File | Settings | File Templates.
  19.  */
  20. public class CloseSessionFilter implements Filter {
  21.     Log log = LogFactory.getLog(this.getClass());
  22.     protected FilterConfig config;
  23.     public void init(FilterConfig config) throws ServletException {
  24.         this.config = config;
  25.     }
  26.     public void doFilter(
  27.             ServletRequest request,
  28.             ServletResponse response,
  29.             FilterChain chain)
  30.             throws IOException, ServletException {
  31.         try {
  32.             chain.doFilter((HttpServletRequest) request, (HttpServletResponse) response);
  33.         }
  34.         finally {
  35.             try {
  36.                 HibernateUtil.closeSession();
  37.                 log.debug("close session success");
  38.             }
  39.             catch (Exception e) {
  40.                 HibernateUtil.rollbackTransaction();
  41.                 log.debug("can not close session!/nerrors:" + e.getMessage());
  42.             }
  43.             finally {
  44.                 HibernateUtil.closeSession();
  45.             }
  46.         }
  47.     }
  48.     public void destroy() {
  49.     }
  50. }

这个需要在web.xml中配置一下

 

  1. <filter> 
  2.         <filter-name>closeHibernateSessionFilter</filter-name> 
  3.         <filter-class>com.eway.framework.basecomponent.services.jbpm.util.CloseSessionFilter</filter-class
  4.     </filter> 
  5.     <filter-mapping> 
  6.         <filter-name>closeHibernateSessionFilter</filter-name> 
  7.         <url-pattern>/jbpm/*</url-pattern>
  8.     </filter-mapping> 
 
JbpmBaseJdbcDAO .java负责处理查询,根据传来的sql,page,和参数进行查询,并返回查询结果
 
  1. package com.eway.framework.basecomponent.services.jbpm.util;
  2. import org.hibernate.Session;
  3. import org.hibernate.Query;
  4. import org.hibernate.HibernateException;
  5. import org.apache.commons.logging.Log;
  6. import org.apache.commons.logging.LogFactory;
  7. import java.util.List;
  8. import java.util.Map;
  9. import java.util.HashMap;
  10. /**
  11.  * Created by IntelliJ IDEA.
  12.  * User: yuchen
  13.  * Date: 2008-11-24
  14.  * Time: 17:26:16
  15.  * To change this template use File | Settings | File Templates.
  16.  */
  17. public class JbpmBaseJdbcDAO {
  18.     private Page page;
  19.     private Session hibernateSession;
  20.     /**
  21.      * 默认构造器
  22.      */
  23.     public JbpmBaseJdbcDAO() {
  24.         this.page = null;
  25.         this.hibernateSession = HibernateUtil.currentSession(); //当前的hibernate会话
  26.     }
  27.     /**
  28.      * 带参构造器
  29.      *
  30.      * @param pageSize
  31.      * @param currentPage
  32.      * @param recordCount
  33.      */
  34.     public JbpmBaseJdbcDAO(int pageSize, int currentPage, int recordCount) {
  35.         page = new Page();
  36.         page.setRecordCount(recordCount);
  37.         page.setCurrentPage(currentPage);
  38.         page.setPageSize(pageSize);
  39.         this.hibernateSession = HibernateUtil.currentSession(); //当前的hibernate会话
  40.     }
  41.     /**
  42.      * @param page
  43.      */
  44.     public JbpmBaseJdbcDAO(Page page) {
  45.         this.page = page;
  46.     }
  47.     /*
  48.     * 根据sql,参数查询出结果
  49.     * @param sql
  50.     * @param parameterMap
  51.     * @return
  52.     */
  53.     public List<Object> findByOutQuery(String sql, Map<String, Object> parameterMap) {
  54.         Query query = null;
  55.         List list = null;
  56.         try {
  57.             log.info("hibernateSession.isOpen()====" + hibernateSession.isOpen());
  58.             boolean issql = sql.indexOf("from") != -1;//sql中包含字符串 “from”
  59.             if (issql)
  60.                 query = hibernateSession.createQuery(sql);        //查询对象
  61.             else
  62.                 query = hibernateSession.getNamedQuery(sql);        //查询对象
  63.             if (this.page != null) {
  64.                 page.setRecordCount(this.getTotalCount(sql, parameterMap));
  65.                 int pageSize = page.getPageSize();//每页显示的条数
  66.                 int firstResult = page.getFromIndex();//从第多少条记录开始查询
  67.                 if (pageSize > 0 && firstResult > 0) {
  68.                     query.setFirstResult(firstResult);
  69.                     query.setMaxResults(pageSize);
  70.                 }
  71.             }
  72.             parameterMap = parameterMap == null ? new HashMap() : parameterMap;
  73.             for (String key : parameterMap.keySet()) {      //对查询条件进行迭代
  74.                 if (key != null && !"".equals(key)) {
  75.                     Object value = parameterMap.get(key);
  76.                     if (value != null) {
  77.                         query.setParameter(key, value);     //加入查询条件
  78.                     }
  79.                 }
  80.             }
  81.             list = query.list();
  82.         } catch (HibernateException e) {
  83.             log.error("method--[findByOutQuery] throws HibernateException" + e.getMessage());
  84.             e.printStackTrace();
  85.         }
  86.         return list;
  87.     }
  88.     /**
  89.      * 根据sql,参数和页码查询出结果
  90.      *
  91.      * @param sql
  92.      * @param parameterMap
  93.      * @param page
  94.      * @return
  95.      */
  96.     public List<Object> findByOutQuery(String sql, Map<String, Object> parameterMap, Page page) {
  97.         this.page = page;
  98.         return this.findByOutQuery(sql, parameterMap);
  99.     }
  100.     /**
  101.      * 根据sql,参数和页码查询出结果
  102.      *
  103.      * @param sql
  104.      * @param parameterMap
  105.      * @param pageSize
  106.      * @param currentPage
  107.      * @param recordCount
  108.      * @return
  109.      */
  110.     public List<Object> findByOutQueryAndPage(String sql, Map<String, Object> parameterMap, int pageSize, int currentPage, int recordCount) {
  111.         page = new Page();
  112.         page.setRecordCount(recordCount);
  113.         page.setCurrentPage(currentPage);
  114.         page.setPageSize(pageSize);
  115.         return this.findByOutQuery(sql, parameterMap);
  116.     }
  117.     /**
  118.      * 取到总共的条数
  119.      *
  120.      * @param sql
  121.      * @param parameterMap
  122.      * @return
  123.      */
  124.     private Integer getTotalCount(String sql, Map<String, Object> parameterMap) {
  125.         Integer  amount = 0;
  126.         Query query = null;
  127.         try {
  128.             boolean issql = sql.indexOf("from") != -1;//sql中包含字符串 “from”
  129.             if (!issql) {
  130.                 query = hibernateSession.getNamedQuery(sql);
  131.                 sql = query.getQueryString();
  132.             }
  133.             int sql_index = sql.indexOf(" from");
  134.             String countStr = "select count(*) " + sql.substring(sql_index);
  135.             query = hibernateSession.createQuery(countStr);        //查询对象
  136.             parameterMap = parameterMap == null ? new HashMap() : parameterMap;
  137.             for (String key : parameterMap.keySet()) {      //对查询条件进行迭代
  138.                 if (key != null && !"".equals(key)) {
  139.                     Object value = parameterMap.get(key);
  140.                     if (value != null) {
  141.                         query.setParameter(key, value);     //加入查询条件
  142.                     }
  143.                 }
  144.             }
  145.             List list = query.list();
  146.             if (!list.isEmpty()) {
  147.                 Object count    =   list.get(0);
  148.                  amount   =    Integer.parseInt(count.toString());
  149.             }
  150.         } catch (HibernateException e) {
  151.             log.error("method--[getTotalCount] throws HibernateException" + e.getMessage());
  152.             e.printStackTrace();
  153.         }
  154.         return amount;
  155.     }
  156.     private static Log log = LogFactory.getLog(JbpmBaseJdbcDAO.class);
  157.     //getter and setter method
  158.     public Page getPage() {
  159.         return page;
  160.     }
  161.     public void setPage(Page page) {
  162.         this.page = page;
  163.     }
  164. }

那么谁来调用JbpmBaseJdbcDAO .java呢?

 

有下面的接口提供给用户使用

  1. package com.eway.framework.basecomponent.services.jbpm;
  2. import com.eway.framework.basecomponent.services.jbpm.util.Page;
  3. import java.util.Collection;
  4. import java.util.List;
  5. /**
  6.  * Created by IntelliJ IDEA.
  7.  * Author: xinpeng
  8.  * Date: 2008-10-21
  9.  * Time: 11:08:14
  10.  * To change this template use File | Settings | File Templates.
  11.  */
  12. public interface JbpmWorklistQueryService {
  13.     public Collection<TaskInstanceDTO> queryToSignInListByPage(String userId,Page page);
  14.     public List queryTodoListByPage(String userId, Page page);
  15.     public Collection<TaskInstanceDTO> queryCompletedListByPage(String userId, Page page);
  16. }

可以看到方法public List queryTodoListByPage(String userId, Page page);正是我们所需要的

 

根据参与者和page对象可以取到当前参与者的对应page的待办列表

JbpmWorklistQueryServiceImpl.java是此接口的实现类

 

 

 

  1. package com.eway.framework.basecomponent.services.jbpm;
  2. import org.apache.commons.logging.Log;
  3. import org.apache.commons.logging.LogFactory;
  4. import java.math.BigDecimal;
  5. import java.util.*;
  6. import com.eway.framework.basecomponent.services.jbpm.util.Page;
  7. import com.eway.framework.basecomponent.services.jbpm.util.JbpmBaseJdbcDAO;
  8. /**
  9.  * Created by IntelliJ IDEA.
  10.  * Author: xinpeng
  11.  * Date: 2008-10-21
  12.  * Time: 11:08:37
  13.  * To change this template use File | Settings | File Templates.
  14.  */
  15. public class JbpmWorklistQueryServiceImpl implements JbpmWorklistQueryService {
  16.     private static final Log log = LogFactory.getLog(JbpmWorklistQueryServiceImpl.class);
  17.     public Collection<TaskInstanceDTO> queryToSignInListByPage(String userId, Page page) {
  18.         //todo:改为分页的实现
  19.         Collection<TaskInstanceDTO> todoList = new ArrayList<TaskInstanceDTO>();
  20.         return todoList;
  21.     }
  22.     /**
  23.      * 取到待办列表
  24.      */
  25.     public List queryTodoListByPage(String userId, Page page) {
  26.         List todoList = new ArrayList();
  27.         String sqlPath = "TaskMgmtSession.findTaskInstancesByActorId";
  28.         JbpmBaseJdbcDAO baseJdbcDao = new JbpmBaseJdbcDAO();
  29.         Map paraMap = new HashMap();
  30.         paraMap.put("actorId""admin");
  31.         todoList = baseJdbcDao.findByOutQuery(sqlPath, paraMap, page);
  32. //
  33. //        String sql = "select * from JBPM_TASKINSTANCE a where a.actorId_=? and a.isSuspended_ = ? and a.isOpen_ = ? and a.start_ is not null order by a.START_ desc";
  34. //        Object[] args = new Object[]{userId, false, true};
  35. //        List lstResultMap = baseJdbcDAO.findByOutQuery(sql, args);
  36. //        for (Object mapItem : lstResultMap) {
  37. //            Map map = (Map) mapItem;
  38. //            String name = (String) map.get("NAME_");
  39. //            log.debug("name = " + name);
  40. //            TaskInstanceDTO taskInstance = new TaskInstanceDTO();
  41. //            BigDecimal big = (BigDecimal) map.get("ID_");
  42. //            taskInstance.setId(big.longValue());
  43. //            taskInstance.setName(name);
  44. //            taskInstance.setActorId((String) map.get("ACTORID_"));
  45. //            taskInstance.setStart((Date) map.get("START_"));
  46. //            taskInstance.setTokenId(((BigDecimal) map.get("TOKEN_")).longValue());
  47. //            taskInstance.setTaskId(((BigDecimal) map.get("TASK_")).longValue());
  48. //            taskInstance.setTaskMgmtInstanceId(((BigDecimal) map.get("TASKMGMTINSTANCE_")).longValue());
  49. //            //taskInstance.setSwimlaneInstanceId(((BigDecimal)map.get("SWIMLANINSTANCE_")).longValue());
  50. //            todoList.add(taskInstance);
  51. //        }
  52. //        log.info("todoList==" + todoList);
  53.         return todoList;
  54.     }
  55.     /**
  56.      * 取到办结列表
  57.      * @param userId
  58.      * @param page
  59.      * @return
  60.      */
  61.     public Collection<TaskInstanceDTO> queryCompletedListByPage(String userId, Page page) {
  62.         //todo:改为分页的实现
  63.         JbpmBaseJdbcDAO jbpmBaseJdbcDAO = new JbpmBaseJdbcDAO();
  64.         Collection<TaskInstanceDTO> completedList = new ArrayList<TaskInstanceDTO>();
  65.         return completedList;
  66.     }
  67. }

这样在客户端,,对此接口的方法进行调用就可以分页了。。

下面是客户端调用的代码

 

当然也是用webwork的一个action进行访问

 

webwork的具体配置就省去了,相信大家已经很熟悉了

JbpmAction.java中的获取待办列表的方法todoList 对待办列表进行了调用。

  1. package com.mycompany.jbpm.action;
  2. import com.eway.framework.basecomponent.services.jbpm.util.IDeployJbpmProcessService;
  3. import com.eway.framework.basecomponent.services.jbpm.util.Page;
  4. import com.eway.framework.basecomponent.services.jbpm.JbpmProcessDefinitionService;
  5. import com.eway.framework.basecomponent.services.jbpm.JbpmProcessInstanceService;
  6. import com.eway.framework.basecomponent.services.jbpm.JbpmWorklistQueryService;
  7. import com.opensymphony.webwork.ServletActionContext;
  8. import java.util.List;
  9. import org.apache.commons.logging.Log;
  10. import org.apache.commons.logging.LogFactory;
  11. import org.jbpm.taskmgmt.exe.TaskInstance;
  12. import javax.servlet.http.HttpServletRequest;
  13. import javax.servlet.http.HttpServletResponse;
  14. /**
  15.  * Created by IntelliJ IDEA.
  16.  * User: yucehn
  17.  * Date: 2008-11-25
  18.  * Time: 17:20:01
  19.  * To change this template use File | Settings | File Templates.
  20.  */
  21. public class JbpmAction {
  22.     private String processName;
  23.     private IDeployJbpmProcessService ideployJbpmProcessService;//流程发布
  24.     private JbpmProcessDefinitionService jbpmProcessDefinitionService;//流程定义服务
  25.     private Page page = new Page();
  26.     private int currentPageNum;
  27.     private List jbpmProcessDefinitionList;   //流程定义
  28.     private List<TaskInstance> jbpmTaskInstanceList;     //任务实例
  29.     private JbpmProcessInstanceService jbpmProcessInstanceService;
  30.     private JbpmWorklistQueryService jbpmWorklistQueryService;
  31.     private static final Log log = LogFactory.getLog(JbpmAction.class);
  32.     /**
  33.      * 发布流程为processName的流程定义
  34.      *
  35.      * @return
  36.      */
  37.     public String deploy() {
  38.         if (processName == null) {
  39.             HttpServletRequest request = ServletActionContext.getRequest();
  40.             processName = request.getParameter("processName");
  41.         }
  42.         log.info("processName===========" + processName);
  43.         ideployJbpmProcessService.deployByname(this.processName);
  44.         return "success";
  45.     }
  46.     /**
  47.      * 发布所有的流程定义
  48.      *
  49.      * @return
  50.      */
  51.     public String deployAll() {
  52.         ideployJbpmProcessService.deployAll();
  53.         return "success";
  54.     }
  55.     /**
  56.      * 默认执行
  57.      *
  58.      * @return
  59.      */
  60.     public String execute() {
  61.         return "success";
  62.     }
  63.     /**
  64.      * @return
  65.      */
  66.     public String findAllProcessDefination() {
  67.         if (currentPageNum != 0)
  68.             page.setCurrentPage(currentPageNum);
  69.         this.jbpmProcessDefinitionList = jbpmProcessDefinitionService.getLatestProcessDefinitionListsByPage(page);
  70.         return "success";
  71.     }
  72.     /**
  73.      * 启动流程
  74.      *
  75.      * @return
  76.      */
  77.     public String startProcess() {
  78.         if (processName == null) {
  79.             HttpServletRequest request = ServletActionContext.getRequest();
  80.             processName = (String) request.getParameter("processName");
  81.         }
  82.         log.info("processName===========" + processName);
  83.         jbpmProcessInstanceService.startProcess("admin"this.processName);
  84.         return "success";
  85.     }
  86.     /**
  87.      * 待办列表
  88.      * @return
  89.      */
  90.     public String todoList() {
  91.         HttpServletRequest request = ServletActionContext.getRequest();
  92.         try{
  93.         currentPageNum = Integer.parseInt(request.getParameter("currentPageNum"));
  94.         }catch(Exception e){
  95.                currentPageNum   =1;
  96.         }
  97.             Page page = new Page();
  98.             page.setCurrentPage(currentPageNum);
  99.             page.setPageSize(8);
  100.             page.setRecordCount(100);
  101.         log.info("page.getCurrentPage()======" + page.getCurrentPage());
  102.         log.info("page.getRecordCount()" + page.getRecordCount());
  103.         log.info("page.getPageSize()" + page.getPageSize());
  104.         jbpmTaskInstanceList    = jbpmWorklistQueryService.queryTodoListByPage("admin", page);
  105.        //  HttpServletResponse response = ServletActionContext.getResponse();
  106.          request.setAttribute("list",jbpmTaskInstanceList);
  107.         return "success";
  108.     }
  109.     //getter and setter method
  110.     public String getProcessName() {
  111.         return processName;
  112.     }
  113.     public void setProcessName(String processName) {
  114.         this.processName = processName;
  115.     }
  116.     public void setIdeployJbpmProcessService(IDeployJbpmProcessService ideployJbpmProcessService) {
  117.         this.ideployJbpmProcessService = ideployJbpmProcessService;
  118.     }
  119.     public void setJbpmProcessDefinitionService(JbpmProcessDefinitionService jbpmProcessDefinitionService) {
  120.         this.jbpmProcessDefinitionService = jbpmProcessDefinitionService;
  121.     }
  122.     public Page getPage() {
  123.         return page;
  124.     }
  125.     public void setPage(Page page) {
  126.         this.page = page;
  127.     }
  128.     public int getCurrentPageNum() {
  129.         return currentPageNum;
  130.     }
  131.     public void setCurrentPageNum(int currentPageNum) {
  132.         this.currentPageNum = currentPageNum;
  133.     }
  134.     public List getJbpmProcessDefinitionList() {
  135.         return jbpmProcessDefinitionList;
  136.     }
  137.     public void setJbpmProcessDefinitionList(List jbpmProcessDefinitionList) {
  138.         this.jbpmProcessDefinitionList = jbpmProcessDefinitionList;
  139.     }
  140.     public JbpmProcessInstanceService getJbpmProcessInstanceService() {
  141.         return jbpmProcessInstanceService;
  142.     }
  143.     public void setJbpmProcessInstanceService(JbpmProcessInstanceService jbpmProcessInstanceService) {
  144.         this.jbpmProcessInstanceService = jbpmProcessInstanceService;
  145.     }
  146.     public void setJbpmWorklistQueryService(JbpmWorklistQueryService jbpmWorklistQueryService) {
  147.         this.jbpmWorklistQueryService = jbpmWorklistQueryService;
  148.     }
  149.     public List<TaskInstance> getJbpmTaskInstanceList() {
  150.         return jbpmTaskInstanceList;
  151.     }
  152.     public void setJbpmTaskInstanceList(List<TaskInstance> jbpmTaskInstanceList) {
  153.         this.jbpmTaskInstanceList = jbpmTaskInstanceList;
  154.     }
  155. }

到此时已经完成jbpm的分页的一个简单的测试demo

其中很多代码没有完成。。是今天刚写的,但在我的机器上已经编译通过,测试正常,每天都会有新的代码,敬请期待。

如果有地方不妥,或者是需要交流,欢迎email到madrocket@163.com  (昵称:疯狂火箭)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值