JBPM3.2相关

来源:互联网 发布:广电网络招聘 编辑:程序博客网 时间:2024/06/17 16:33

一、web.xml

<filter>  <filter-name>jbpmContextFilter</filter-name>  <filter-class>com.sasis.workflow.jbpm.filter.JbpmContextFilter </filter-class></filter><filter-mapping>  <filter-name>jbpmContextFilter</filter-name>  <url-pattern>/*</url-pattern>    </filter-mapping><servlet><servlet-name>jbpmProcessImageServlet</servlet-name><servlet-class>com.sasis.workflow.image.JbpmProcessImageServlet</servlet-class>    </servlet><servlet><servlet-name>jbpmComplaintProcessImageServlet</servlet-name><servlet-class>com.sasis.workflow.image.JbpmComplaintProcessImageServlet</servlet-class>    </servlet><servlet><servlet-name>processTestInstanceImageServlet</servlet-name><servlet-class> com.sasis.workflow.image.JbpmTaskInstanceImageServlet</servlet-class></servlet>  <servlet-mapping><servlet-name>jbpmProcessImageServlet</servlet-name><url-pattern>/jbpmProcessImageServlet</url-pattern></servlet-mapping><servlet-mapping><servlet-name>jbpmComplaintProcessImageServlet</servlet-name><url-pattern>/jbpmComplaintProcessImageServlet</url-pattern></servlet-mapping><taglib>  <taglib-uri>jbpm</taglib-uri><taglib-location>/WEB-INF/tlds/jbpm.tld</taglib-location></taglib><filter>  <filter-name>hibernateFilter</filter-name>  <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class></filter><filter-mapping>  <filter-name>hibernateFilter</filter-name>  <url-pattern>/*</url-pattern>  </filter-mapping>
二、流程模板


三、jbpm.cfg.xml

<jbpm-configuration>  <!--     This configuration is used when there is no jbpm.cfg.xml file found in the     root of the classpath.  It is a very basic configuration without persistence    and message services.  Only the authorization service installed.    You can parse and create processes, but when you try to use one of the     unavailable services, you'll get an exception.  -->    <jbpm-context>    <service name="persistence"> <factory> <bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory"> <field name="isTransactionEnabled"><false/> </field> <field name="isCurrentSessionEnabled"><true/> </field> </bean> </factory> </service>     <service name="tx" factory="org.jbpm.tx.TxServiceFactory" />     <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />    <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />    <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />    <service name="authentication" factory="com.sasis.workflow.jbpm.security.SasisAuthenticationServiceFactory" />  </jbpm-context>  <!-- configuration resource files pointing to default configuration files in jbpm-{version}.jar -->       <string name="resource.business.calendar" value="org/jbpm/calendar/jbpm.business.calendar.properties" />  <string name="resource.default.modules" value="org/jbpm/graph/def/jbpm.default.modules.properties" />  <string name="resource.converter" value="org/jbpm/db/hibernate/jbpm.converter.properties" />  <string name="resource.action.types" value="org/jbpm/graph/action/action.types.xml" />  <string name="resource.node.types" value="org/jbpm/graph/node/node.types.xml" />  <string name="resource.parsers" value="com/sasis/workflow/jbpm/config/jbpm.parsers.xml" />  <string name="resource.varmapping" value="org/jbpm/context/exe/jbpm.varmapping.xml" />  <long   name="jbpm.msg.wait.timout" value="5000" singleton="true" />  <int    name="jbpm.byte.block.size" value="1024" singleton="true" />  <string name="mail.smtp.host" value="localhost" />  <bean   name="jbpm.task.instance.factory" class="org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl" singleton="true" />  <bean   name="jbpm.variable.resolver" class="org.jbpm.jpdl.el.impl.JbpmVariableResolver" singleton="true" />  <bean   name="jbpm.mail.address.resolver" class="org.jbpm.identity.mail.IdentityAddressResolver" singleton="true" /></jbpm-configuration>

四、


五、gpd.xml

<?xml version="1.0" encoding="UTF-8"?><root-container name="complaintFlow" width="1124" height="571">  <node name="开始" x="24" y="24" width="132" height="36">    <edge>      <label x="-21" y="-6"/>    </edge>  </node>  <node name="投诉录入" x="253" y="25" width="132" height="36">    <edge>      <label x="5" y="-10"/>    </edge>  </node>  <node name="投诉验证" x="392" y="304" width="132" height="36">    <edge>      <label x="5" y="-10"/>    </edge>  </node>  <node name="投诉评估" x="394" y="367" width="132" height="36">    <edge>      <label x="5" y="-10"/>    </edge>  </node>  <node name="投诉处理" x="390" y="95" width="132" height="36">    <edge>      <label x="5" y="-10"/>    </edge>  </node>  <node name="单元经理审核" x="391" y="163" width="132" height="36">    <edge>      <label x="5" y="-10"/>    </edge>  </node>  <node name="最终结案" x="396" y="436" width="132" height="36">    <edge>      <label x="5" y="-10"/>    </edge>  </node>  <node name="单元审核判定" x="188" y="163" width="132" height="36">    <edge>      <label x="5" y="-10"/>    </edge>    <edge>      <label x="5" y="-10"/>    </edge>  </node>  <node name="评估判定" x="733" y="238" width="132" height="36">    <edge>      <label x="5" y="-10"/>    </edge>    <edge>      <label x="5" y="-4"/>    </edge>  </node>  <node name="协查" x="575" y="96" width="132" height="36">    <edge>      <label x="5" y="-10"/>    </edge>  </node>  <node name="部门领导审核" x="391" y="235" width="132" height="36">    <edge>      <label x="5" y="-10"/>    </edge>  </node>  <node name="部门领导审核判定" x="566" y="236" width="132" height="36">    <edge>      <label x="5" y="-10"/>    </edge>    <edge>      <label x="5" y="-10"/>    </edge>  </node>  <node name="总经理判定" x="189" y="437" width="132" height="36">    <edge>      <label x="5" y="-10"/>    </edge>    <edge>      <label x="5" y="-10"/>    </edge>  </node>  <node name="协查判定" x="466" y="25" width="132" height="36">    <edge>      <label x="5" y="-10"/>    </edge>    <edge>      <label x="5" y="-10"/>    </edge>  </node>  <node name="结束" x="396" y="508" width="132" height="36"/></root-container>
六、processdefinition.xml

<?xml version="1.0" encoding="UTF-8"?><process-definition  xmlns=""  name="complaintFlow"><start-state name="开始"><transition  to="投诉录入"><action name="start_action" class="com.sasis.workflow.jbpm.handler.StartComplaintProcessHandler"></action></transition></start-state><task-node name="投诉录入"><task name="投诉录入"> <assignment class="com.sasis.workflow.jbpm.handler.InputComplaintTaskAssignmentHandler"></assignment> </task><transition to="协查判定"></transition></task-node><task-node name="投诉验证"><task name="投诉验证"><assignment class="com.sasis.workflow.jbpm.handler.CheckComplaintTaskAssignmentHandler"></assignment></task><transition name="" to="投诉评估"><action name="to_evaluate" class="com.sasis.workflow.jbpm.handler.ToEvaluateActionHandler"></action></transition></task-node><task-node name="投诉评估"><task name="投诉评估"><assignment class="com.sasis.workflow.jbpm.handler.EvalueateComplaintTaskAssignmentHandler"></assignment></task><transition to="评估判定"></transition></task-node><task-node name="投诉处理"><task name="投诉处理"><assignment class="com.sasis.workflow.jbpm.handler.DealComplaintTaskAssignmentHandler"></assignment></task><transition to="单元经理审核"></transition></task-node><task-node name="单元经理审核"><task name="单元经理审核"><assignment class="com.sasis.workflow.jbpm.handler.AuditTaskAssignmentHandler"></assignment></task><transition to="单元审核判定"><action name="dealJudge" class="com.sasis.workflow.jbpm.handler.JudgeActionHandler"></action></transition></task-node><task-node name="最终结案"><task name="最终结案"><assignment class="com.sasis.workflow.jbpm.handler.CloseCaseTaskAssignmentHandler"></assignment></task><transition to="总经理判定" name=""></transition></task-node><decision name="单元审核判定"><handler class="com.sasis.workflow.jbpm.handler.UnitAuditJudgeDecisionHandler"></handler><transition to="部门领导审核" name="y"></transition><transition to="投诉处理" name="n"></transition></decision><decision name="评估判定"><handler class="com.sasis.workflow.jbpm.handler.EvaluateJudgeDecisionHandler"></handler><transition to="最终结案" name="y"></transition><transition to="投诉处理" name="n"></transition></decision><task-node name="协查"><task name="协查"><assignment class="com.sasis.workflow.jbpm.handler.AssistTaskAssignmentHandler"></assignment></task><transition to="投诉处理" ></transition></task-node><task-node name="部门领导审核"><task name="部门领导审核"><assignment class="com.sasis.workflow.jbpm.handler.LeadAuditTaskAssignmentHandler"></assignment></task><transition to="部门领导审核判定"></transition></task-node><decision name="部门领导审核判定"><handler class="com.sasis.workflow.jbpm.handler.LeadAuditJudgeDecisionHandler"></handler><transition to="投诉验证" name="y"></transition><transition to="投诉处理" name="n"></transition></decision><decision name="总经理判定"><handler class="com.sasis.workflow.jbpm.handler.ManagerJudgeDecisionHandler"></handler><transition to="结束" name="y"></transition><transition to="投诉评估" name="n"></transition></decision><decision name="协查判定"><handler class="com.sasis.workflow.jbpm.handler.AssistJudgeDecisionHandler"></handler><transition to="投诉处理" name="n"></transition><transition to="协查" name="y"></transition></decision><end-state name="结束"></end-state></process-definition>
七、StartComplaintProcessHandler.java

package com.sasis.workflow.jbpm.handler;import java.util.Date;import org.jbpm.context.exe.ContextInstance;import org.jbpm.graph.def.ActionHandler;import org.jbpm.graph.exe.ExecutionContext;public class StartComplaintProcessHandler implements ActionHandler{private static final long serialVersionUID = -7703930993012075081L;public void execute(ExecutionContext executionContext) throws Exception {  ContextInstance ci = executionContext.getContextInstance();  String name = (String)ci.getVariable("inputActor");  System.out.println(name+"have start a complaint process");}}
八、UnitAuditJudgeDecisionHandler.java

package com.sasis.workflow.jbpm.handler;import org.jbpm.context.exe.ContextInstance;import org.jbpm.graph.exe.ExecutionContext;import org.jbpm.graph.node.DecisionHandler;public class UnitAuditJudgeDecisionHandler implements DecisionHandler {private static final long serialVersionUID = -6006030520398243985L;public String decide(ExecutionContext executionContext) throws Exception { ContextInstance ci = executionContext.getContextInstance();String noPass = (String)ci.getVariable("noPass");if(noPass!=null && noPass.equals("1")){return "n";}else{return "y";}        }}
九、JbpmTemplate.java

/* JbpmTemplate.java*/package com.sasis.workflow.jbpm;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStream;import java.math.BigDecimal;import java.util.Date;import java.util.Iterator;import java.util.List;import java.util.Map;import org.apache.commons.lang.StringUtils;import org.apache.struts.action.ActionForm;import org.hibernate.Query;import org.hibernate.Session;import org.hibernate.engine.SessionFactoryImplementor;import org.hibernate.persister.entity.EntityPersister;import org.jbpm.JbpmContext;import org.jbpm.context.exe.ContextInstance;import org.jbpm.graph.def.ProcessDefinition;import org.jbpm.graph.def.Transition;import org.jbpm.graph.exe.ProcessInstance;import org.jbpm.graph.exe.Token;import org.jbpm.taskmgmt.def.Task;import org.jbpm.taskmgmt.exe.TaskInstance;import org.springframework.util.Assert;import org.xml.sax.InputSource;import com.sasis.model.ActivityChangeMsg;import com.sasis.model.User;import com.sasis.service.ActivityChangeMsgManager;import com.sasis.util.DateUtil;import com.sasis.util.StringUtil;import com.sasis.util.holder.RequestHelper;import com.sasis.webapp.ApplicationContextKeeper;import com.sasis.webapp.form.FlightTransInstructionForm;import com.sasis.webapp.form.OperationForm;import com.sasis.workflow.WorkflowTemplate;import com.sasis.workflow.jbpm.definition.ProcessDefinitionFactoryBean;import com.sasis.workflow.jbpm.parser.JpdlXmlPlugReader;import com.sasis.workflow.jbpm.task.model.TaskVariable;public class JbpmTemplate implements WorkflowTemplate   {/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#getContext() */public JbpmContext getContext() {JbpmContext context = JbpmContext.getCurrentJbpmContext();return context;}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#findTaskInstances(java.lang.String) */public List findTaskInstances(final String actorId) {return getContext().getTaskMgmtSession().findTaskInstances(actorId);}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#getTaskInstance(java.lang.Long) */public TaskInstance getTaskInstance(final Long taskInstanceId) {return getContext().getTaskMgmtSession().getTaskInstance(taskInstanceId.longValue());}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#findTaskInstances(java.lang.String[]) */public List findTaskInstances(final String[] actorIds) {return getContext().getTaskMgmtSession().findTaskInstances(actorIds);}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#saveTaskInstances(org.jbpm.taskmgmt.exe.TaskInstance) */public void saveTaskInstances(TaskInstance taskInstance) {Session session = getContext().getSessionFactory().getCurrentSession();session.save(taskInstance);}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#saveTaskInstancess(org.jbpm.taskmgmt.exe.TaskInstance) */public void saveTaskInstancess(TaskInstance taskInstance) {Session session = getContext().getSessionFactory().getCurrentSession();session.save(taskInstance);}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#findTaskInstances(java.util.List) */public List findTaskInstances(final List actorIds) {return getContext().getTaskMgmtSession().findTaskInstances(actorIds);}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#findTaskInstancesByToken(org.jbpm.graph.exe.Token) */public List findTaskInstancesByToken(Token token) {return findTaskInstancesByToken(token.getId());}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#findTaskInstancesByToken(long) */public List findTaskInstancesByToken(final long tokenId) {return getContext().getTaskMgmtSession().findTaskInstancesByToken(tokenId);}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#signal(org.jbpm.graph.exe.ProcessInstance) */public void signal(final ProcessInstance processInstance) {processInstance.signal();}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#signal(org.jbpm.graph.exe.ProcessInstance, java.lang.String) */public void signal(final ProcessInstance processInstance, final String transitionId) {processInstance.signal(transitionId);}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#signal(org.jbpm.graph.exe.ProcessInstance, org.jbpm.graph.def.Transition) */public void signal(final ProcessInstance processInstance, final Transition transition) {processInstance.signal(transition);}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#signalToken(org.jbpm.graph.exe.ProcessInstance, java.lang.String) */    public void signalToken(final ProcessInstance processInstance, final String tokenName) {Token token = processInstance.getRootToken().findToken(tokenName);        if (token == null) {            processInstance.signal();        } else {            token.signal();        }}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#signalToken(org.jbpm.graph.exe.ProcessInstance, java.lang.String, java.lang.String) */    public void signalToken(final ProcessInstance processInstance, final String tokenName, final String transitionId) {Token token = processInstance.getRootToken().findToken(tokenName);        if (token == null) {            processInstance.signal(transitionId);        } else {            token.signal(transitionId);        }}    /* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#findPooledTaskInstances(java.util.List) */public List findPooledTaskInstances(final List actorIds) {return getContext().getTaskMgmtSession().findPooledTaskInstances(actorIds);}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#findPooledTaskInstances(java.lang.String) */public List findPooledTaskInstances(String actorId) {return getContext().getTaskMgmtSession().findPooledTaskInstances(actorId);}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#saveProcessInstance(org.jbpm.graph.exe.ProcessInstance) */public ProcessInstance saveProcessInstance(ProcessInstance processInstance) {Session session = getContext().getSessionFactory().getCurrentSession();session.save(processInstance);return processInstance;}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#findProcessInstances(java.lang.Long) */public List findProcessInstances(Long processDefinitionId) {return getContext().getGraphSession().findProcessInstances(processDefinitionId.longValue());}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#findProcessInstance(java.lang.Long) */public ProcessInstance findProcessInstance(Long processInstanceId) {return getContext().loadProcessInstance(processInstanceId.longValue());}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#findLatestProcessDefinition(java.lang.String) */public ProcessDefinition findLatestProcessDefinition(String processDefinitionName){return getContext().getGraphSession().findLatestProcessDefinition(processDefinitionName);}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#deployProcessDefinition(java.lang.String) */public ProcessDefinition deployProcessDefinition(String processDefinitionBeanName) {ProcessDefinitionFactoryBean processDefinitionBean = (ProcessDefinitionFactoryBean)ApplicationContextKeeper.getAppCtx().getBean(processDefinitionBeanName);getContext().deployProcessDefinition(processDefinitionBean.getProcessDefinition());List taskVariableList = processDefinitionBean.getTaskVariableList();Iterator taskVariableIT = taskVariableList.iterator();while (taskVariableIT.hasNext()){TaskVariable TaskVariable = (TaskVariable)taskVariableIT.next();Session session = getContext().getSessionFactory().getCurrentSession();session.save(TaskVariable);}return processDefinitionBean.getProcessDefinition(); }/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#deployProcessDefinition(org.jbpm.graph.def.ProcessDefinition) */public ProcessDefinition deployProcessDefinition(ProcessDefinition processDefinition) {getContext().deployProcessDefinition(processDefinition);RequestHelper requestHelper = RequestHelper.getContextrequestHelper();Session session = getContext().getSessionFactory().getCurrentSession();session.flush();List taskVariableList = (List)requestHelper.getAttribute("taskVariableList");if (null == taskVariableList){return processDefinition; }Iterator taskVariableIT = taskVariableList.iterator();while (taskVariableIT.hasNext()){TaskVariable TaskVariable = (TaskVariable)taskVariableIT.next();session.save(TaskVariable);}return processDefinition; }/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#deployProcessDefinition(java.io.File) */public long deployProcessDefinition(File processDefinitionFile) throws FileNotFoundException,IOException {InputStream is = null;ProcessDefinition processDefinition = null;try {    is = new FileInputStream(processDefinitionFile);JpdlXmlPlugReader jpdlReader = new JpdlXmlPlugReader(new InputSource(is));         processDefinition = jpdlReader.readProcessDefinition();         getContext().deployProcessDefinition(processDefinition);} finally {if (is != null) {is.close();}}if (null != processDefinition)return processDefinition.getId(); return 0;}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#isTheAssignPooledTaskInstances(java.lang.Long) */public boolean isTheAssignPooledTaskInstances(Long taskInstanceId){StringBuffer sqlBF = new StringBuffer();sqlBF.append("select taskinstance.id_ from jbpm_taskinstance taskinstance ").append("left join jbpm_taskactorpool taskactorpool on taskinstance.id_ = taskactorpool.taskinstance_ ").append("left join jbpm_pooledactor pooledactor on taskactorpool.pooledactor_ = pooledactor.id_ ").append(" where taskinstance.id_ =:taskinstanceid and pooledactor.actorid_=:actorid ").append("and taskinstance.issuspended_ = 0 ").append("and taskinstance.isopen_ = 1 ");Session session = getContext().getSessionFactory().getCurrentSession();Query sqlQuery = session.createSQLQuery(sqlBF.toString());sqlQuery.setLong("taskinstanceid",taskInstanceId.longValue());sqlQuery.setString("actorid", getContext().getActorId());sqlQuery.setFirstResult(10000);sqlQuery.setMaxResults(10000);List countResult = sqlQuery.list(); if (null != countResult && 0 <countResult.size()){return true; }return false;}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#isTheAssignTaskInstances(java.lang.Long) */public boolean isTheAssignTaskInstances(Long taskInstanceId){StringBuffer sqlBF = new StringBuffer();sqlBF.append("select ti.id_ from jbpm_taskinstance ti ").append("where ti.actorid_ = :actorId ").append("and ti.id_ = :taskInstanceId ").append("and ti.issuspended_ != 1 ").append("and ti.isopen_ = 1");Session session = getContext().getSessionFactory().getCurrentSession();Query sqlQuery = session.createSQLQuery(sqlBF.toString());sqlQuery.setBigDecimal("taskInstanceId",BigDecimal.valueOf(taskInstanceId.longValue()));sqlQuery.setString("actorId", getContext().getActorId());sqlQuery.setFirstResult(0);sqlQuery.setMaxResults(10000);List countResult = sqlQuery.list(); if (null != countResult && 0 <countResult.size()){return true; }return false;}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#startProcess(java.lang.String, java.lang.Object) */public Long startProcess(String processDefinitionName,Object model) {EntityPersister meta = ((SessionFactoryImplementor)getContext().getSessionFactory()).getEntityPersister(model.getClass().getName());Assert.notNull(meta.getEntityName());Assert.notNull(meta.getIdentifier(model, meta.guessEntityMode(model)));ProcessDefinition processDefinition = findLatestProcessDefinition(processDefinitionName);ProcessInstance processInstance = processDefinition.createProcessInstance();processInstance.setKey(String.valueOf(processInstance.getId()));processInstance.getContextInstance().setVariable("processStarter", getContext().getActorId());processInstance.getContextInstance().setVariable("entityName",meta.getEntityName());processInstance.getContextInstance().setVariable("entityIdentiferValue",meta.getIdentifier(model, meta.guessEntityMode(model)));processInstance.signal();saveProcessInstance(processInstance);return new Long(processInstance.getId());}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#startProcess(java.lang.String) */public ProcessInstance startProcess(String processDefinitionName,Map valuesMap) {ProcessDefinition processDefinition = findLatestProcessDefinition(processDefinitionName);ProcessInstance processInstance = processDefinition.createProcessInstance();processInstance.setKey(String.valueOf(processInstance.getId()));this.assignProcessInstanceAttribute(processInstance, valuesMap);processInstance.signal();saveProcessInstance(processInstance);return processInstance;}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#startTaskInstance(java.lang.Long, java.lang.String) */public TaskInstance startTaskInstance(Long taskInstanceId,String actorId) {TaskInstance taskInstance= getTaskInstance(taskInstanceId);if (StringUtils.isNotEmpty(actorId)){taskInstance.start(actorId);} else {taskInstance.start();}this.getContext().save(taskInstance);return taskInstance;}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#getAssignPooledTaskInstanceIds(java.lang.Long) */public List getAssignPooledTaskInstanceIds(Long processInstanceId){StringBuffer sqlBF = new StringBuffer();sqlBF.append("select taskinstance.id_,taskinstance.name_ from jbpm_taskinstance taskinstance ").append("left join jbpm_taskactorpool taskactorpool on taskinstance.id_ = taskactorpool.taskinstance_ ").append("left join jbpm_pooledactor pooledactor on taskactorpool.pooledactor_ = pooledactor.id_ ").append(" where taskinstance.procinst_ =:processInstanceId and pooledactor.actorid_=:actorid ").append("and taskinstance.issuspended_ = 0 ").append("and taskinstance.isopen_ = 1 ");Session session = getContext().getSessionFactory().getCurrentSession();Query sqlQuery = session.createSQLQuery(sqlBF.toString());sqlQuery.setBigDecimal("processInstanceId",BigDecimal.valueOf(processInstanceId.longValue()));sqlQuery.setString("actorid", getContext().getActorId());sqlQuery.setFirstResult(0);sqlQuery.setMaxResults(10000);return sqlQuery.list();}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#getAssignTaskInstanceIds(java.lang.Long) */public List getAssignTaskInstanceIds(Long processInstanceId){StringBuffer sqlBF = new StringBuffer();sqlBF.append("select ti.id_,ti.name_ from jbpm_taskinstance ti ").append("where ti.actorid_ = :actorId ").append("and ti.procinst_ = :processInstanceId ").append("and ti.issuspended_ = 0 ").append("and ti.isopen_ = 1");Session session = getContext().getSessionFactory().getCurrentSession();Query sqlQuery = session.createSQLQuery(sqlBF.toString());sqlQuery.setBigDecimal("processInstanceId",BigDecimal.valueOf(processInstanceId.longValue()));sqlQuery.setString("actorId", getContext().getActorId());sqlQuery.setFirstResult(0);sqlQuery.setMaxResults(10000);return sqlQuery.list();}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#getNodesByDefinitionId(java.lang.Long) */public List getNodesByDefinitionId(Long processDefinitionId){String sqlBF = "select * from jbpm_node t where t.processdefinition_ = :processDefinitionId";Session session = getContext().getSessionFactory().getCurrentSession();Query sqlQuery = session.createSQLQuery(sqlBF.toString());sqlQuery.setBigDecimal("processDefinitionId",BigDecimal.valueOf(processDefinitionId.longValue()));sqlQuery.setFirstResult(0);sqlQuery.setMaxResults(10000);return sqlQuery.list();}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#getTaskInstanceByPidAndNodeName(java.lang.Long, java.lang.String) */public List getTaskInstanceByPidAndNodeName(Long processInstanceId,String name){String sqlBF = "select  taskinstance.actorid_,taskinstance.isopen_ from jbpm_taskinstance taskinstance,jbpm_task task,jbpm_node node  " +"where taskinstance.task_ = task.id_ and task.tasknode_ = node.id_ and taskinstance.procinst_ = :processInstanceId " +"and node.name_ = :name";Session session = getContext().getSessionFactory().getCurrentSession();Query sqlQuery = session.createSQLQuery(sqlBF.toString());sqlQuery.setBigDecimal("processInstanceId",BigDecimal.valueOf(processInstanceId.longValue()));sqlQuery.setString("name",name);sqlQuery.setFirstResult(0);sqlQuery.setMaxResults(10000);return sqlQuery.list();}public List getTaskInstanceByProcessInstanceId(String  processId){String sqlBF = "select name_,end_ from jbpm_taskinstance taskinstance  " +"where taskinstance.procinst_ =  '"+processId+"'";Session session = getContext().getSessionFactory().getCurrentSession();Query sqlQuery = session.createSQLQuery(sqlBF.toString());sqlQuery.setFirstResult(0);sqlQuery.setMaxResults(10000);//return getContext().getTaskMgmtSession().findTaskInstancesByProcessInstance(processInstance);return sqlQuery.list();}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#assignProcessInstanceAttribute(org.jbpm.graph.exe.ProcessInstance, java.util.Map) */public void assignProcessInstanceAttribute(ProcessInstance processInstance,Map values){//ProcessInstance processInstance = findProcessInstance(processInstanceId);if (null == processInstance) return;ContextInstance contextInstance = processInstance.getContextInstance();Session session = getContext().getSessionFactory().getCurrentSession();contextInstance.addVariables(values);session.save(contextInstance);}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#assignProcessInstanceAttribute(java.lang.Long, java.util.Map) */public void assignProcessInstanceAttribute(Long processInstanceId,Map values){ProcessInstance processInstance = findProcessInstance(processInstanceId);if (null == processInstance) return;ContextInstance contextInstance = processInstance.getContextInstance();Session session = getContext().getSessionFactory().getCurrentSession();contextInstance.addVariables(values);session.save(contextInstance);}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#assignProcessInstanceAttribute(org.jbpm.graph.exe.ProcessInstance, java.lang.String, java.lang.Object) */public void assignProcessInstanceAttribute(ProcessInstance processInstance,String key,Object value){if (null == processInstance) return;ContextInstance contextInstance = processInstance.getContextInstance();Session session = getContext().getSessionFactory().getCurrentSession();contextInstance.createVariable(key, value);session.save(contextInstance);}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#assignProcessInstanceAttribute(java.lang.Long, java.lang.String, java.lang.Object) */public void assignProcessInstanceAttribute(Long processInstanceId,String key,Object value){ProcessInstance processInstance = findProcessInstance(processInstanceId);if (null == processInstance) return;ContextInstance contextInstance = processInstance.getContextInstance();Session session = getContext().getSessionFactory().getCurrentSession();contextInstance.createVariable(key, value);session.save(contextInstance);}/* (non-Javadoc) * @see com.sasis.workflow.jbpm.WorkflowTemplate#getVariablebyTask(org.jbpm.taskmgmt.def.Task, java.lang.String) */public Object getVariablebyTask(Task task,String keyName){Session session = getContext().getSessionFactory().getCurrentSession();Query query = session.createQuery("from TaskVariable taskTaskVariable where taskTaskVariable.task.id = "+task.getId() +" and taskTaskVariable.name = '" + keyName +"'");List valueList = query.list();if (null!= valueList && 0 <valueList.size()){return valueList.get(0);}return null;}/* (non-Javadoc) * @see com.sasis.workflow.WorkflowTemplate#startFlow(java.util.Map, java.lang.String) */public String startFlow(Map valuesMap, String processName) {ProcessInstance processInstance = this.startProcess(processName,valuesMap);return String.valueOf(processInstance.getId());}}
十、ComplaintAction.java


1 0