MIS系统中JBPM SOP

JAVAJBPM SOP

 

软件

Eclipse 3.3 或以上

jbpm-starters-kit-3.1.4

tomcat1.6

sqlserver2005

 

步骤:

Eclipse 开发环境设置:

1、从网上下载jbpm-starters-kit-3.1.4 ,同时解压此压缩包,并把jbpm-starters-kit-3.1.4/jbpm-designer/jbpm-gpd-feature/eclipsefeaturesplugins两个目录文件拷到eclipse目录下。

2   建表:执行/jbpm-db/build/mssql/scripts/mssql.create.sql语句。

定义流程:

1、  建立项目:

打开配置好的eclipse,选择file—New---java project,出现如下界面:

在此页面中,输入Project name,此处我命名为jbpmsop,全部配置好后,点击Next按钮,出现如下界面:

再点击Finisheclipse下就出现了jbpmsop的项目。

 

右击jbpmsop项目,选择New---Other  出现如下界面,并选择Process Definition,并点击Next

在下一页面中输入Process Namejbpmsoptest,并finish,项目中生成了jbpmtest并且附带gpd.xml processdefinition.xml两个文件,点击processdefinition.xml文件,在显示页面上定义需要的流程。

 

2、   画流程:

这边主要介绍定义流程页面的主要组成,具体看下图:

左边的各个节点为流程定义中需要用到的节点,如果需要用到,只要直接把相关节点拖到右边的空白区域即可。

具体各个节点详细介绍如下:这边主要讲比较常用的:

Start:流程开始节点,每个流程第一个节点都必须是次节点。

Fork:分支节点,流程分成两条路。

Join:合并节点,流程两条路合并成一条。

Decision:判断节点,选择流程走向。

Task Node:任务节点,设置任务并分配任务。

End:流程结束节点,和开始节点类似。

Transition:连接线,用于连接各个节点的,表示走向。

3、  流程定义结束以后,把项目中的gpd.xmlprocessdefinition.xmlprocessimage.jpg打包成zip格式.

gpd:用于生成流程图的定义文件,主要是一些方框的坐标和长宽。

processdefinition:这个是最重要的流程配置文件,所有流程定义都是在这个文件中设置。

processimage.jpg:定义的流程图。

4、  等流程完全定义好以后,需要发布此流程:

这边我们需要在java程序中建立一个Deploy类;具体代码如下:

import org.jbpm.JbpmContext;

import org.jbpm.JbpmConfiguration;

import org.jbpm.graph.def.ProcessDefinition;

 

import java.io.IOException;

import java.io.FileInputStream;

import java.io.File;

import java.util.zip.ZipInputStream;

 

public class Deploy {

    public static void main(String[] args) throws IOException {

        JbpmContext context = JbpmConfiguration.getInstance().createJbpmContext();

        try{

            String archivrfile="E://workspace//jbpm//qianhe//qianhe.zip";

            FileInputStream inputStream = new FileInputStream(new File(archivrfile));

            ZipInputStream inputStream1 = new ZipInputStream(inputStream);

            ProcessDefinition processDefinition = ProcessDefinition.parseParZipInputStream(inputStream1);

            context.deployProcessDefinition(processDefinition);

            inputStream1.close();

            inputStream.close();

        }

        finally {

            context.close();

        }

    }

}

我们只要更改红色底纹的路径值,并运行此main函数即可。

5、  配置java项目的jbpm环境:

   

6、  配置hibernate.cfg.xml

主要配置红色底纹中的数据源路径(你的jbpm路径放在那边,就连接在哪边)

    <?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

    <session-factory>

        <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>

        <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>

        <property name="hibernate.connection.url">jdbc:sqlserver://192.168.254.251:1433;DatabaseName=FrameJBPM</property>

        <property name="hibernate.connection.username">sa</property>

        <property name="hibernate.connection.password">```111sql</property>

        <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>

        <mapping resource="org/jbpm/db/hibernate.queries.hbm.xml"/>

        <mapping resource="org/jbpm/graph/action/MailAction.hbm.xml"/>

        <mapping resource="org/jbpm/graph/def/ProcessDefinition.hbm.xml"/>

        <mapping resource="org/jbpm/graph/def/Node.hbm.xml"/>

        <mapping resource="org/jbpm/graph/def/Transition.hbm.xml"/>

        <mapping resource="org/jbpm/graph/def/Event.hbm.xml"/>

        <mapping resource="org/jbpm/graph/def/Action.hbm.xml"/>

        <mapping resource="org/jbpm/graph/def/SuperState.hbm.xml"/>

        <mapping resource="org/jbpm/graph/def/ExceptionHandler.hbm.xml"/>

        <mapping resource="org/jbpm/instantiation/Delegation.hbm.xml"/>

        <mapping resource="org/jbpm/graph/action/Script.hbm.xml"/>

        <mapping resource="org/jbpm/graph/node/StartState.hbm.xml"/>

        <mapping resource="org/jbpm/graph/node/EndState.hbm.xml"/>

        <mapping resource="org/jbpm/graph/node/ProcessState.hbm.xml"/>

        <mapping resource="org/jbpm/graph/node/Decision.hbm.xml"/>

        <mapping resource="org/jbpm/graph/node/Fork.hbm.xml"/>

        <mapping resource="org/jbpm/graph/node/Join.hbm.xml"/>

        <mapping resource="org/jbpm/graph/node/MailNode.hbm.xml"/>

        <mapping resource="org/jbpm/graph/node/State.hbm.xml"/>

        <mapping resource="org/jbpm/graph/node/TaskNode.hbm.xml"/>

        <mapping resource="org/jbpm/context/def/ContextDefinition.hbm.xml"/>

        <mapping resource="org/jbpm/context/def/VariableAccess.hbm.xml"/>

        <mapping resource="org/jbpm/bytes/ByteArray.hbm.xml"/>

        <mapping resource="org/jbpm/module/def/ModuleDefinition.hbm.xml"/>

        <mapping resource="org/jbpm/file/def/FileDefinition.hbm.xml"/>

        <mapping resource="org/jbpm/taskmgmt/def/TaskMgmtDefinition.hbm.xml"/>

        <mapping resource="org/jbpm/taskmgmt/def/Swimlane.hbm.xml"/>

        <mapping resource="org/jbpm/taskmgmt/def/Task.hbm.xml"/>

        <mapping resource="org/jbpm/taskmgmt/def/TaskController.hbm.xml"/>

        <mapping resource="org/jbpm/scheduler/def/CreateTimerAction.hbm.xml"/>

        <mapping resource="org/jbpm/scheduler/def/CancelTimerAction.hbm.xml"/>

        <mapping resource="org/jbpm/graph/exe/Comment.hbm.xml"/>

        <mapping resource="org/jbpm/graph/exe/ProcessInstance.hbm.xml"/>

        <mapping resource="org/jbpm/graph/exe/Token.hbm.xml"/>

        <mapping resource="org/jbpm/graph/exe/RuntimeAction.hbm.xml"/>

        <mapping resource="org/jbpm/module/exe/ModuleInstance.hbm.xml"/>

        <mapping resource="org/jbpm/context/exe/ContextInstance.hbm.xml"/>

        <mapping resource="org/jbpm/context/exe/TokenVariableMap.hbm.xml"/>

        <mapping resource="org/jbpm/context/exe/VariableInstance.hbm.xml"/>

        <mapping resource="org/jbpm/context/exe/variableinstance/ByteArrayInstance.hbm.xml"/>

        <mapping resource="org/jbpm/context/exe/variableinstance/DateInstance.hbm.xml"/>

        <mapping resource="org/jbpm/context/exe/variableinstance/DoubleInstance.hbm.xml"/>

        <mapping resource="org/jbpm/context/exe/variableinstance/HibernateLongInstance.hbm.xml"/>

        <mapping resource="org/jbpm/context/exe/variableinstance/HibernateStringInstance.hbm.xml"/>

        <mapping resource="org/jbpm/context/exe/variableinstance/LongInstance.hbm.xml"/>

        <mapping resource="org/jbpm/context/exe/variableinstance/NullInstance.hbm.xml"/>

        <mapping resource="org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml"/>

        <mapping resource="org/jbpm/job/Job.hbm.xml"/>

        <mapping resource="org/jbpm/job/Timer.hbm.xml"/>

        <mapping resource="org/jbpm/job/ExecuteNodeJob.hbm.xml"/>

        <mapping resource="org/jbpm/job/ExecuteActionJob.hbm.xml"/>

        <mapping resource="org/jbpm/taskmgmt/exe/TaskMgmtInstance.hbm.xml"/>

        <mapping resource="org/jbpm/taskmgmt/exe/TaskInstance.hbm.xml"/>

        <mapping resource="org/jbpm/taskmgmt/exe/PooledActor.hbm.xml"/>

        <mapping resource="org/jbpm/taskmgmt/exe/SwimlaneInstance.hbm.xml"/>

        <mapping resource="org/jbpm/logging/log/ProcessLog.hbm.xml"/>

        <mapping resource="org/jbpm/logging/log/MessageLog.hbm.xml"/>

        <mapping resource="org/jbpm/logging/log/CompositeLog.hbm.xml"/>

        <mapping resource="org/jbpm/graph/log/ActionLog.hbm.xml"/>

        <mapping resource="org/jbpm/graph/log/NodeLog.hbm.xml"/>

        <mapping resource="org/jbpm/graph/log/ProcessInstanceCreateLog.hbm.xml"/>

        <mapping resource="org/jbpm/graph/log/ProcessInstanceEndLog.hbm.xml"/>

        <mapping resource="org/jbpm/graph/log/ProcessStateLog.hbm.xml"/>

        <mapping resource="org/jbpm/graph/log/SignalLog.hbm.xml"/>

        <mapping resource="org/jbpm/graph/log/TokenCreateLog.hbm.xml"/>

        <mapping resource="org/jbpm/graph/log/TokenEndLog.hbm.xml"/>

        <mapping resource="org/jbpm/graph/log/TransitionLog.hbm.xml"/>

        <mapping resource="org/jbpm/context/log/VariableLog.hbm.xml"/>

        <mapping resource="org/jbpm/context/log/VariableCreateLog.hbm.xml"/>

        <mapping resource="org/jbpm/context/log/VariableDeleteLog.hbm.xml"/>

        <mapping resource="org/jbpm/context/log/VariableUpdateLog.hbm.xml"/>

        <mapping resource="org/jbpm/context/log/variableinstance/ByteArrayUpdateLog.hbm.xml"/>

        <mapping resource="org/jbpm/context/log/variableinstance/DateUpdateLog.hbm.xml"/>

        <mapping resource="org/jbpm/context/log/variableinstance/DoubleUpdateLog.hbm.xml"/>

        <mapping resource="org/jbpm/context/log/variableinstance/HibernateLongUpdateLog.hbm.xml"/>

        <mapping resource="org/jbpm/context/log/variableinstance/HibernateStringUpdateLog.hbm.xml"/>

        <mapping resource="org/jbpm/context/log/variableinstance/LongUpdateLog.hbm.xml"/>

        <mapping resource="org/jbpm/context/log/variableinstance/StringUpdateLog.hbm.xml"/>

        <mapping resource="org/jbpm/taskmgmt/log/TaskLog.hbm.xml"/>

        <mapping resource="org/jbpm/taskmgmt/log/TaskCreateLog.hbm.xml"/>

        <mapping resource="org/jbpm/taskmgmt/log/TaskAssignLog.hbm.xml"/>

        <mapping resource="org/jbpm/taskmgmt/log/TaskEndLog.hbm.xml"/>

        <mapping resource="org/jbpm/taskmgmt/log/SwimlaneLog.hbm.xml"/>

        <mapping resource="org/jbpm/taskmgmt/log/SwimlaneCreateLog.hbm.xml"/>

        <mapping resource="org/jbpm/taskmgmt/log/SwimlaneAssignLog.hbm.xml"/>

        <class-cache class="org.jbpm.context.def.VariableAccess" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.file.def.FileDefinition.processFiles" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.action.Script.variableAccesses" usage="nonstrict-read-write"/>

        <class-cache class="org.jbpm.graph.def.Action" usage="nonstrict-read-write"/>

        <class-cache class="org.jbpm.graph.def.Event" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.def.Event.actions" usage="nonstrict-read-write"/>

        <class-cache class="org.jbpm.graph.def.ExceptionHandler" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.def.ExceptionHandler.actions" usage="nonstrict-read-write"/>

        <class-cache class="org.jbpm.graph.def.Node" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.def.Node.events" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.def.Node.exceptionHandlers" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.def.Node.leavingTransitions" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.def.Node.arrivingTransitions" usage="nonstrict-read-write"/>

        <class-cache class="org.jbpm.graph.def.ProcessDefinition" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.def.ProcessDefinition.events" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.def.ProcessDefinition.exceptionHandlers" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.def.ProcessDefinition.nodes" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.def.ProcessDefinition.actions" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.def.ProcessDefinition.definitions" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.def.SuperState.nodes" usage="nonstrict-read-write"/>

        <class-cache class="org.jbpm.graph.def.Transition" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.def.Transition.events" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.def.Transition.exceptionHandlers" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.node.Decision.decisionConditions" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.node.ProcessState.variableAccesses" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.graph.node.TaskNode.tasks" usage="nonstrict-read-write"/>

        <class-cache class="org.jbpm.instantiation.Delegation" usage="nonstrict-read-write"/>

        <class-cache class="org.jbpm.module.def.ModuleDefinition" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.taskmgmt.def.Swimlane.tasks" usage="nonstrict-read-write"/>

        <class-cache class="org.jbpm.taskmgmt.def.TaskController" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.taskmgmt.def.TaskController.variableAccesses" usage="nonstrict-read-write"/>

        <class-cache class="org.jbpm.taskmgmt.def.Task" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.taskmgmt.def.Task.events" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.taskmgmt.def.Task.exceptionHandlers" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.taskmgmt.def.TaskMgmtDefinition.swimlanes" usage="nonstrict-read-write"/>

        <collection-cache collection="org.jbpm.taskmgmt.def.TaskMgmtDefinition.tasks" usage="nonstrict-read-write"/>

        <class-cache    class="org.jbpm.context.def.VariableAccess" usage="transactional" />

        <collection-cache collection="org.jbpm.file.def.FileDefinition.processFiles" usage="transactional" />

        <collection-cache collection="org.jbpm.graph.action.Script.variableAccesses" usage="transactional" />

        <class-cache   class="org.jbpm.graph.def.Action"       usage="transactional" />

        <class-cache   class="org.jbpm.graph.def.Event" usage="transactional" />

        <collection-cache collection="org.jbpm.graph.def.Event.actions" usage="transactional" />

        <class-cache   class="org.jbpm.graph.def.ExceptionHandler"     usage="transactional" />

        <collection-cache collection="org.jbpm.graph.def.ExceptionHandler.actions" usage="transactional" />

        <class-cache   class="org.jbpm.graph.def.Node" usage="transactional" />

        <collection-cache collection="org.jbpm.graph.def.Node.events" usage="transactional" />

        <collection-cache collection="org.jbpm.graph.def.Node.exceptionHandlers" usage="transactional" />

        <collection-cache collection="org.jbpm.graph.def.Node.leavingTransitions" usage="transactional" />

        <collection-cache collection="org.jbpm.graph.def.Node.arrivingTransitions" usage="transactional" />

        <class-cache   class="org.jbpm.graph.def.ProcessDefinition"     usage="transactional" />

        <collection-cache collection="org.jbpm.graph.def.ProcessDefinition.events" usage="transactional" />

        <collection-cache collection="org.jbpm.graph.def.ProcessDefinition.exceptionHandlers" usage="transactional" />

        <collection-cache collection="org.jbpm.graph.def.ProcessDefinition.nodes" usage="transactional" />

        <collection-cache collection="org.jbpm.graph.def.ProcessDefinition.actions" usage="transactional" />

        <collection-cache collection="org.jbpm.graph.def.ProcessDefinition.definitions" usage="transactional" />

        <collection-cache collection="org.jbpm.graph.def.SuperState.nodes" usage="transactional" />

        <class-cache   class="org.jbpm.graph.def.Transition"  usage="transactional" />

        <collection-cache collection="org.jbpm.graph.def.Transition.events" usage="transactional" />

        <collection-cache collection="org.jbpm.graph.def.Transition.exceptionHandlers" usage="transactional" />

        <collection-cache collection="org.jbpm.graph.node.Decision.decisionConditions" usage="transactional" />

        <collection-cache collection="org.jbpm.graph.node.ProcessState.variableAccesses" usage="transactional" />

        <collection-cache collection="org.jbpm.graph.node.TaskNode.tasks" usage="transactional" />

        <class-cache   class="org.jbpm.instantiation.Delegation"    usage="transactional" />

        <class-cache   class="org.jbpm.module.def.ModuleDefinition"    usage="transactional" />

        <collection-cache collection="org.jbpm.taskmgmt.def.Swimlane.tasks" usage="transactional" />

        <class-cache   class="org.jbpm.taskmgmt.def.TaskController"   usage="transactional" />

        <collection-cache collection="org.jbpm.taskmgmt.def.TaskController.variableAccesses" usage="transactional" />

        <class-cache   class="org.jbpm.taskmgmt.def.Task"   usage="transactional" />

        <collection-cache collection="org.jbpm.taskmgmt.def.Task.events" usage="transactional" />

        <collection-cache collection="org.jbpm.taskmgmt.def.Task.exceptionHandlers" usage="transactional" />

        <collection-cache collection="org.jbpm.taskmgmt.def.TaskMgmtDefinition.swimlanes" usage="transactional" />

        <collection-cache collection="org.jbpm.taskmgmt.def.TaskMgmtDefinition.tasks" usage="transactional" />

    </session-factory>

</hibernate-configuration>

7、  java项目中调用你定义的流程:

   JbpmContext jbpmContext1 = JbpmConfiguration.getInstance().createJbpmContext();

  //获取名为swr的流程定义

    ProcessDefinition pd = jbpmContext1.getGraphSession().findLatestProcessDefinition("jbpmsoptest");

    ProcessInstance pi = pd.createProcessInstance();

    ContextInstance ci = pi.getContextInstance();//全局变量

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值