activiti工作流笔记
什么是activiti?
Activiti是一个身经百战的业务流程管理引擎, 并且还是一个流程平台
为什么要用工作流引擎?
想想看,如果要设计一个流程的程序,通常需要在数据库中存各种状态值,比如一个订单程序,要标记订单是未付款、已付款、已出库等等状态,而这些各种各样的状态参杂在程序中,逻辑自然就变得复杂了。
而将这些状态对应到流程里的一个个步骤,交由流程引擎去管理,这样不仅简化了业务逻辑代码,
状态机---->工作流。
API介绍
(一)

额外再加一个: DynamicBpmnService:提供动态获取,以及动态修改流程定义的方法。
Activiti的后台是有数据库的支持,所有的表都以ACT_开头。 第二部分是表示表的用途的两个字母标识。用途也和服务的API对应。
1) ACT_RE_*: ‘RE’表示repository。 这个前缀的表包含了流程定义和流程静态资源(图片,规则,等等)。
2) ACT_RU_*: ‘RU’表示runtime。 这些运行时的表,包含流程实例,任务,变量,异步任务,等运行中的数据。 Activiti只在流程实例执行过程中保存这些数据,在流程结束时就会删除这些记录。 这样运行时表可以一直很小速度很快。
3) ACT_ID_*: ‘ID’表示identity。 这些表包含身份信息,比如用户,组等等。
4) ACT_HI_*: ‘HI’表示history。 这些表包含历史数据,比如历史流程实例,变量,任务等等。
5) ACT_GE_*: 通用数据, 用于不同场景下。
资源库流程规则表
1) act_re_deployment 部署信息表
2) act_re_model 流程设计模型部署表
3) act_re_procdef 流程定义数据表
运行时数据库表
1) act_ru_execution 运行时流程执行实例表
2) act_ru_identitylink 运行时流程人员表,主要存储任务节点与参与者的相关信息
3) act_ru_task 运行时任务节点表
4) act_ru_variable 运行时流程变量数据表
5) act_ru_timer_job (5.22不存在)
6) act_ru_suspended_job (5.22不存在)
7) act_ru_event_subscr
8) act_ru_deadletter_job (5.22不存在)
9) act_ru_job
历史数据库表
1) act_hi_actinst 历史节点表
2) act_hi_attachment 历史附件表
3) act_hi_comment 历史意见表
4) act_hi_identitylink 历史流程人员表
5) act_hi_detail 历史详情表,提供历史变量的查询
6) act_hi_procinst 历史流程实例表
7) act_hi_taskinst 历史任务实例表
8) act_hi_varinst 历史变量表
组织机构表
1) act_id_group 用户组信息表
2) act_id_info 用户扩展信息表
3) act_id_membership 用户与用户组对应信息表
4) act_id_user 用户信息表
这四张表很常见,基本的组织机构管理,关于用户认证方面建议还是自己开发一套,组件自带的功能太简单,使用中有很多需求难以满足
通用数据表
1) act_ge_bytearray 二进制数据表
2) act_ge_property 属性数据表存储整个流程引擎级别的数据,初始化表结构时,会默认插入三条记录
(二) ACT_RE_MODEL
1 查询model 是否存在
List<Model> modelList = repositoryService.createModelQuery().modelName("Demo model").list();
2 有三个外键,对应ACT_GE_BYTEARRAY的有两个。
EDITOR_SOURCE_VALUE_ID_对应ACT_GE_BYTEARRAY的ID_,表示该模型对应的模型文件(json格式数据)。
repositoryService.addModelEditorSource方法实现。
EDITOR_SOURCE_EXTRA_VALUE_ID_对应ACT_GE_BYTEARRAY的ID_,表示该模型生成的图片文件。
repositoryService.addModelEditorSourceExtra方法实现。
3 保存model
Model modelData = repositoryService.newModel();
repositoryService.saveModel(modelData);
执行对应的SaveModelCmd。会插入或更新ACT_RE_MODEL的数据。
SaveModelCmd对应的execute方法:
public Void execute(CommandContext commandContext) {
if (this.model == null) {
throw new ActivitiIllegalArgumentException("model is null");
} else {
if (this.model.getId() == null) {
commandContext.getModelEntityManager().insertModel(this.model);
} else {
commandContext.getModelEntityManager().updateModel(this.model);
}
return null;
}
}
// insert方法分发ENTITY_CREATED和ENTITY_INITIALIZED事件:
public void insertModel(Model model) {
((ModelEntity)model).setCreateTime(Context.getProcessEngineConfiguration().getClock().getCurrentTime());
((ModelEntity)model).setLastUpdateTime(Context.getProcessEngineConfiguration().getClock().getCurrentTime());
this.getDbSqlSession().insert((PersistentObject)model);
if (Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_CREATED, model));
Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_INITIALIZED, model));
}
}
// update方法分发ENTITY_UPDATED方法:
public void updateModel(ModelEntity updatedModel) {
CommandContext commandContext = Context.getCommandContext();
updatedModel.setLastUpdateTime(Context.getProcessEngineConfiguration().getClock().getCurrentTime());
DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
dbSqlSession.update(updatedModel);
if (Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, updatedModel));
}
}
(三) 流程发起人
identityService.setAuthenticatedUserId(user.getId());
参考:https://www.cnblogs.com/skilltalent-huan/articles/5091592.html
workFlow学习总结---------------------常用的工作流引擎
https://blog.csdn.net/liuwenbiao1203/article/details/53158254
Activiti 5.16 用户手册
http://www.mossle.com/docs/activiti/index.html#bpmnConstructs
三分钟明白 Activity工作流 -- java运用
https://blog.csdn.net/jiangyu1013/article/details/73250902
官网Quick Start Guide
https://www.activiti.org/quick-start
BPMN 2.0规范详解
https://blog.csdn.net/a123demi/article/details/50674124
activiti工作流笔记的更多相关文章
- Activiti工作流笔记(4)
Activiti工作流启动流程 /** * 启动流程 * */ public class ActivitiTest2 { RepositoryService repositoryService; Ru ...
- Activiti工作流笔记(3)
Activiti工作流的流程部署和删除流程部署 流程部署代码: /** * 部署流程 */ public class ActivitiTest { RepositoryService reposito ...
- Activiti工作流笔记(2)
1.Activiti工作数据表 Activiti用来存放流程数据的表共使用23张表,表名都是以"ACT_"开头,底层操作默认使用mybatis操作 工作流Activiti的表是用来 ...
- Activiti工作流笔记(1)
Activiti下载地址: eclipse的activiti插件下载地址:http://www.activiti.org/designer/archived/activiti-designer-5.1 ...
- Activiti工作流学习笔记一
Activiti工作流 一:Activiti第一天 1:工作流的概念 说明: 假设:这两张图就是华谊兄弟的请假流程图 图的组成部分: 人物:范冰冰冯小刚王中军 事件(动作):请假.批准.不批准 工作流 ...
- Activiti工作流框架学习笔记(二)之springboot2.0整合工作流Activiti6.0
以前在工作当中做过不少与工作流Activiti有关的工作,当时都是spring集成activiti5.22的项目,现在回过头去看,其实版本已经稍微老了,因此,基于先前的工作经验,决定用较新版本的技术来 ...
- Activiti工作流学习笔记(三)——自动生成28张数据库表的底层原理分析
原创/朱季谦 我接触工作流引擎Activiti已有两年之久,但一直都只限于熟悉其各类API的使用,对底层的实现,则存在较大的盲区. Activiti这个开源框架在设计上,其实存在不少值得学习和思考的地 ...
- Activiti工作流学习笔记(四)——工作流引擎中责任链模式的建立与应用原理
原创/朱季谦 本文需要一定责任链模式的基础,主要分成三部分讲解: 一.简单理解责任链模式概念 二.Activiti工作流里责任链模式的建立 三.Activiti工作流里责任链模式的应用 一.简单理解责 ...
- Activiti 学习笔记记录(二)
上一篇:Activiti 学习笔记记录 导读:对于工作流引擎的使用,我们都知道,需要一个业务事件,比如请假,它会去走一个流程(提交申请->领导审批---(批,不批)---->结束),Act ...
随机推荐
- AttributeError: Got AttributeError when attempting to get a value for field `password2` on serializer ` UserSerializer`...
Error_msg: AttributeError: Got AttributeError when attempting to get a value for field `password2` o ...
- Messenger更改系统语言以后无法登陆,提示“初始设置被修改”
在安装messenger机器上使用SQL management studio打开数据库,链接YCD的数据库,找到dbo.Dic_Defaults的表,编辑打开以后找到“CultureInfo”两项,删 ...
- CDH Yarn 调度资源指南 - CDH6.0.x 详解
Yarn 工作架构 最近随着集群大家开始频繁使用集群,资源调度的问题越发的凸显出来.需要更加深入的了解 yarn 资源调度的原理,以及到底在背后做了一些什么事情. 来看一下下面这张图. yarn 里面 ...
- Linux 学习 (七) 挂载命令 & 用户登陆查看
Linux达人养成计划 I 学习笔记 挂载命令 mount:查询系统中已经挂载的设备 mount -a:根据配置文件 /etc/fstab 的内容,自动挂载 mount [-t 文件系统] [-o 特 ...
- 【C/C++】任意进制转换
进制转换:R进制->10进制:10进制->R进制. #include<bits/stdc++.h> using namespace std; /*函数:r进制转换成10进制*/ ...
- CentOS 7安装MongoDB
1 下载安装包 wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.4.tgz 2 解压 .tgz 3 将解压包 ...
- codeforces1107G Vasya and Maximum Profit 【模拟】
题目分析: 前缀和啥的模拟一下就行了. 代码: #include<bits/stdc++.h> using namespace std; ; int n,x,d[maxn],sta[max ...
- 整理CSS选择符
1.星号选择器 ;; } 星号选择器将匹配页面里的每一个元素.很多开发者使用这个技巧将外边距和内边距重置为零.虽然在快速测试时这确实很好用,但我建议你永远不要再生产代码中使用它.它给浏览器带来大量不必 ...
- Luogu P4643 【模板】动态dp
题目链接 Luogu P4643 题解 猫锟在WC2018讲的黑科技--动态DP,就是一个画风正常的DP问题再加上一个动态修改操作,就像这道题一样.(这道题也是PPT中的例题) 动态DP的一个套路是把 ...
- Linux交换分区使用过多的处理办法
处理办法 echo "vm.swappiness=0" >>/etc/sysctl.conf sysctl -p swapoff -a && swapo ...