Learning Activiti workflow framework (a) of the general purpose data table details

Wen / Zhu Jiqian

Activiti workflow engine comes with a set of database tables, and there are a place to note:

5.6.4 version of MySQL lower than the date or time stamp does not support millisecond. Worse, some versions when trying to create such a column will throw an exception, while the other version does not. When executed automatically create / upgrade, the engine will change it in the implementation of DDL. When using the DDL file method, you can either use the regular version which can also be used with mysql55 special file (this applies to any version earlier than 5.6.4). After a column type having no file millisecond accuracy.

I have been tested in version 5.6.0, is not found automatically generated table of 23, but in the 5.6.4 version of the above can be, therefore, the best guarantee mysql version 5.6.4 or higher.

 

A Database Table Name Description

Activiti database tables most 5 points, names beginning with ACT, the second portion is a two-character flag table for the embodiment substantially matches the service API use cases:

 

 

Two data tables common .ACT_GE_ *


Universal Data tables are used to store some common data, these tables do not care about their own specific business processes or only for the storage of these resources or business processes used. There are two general data tables, and are ACT_GE_BYTEARRAY ACT_GE_PROPERTY, they are beginning to ACT_GE_ *.

2.1 ACT_GE_BYTEARRAY resource table

Related resource table ACT_GE_BYTEARRAY resource table that holds the engine in the process, when the process files for deployment, process definition pictures and XML files and other data, will be converted into a byte array to save the table. The table designed a byte field used to save the contents of the resource, the table contains the following fields:

 

 

 NOTE: Activiti To ensure data primary key entire process engine table produced is throughout the process engine only using a DbIdGenerator class generate the primary key, the class stored in the ID value of the next data and the ID of the current block is the last ID value.

 

2.2 ACT_GE_PROPERTY attribute table

Activiti all attributes abstract key-value pairs, and each property has a name and a value.

 

 注:在初始化流程数据库时,会默认加入3条属性数据:next.dbid、schema.history和schema.version。

next.dbid:属性值为1时,表示Activiti数据库表ID生成时,当前ID块最大值为1(即数据库里还没有任何数据)。前面也提到,流程引擎是使用一个DbIdGenerator类来生成主键的,该类保存了下一条数据的ID值和当前ID块的最后一个ID值,所谓ID块就是Activiti数据产生时ID值时,就会从1开始到101进行取值作为数据ID,那么该ID块的最大值为101。DbIdGenerator在产生数据ID时,会判断当前ID值是否大于101(ID块最大值)。如果大于,则请求重新生成一个ID块,那么此时属性中的next.dbid属性值将会为201。

schema.history:属性表示数据表结构的更新历史,例如——

 

 

 create(5.22.0.0)即表示使用了5.22版本的初始化脚本创建。

schema.version:表示当前Activiti数据结构的版本。

 

三.ACT_RE_ *流程存储表

存储表名称以ACT_RE开头,RE是repository单词的前两个字母,流程使用存储表来保存流程定义和部署信息相关的数据。

 

3.1.ACT_RE_DEPLOYMENT部署数据表

在流程引擎中,一次部署可以添加多个资源,即可以有图片与XML之类的资源,这些资源数据会保存到资源表(ACT_GE_BTYEARRAY),剩余部署信息,则保存到部署表中,部署名为ACT_RE_DEPLOYMENT,包含以下三个字段:

 

 

 3.2.ACT_RE_PROCDEF流程定义表

Activiti在部署流程文件时(.bpmn或者.bpmn20.xml),其除了会将内容保存到资源表外,还会解析流程文件的内容,形成特定的流程定义数据,写入到流程定义表(ACT_RE_PROCDEF)中,该表包含了以下的字段:

 

 

 注:该表的主键与其他数据表不同的是,ACT_RE_PROCDEF表的主键是组合主键,其值为流程定义的KEY_字段值加流程定义的VERSION_字段值再加ID生成器生成的ID值,其中这三个值以冒号为分隔符。例如,KEY_值为baoxiaoProcess,VERSION_值为1,ID生成器生成的ID值为722504,则该主键为baoxiaoProcess:1:722504,如以下截图所示:

 

 

 四.ACT_ID_ *身份数据表

Activiti的整个身份证数据模块,可以独立于流程引擎而存在,身份数据表并没有保存流程相关的数据以及关联,身份表名称使用ACT_ID关联,ID是单词identity的前两个字母。

4.1.ACD_ID_USER用户表

流程引擎用户的信息被保存在ACT_ID_USER表中,该表有以下字段:

 

 

 4.2.ACD_ID_GROUP用户组表

使用ACT_ID_GROUP表来保存用户组的数据,该表有以下几个字段:

 

 

  4.3.ACD_ID_MEMBERSHIP关系表

关系表用来描述用户表与用户组表的对应关系:

 注:该表的两个字段均做了外键约束,写入该表的数据时,必须要有用户和用户组数据与之关联。

 

 

五.ACT_RU_ *运行时数据表

运行时数据表用来保存流程在运行过程中所产生的数据,例如流程实例、执行流和任务等,以ACT_RU开头,RU是单词runtime的前两个字母。

5.1.ACT_RU_EXECUTION流程实例表

 流程启动后,会产生一个流程实例,同时产生相应的执行流,流程实例和执行流数据均被保存在ACT_RU_EXECUTION表中。如果一个流程实例只要一条执行流,那么该表中只产生一条数据,该数据既表示执行流,也表示流程实例。

 

 5.2.ACT_RU_TASK流程任务表

流程在运行过程中所产生的任务数据保存在ACT_RU_TASK,字段如下:

 

 

  5.3.ACT_RU_VARIABLE流程参数表

流程引擎提供了ACT_RU_VARIABLE表来存放流程中的参数,这类参数包括流程实例参数、执行流参数和任务参数,各参数可以有多种类型。

 

  5.4.ACT_RU_IDENTITYLINK流程与身份关系表

用户组与用户之间存在的关系,使用ACT_ID_MEMBERSHIP表保存。用户或者用户组与流程数据之间的关系,则使用ACT_RU_IDENTITYLINK表进行保存。

 

   5.5.ACT_RU_JOB工作数据表

在流程执行的过程中,会有一些工作需要定时或者重复执行,这类工作数据被保存到ACT_RU_JOB表中。

 

 

    5.6.ACT_RU_EVENT_SUBSCR事件描述表

如果流程到达某类事件节点,Activiti会往ACT_RU_EVENT_SUBSCR表中加入事件描述数据,这些事件描述数据将会决定流程事件的触发。

 

 

 六.ACT_HI_ *历史数据表


历史数据表就像流程引擎的日志表。被操作过的流程元素,将会被记录到李四表中。历史表名称以ACT_HI开头,HI是单词history的前两个字母。

6.1.ACT_HI_PROCINST流程实例表

流程实例的历史数据会被保存到ACT_HI_PROCINST表中,只要流程启动,Activiti就会将流程实例的数据写入ACT_HI_PROCINST表中。除了基本的流程字段外,与运行时数据表不同的是,历史流程实例表还会记录流程的开始活动ID的、活动结束ID等信息。

 

 6.2.ACT_HI_ACTINST历史行为表

历史行为表会记录每一个流程活动的实例,一个 流程活动将会被记录成一条数据,例如,流程中有开始事件,用户任务,结束事件各一个,当流程结束后,该表就会产生3条历史行为数据。

 

 6.3.附件表ACT_HI_ATTACHMENT

使用任务服务(TaskService)的API,可以添加附件,这些附件数据将会保存到ACT_HI_ATTACHMENT表中。

 

  6.4.评论表ACT_HI_COMMENT

可以专门存放审批过程中的评论数据。

 

 

Guess you like

Origin www.cnblogs.com/zhujiqian/p/11966455.html