01-activiti6基础——引擎如何数据库操作及相关表

更新时间:2023-07-05 20:28:28 阅读: 评论:0

01-activiti6基础——引擎如何数据库操作及相关表
官⽹⽂档:
activiti 的官⽅⽂档讲解详细很详细,也很范。按着⽂档写完了⼀个简单的demo 发现,现实中的⼤多数问题,还是没法很好的解决。
例如:⾸先我需要知道的是,activiti 的有那些表,及各个表的作⽤。这个⽹上有⼈罗列过,但总是觉得不通透。
所以,我先简单看了⼀下activiti 数据处理的源码。
RepositoryServiceImpl海鲈钓法
进⾏对那个操作的封装,传递Command 接⼝的对应⼦类,⾥⾯封装了具体的操作
CommandInvoker
⽅法。具体如下所⽰。
DeployCmd(从这⾥调⽤DataManager 的实现类进⾏相关数据库操作)
DeploymentEntityManagerImpl
实际数据库操作的是DataManager 的实现类,进⾏数据库操作。这个我们能看出来是有两个
对应的xml 操作
在mapping ⽬录下可以查找到对应的操作。前⾯的${prefix}标识数据库,activiti 已经帮我们判断好了,不需要我们再传⼊。
public Deployment deploy(DeploymentBuilderImpl deploymentBuilder) {
ute(new DeployCmd<Deployment>(deploymentBuilder));
}
public <T> T execute(final CommandConfig config, final Command<T> command) {
final CommandContext commandContext = CommandContext();
//省略⼀些代码
@Override
public void run() {
commandContext.ute(commandContext));//这⾥是关键
}
});
// 省略⼀些代码。。。。。。。。。。。。
return (T) Result();
}
public Deployment execute(CommandContext commandContext) {
// Backwards compatibility with Activiti v5
if (ProcessEngineConfiguration().isActiviti5CompatibilityEnabled()
&& DeploymentProperties() != null
&& DeploymentProperties().containsKey(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION)
&& DeploymentProperties().get(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION).equals(Boolean.TRUE)) {
return deployAsActiviti5ProcessDefinition(commandContext);
}
return executeDeploy(commandContext);
}
@Override
public void inrt(DeploymentEntity deployment) {
inrt(deployment, fal);
for (ResourceEntity resource : Resources().values()) {
resource.Id());
getResourceEntityManager().inrt(resource);
}
}
<inrt id="inrtDeployment" parameterType="ine.ity.DeploymentEntityImpl">
inrt into ${prefix}ACT_RE_DEPLOYMENT(ID_, NAME_, CATEGORY_, KEY_, TENANT_ID_, DEPLOY_TIME_, ENGINE_VERSION_)
values(#{id, jdbcType=VARCHAR}, #{name, jdbcType=VARCHAR}, #{category, jdbcType=VARCHA
R}, #{key, jdbcType=VARCHAR}, #{tenantId, jdbcType=VARCHAR}, #{deploymentTime, jdbcType=TIMESTAMP}, #{engineVersion, jdbcType=  </inrt>
<inrt id="inrtResource" parameterType="ine.ity.ResourceEntityImpl">
inrt into ${prefix}ACT_GE_BYTEARRAY(ID_, REV_, NAME_, BYTES_, DEPLOYMENT_ID_, GENERATED_)
values (#{id, jdbcType=VARCHAR}, 1, #{name, jdbcType=VARCHAR}, #{bytes, jdbcType=${blobType}}, #{deploymentId, jdbcType=VARCHAR}, #{generated, jdbcType=BOOLEAN})
DataManager
数据查询操作本质都是通过DataManger 的实现类MybatisDeploymentDataManager
进⾏操作;
查找xml 中对应的sql
需要了解任务类型,以及⽹关相关知识。TaskService AbstractCompleteTaskCmd
ManagementService
TableDataManagerImpl
</inrt>
@Override
public List<Deployment> executeList(CommandContext commandContext, Page page) {
checkQueryOk();
DeploymentEntityManager().findDeploymentsByQueryCriteria(this, page);
}
@Override
@SuppressWarnings("unchecked")
public List<Deployment> findDeploymentsByQueryCriteria(DeploymentQueryImpl deploymentQuery, Page page) {
final String query = "lectDeploymentsByQueryCriteria";
return getDbSqlSession().lectList(query, deploymentQuery, page);
}
<lect id="lectDeploymentsByQueryCriteria" parameterType="ine.impl.DeploymentQueryImpl" resultMap="deploymentResultMap">
${limitBefore}
lect distinct RES.* ${limitBetween}
<include refid="lectDeploymentsByQueryCriteriaSql"/>
${orderBy}
${limitAfter}
</lect>
protected void executeTaskComplete(CommandContext commandContext, TaskEntity taskEntity, Map<String, Object> variables, boolean localScope) {
// Task complete logic
if (DelegationState() != null && DelegationState().equals(DelegationState.PENDING)) {
throw new ActivitiException("A delegated task cannot be completed, but should be resolved instead.");
}
//执⾏节点监听事件
蜂粮
//查找任务lect * from ${prefix}ACT_RU_EXECUTION
// where ROOT_PROC_INST_ID_ = (lect ROOT_PROC_INST_ID_ from ${prefix}ACT_RU_EXECUTION where ID_ = #{parameter})
ExecutionEntity processInstanceEntity = ExecutionEntityManager().ProcessInstanceId());
//任务和identity 绑定
ActivitiEventDispatcher eventDispatcher = ProcessEngineConfiguration().getEventDispatcher();
if (eventDispatcher.isEnabled()) {
if (variables != null) {
eventDispatcher.ateEntityWithVariablesEvent(ActivitiEventType.TASK_COMPLETED, taskEntity, variables, localScope));      } el {
挤奶机eventDispatcher.ateEntityEvent(ActivitiEventType.TASK_COMPLETED, taskEntity));
}
}
//删除已有的任务相关数据
// Continue process (if not a standalone task) 激活下个步骤⼯作
if (ExecutionId() != null) {
ExecutionEntity executionEntity = ExecutionEntityManager().ExecutionId());
}
}
static {
// runtime
entityToTableNameMap.put(TaskEntity.class, "ACT_RU_TASK");
entityToTableNameMap.put(ExecutionEntity.class, "ACT_RU_EXECUTION");
entityToTableNameMap.put(IdentityLinkEntity.class, "ACT_RU_IDENTITYLINK");
entityToTableNameMap.put(VariableInstanceEntity.class, "ACT_RU_VARIABLE");
战略群组
entityToTableNameMap.put(JobEntity.class, "ACT_RU_JOB");
斜谷
entityToTableNameMap.put(TimerJobEntity.class, "ACT_RU_TIMER_JOB");
entityToTableNameMap.put(SuspendedJobEntity.class, "ACT_RU_SUSPENDED_JOB");
entityToTableNameMap.put(DeadLetterJobEntity.class, "ACT_RU_DEADLETTER_JOB");
以Task
接⼝为例
可以看到接⼝的实现类对应xml
的命名空间
官⽅⽂档中的说明
entityToTableNameMap.put(EventSubscriptionEntity.class, "ACT_RU_EVENT_SUBSCR");
entityToTableNameMap.put(CompensateEventSubscriptionEntity.class, "ACT_RU_EVENT_SUBSCR");    entityToTableNameMap.put(MessageEventSubscriptionEntity.class, "ACT_RU_EVENT_SUBSCR");    entityToTableNameMap.put(SignalEventSubscriptionEntity.class, "ACT_RU_EVENT_SUBSCR");    // repository
entityToTableNameMap.put(DeploymentEntity.class, "ACT_RE_DEPLOYMENT");
entityToTableNameMap.put(ProcessDefinitionEntity.class, "ACT_RE_PROCDEF");
entityToTableNameMap.put(ModelEntity.class, "ACT_RE_MODEL");
entityToTableNameMap.put(ProcessDefinitionInfoEntity.class, "ACT_PROCDEF_INFO");
// history
entityToTableNameMap.put(CommentEntity.class, "ACT_HI_COMMENT");
entityToTableNameMap.put(HistoricActivityInstanceEntity.class, "ACT_HI_ACTINST");
自我评价600字
entityToTableNameMap.put(AttachmentEntity.class, "ACT_HI_ATTACHMENT");
entityToTableNameMap.put(HistoricProcessInstanceEntity.class, "ACT_HI_PROCINST");
entityToTableNameMap.put(HistoricVariableInstanceEntity.class, "ACT_HI_VARINST");
entityToTableNameMap.put(HistoricTaskInstanceEntity.class, "ACT_HI_TASKINST");
entityToTableNameMap.put(HistoricIdentityLinkEntity.class, "ACT_HI_IDENTITYLINK");
// a couple of stuff goes to the same table
entityToTableNameMap.put(HistoricDetailAssignmentEntity.class, "ACT_HI_DETAIL");
entityToTableNameMap.put(HistoricDetailTransitionInstanceEntity.class, "ACT_HI_DETAIL");
entityToTableNameMap.put(HistoricFormPropertyEntity.class, "ACT_HI_DETAIL");
entityToTableNameMap.put(HistoricDetailVariableInstanceUpdateEntity.class, "ACT_HI_DETAIL");    entityToTableNameMap.put(HistoricDetailEntity.class, "ACT_HI_DETAIL");
// Identity module
entityToTableNameMap.put(GroupEntity.class, "ACT_ID_GROUP");
entityToTableNameMap.put(MembershipEntity.class, "ACT_ID_MEMBERSHIP");
entityToTableNameMap.put(UrEntity.class, "ACT_ID_USER");
entityToTableNameMap.put(IdentityInfoEntity.class, "ACT_ID_INFO");
// general
entityToTableNameMap.put(PropertyEntity.class, "ACT_GE_PROPERTY");
entityToTableNameMap.put(ByteArrayEntity.class, "ACT_GE_BYTEARRAY");
entityToTableNameMap.put(ResourceEntity.class, "ACT_GE_BYTEARRAY");
entityToTableNameMap.put(EventLogEntryEntity.class, "ACT_EVT_LOG");
// and now the map for the API types (does not cover all cas)
apiTypeToTableNameMap.put(Task.class, "ACT_RU_TASK");
apiTypeToTableNameMap.put(Execution.class, "ACT_RU_EXECUTION");
apiTypeToTableNameMap.put(ProcessInstance.class, "ACT_RU_EXECUTION");
apiTypeToTableNameMap.put(ProcessDefinition.class, "ACT_RE_PROCDEF");
apiTypeToTableNameMap.put(Deployment.class, "ACT_RE_DEPLOYMENT");
apiTypeToTableNameMap.put(Job.class, "ACT_RU_JOB");
apiTypeToTableNameMap.put(Model.class, "ACT_RE_MODEL");
// history
apiTypeToTableNameMap.put(HistoricProcessInstance.class, "ACT_HI_PROCINST");
apiTypeToTableNameMap.put(HistoricActivityInstance.class, "ACT_HI_ACTINST");
apiTypeToTableNameMap.put(HistoricDetail.class, "ACT_HI_DETAIL");
apiTypeToTableNameMap.put(HistoricVariableUpdate.class, "ACT_HI_DETAIL");
apiTypeToTableNameMap.put(HistoricFormProperty.class, "ACT_HI_DETAIL");
apiTypeToTableNameMap.put(HistoricTaskInstance.class, "ACT_HI_TASKINST");
apiTypeToTableNameMap.put(HistoricVariableInstance.class, "ACT_HI_VARINST");
// identity
apiTypeToTableNameMap.put(Group.class, "ACT_ID_GROUP");
apiTypeToTableNameMap.put(Ur.class, "ACT_ID_USER");
// TODO: Identity skipped for the moment as no SQL injection is provided
// here
}
Activiti 的数据库名称都以ACT_开头。第⼆部分是表⽤例的两个字符的标识。该⽤例也将与服务API ⼤致匹配。ACT_RE_ *:RE 代表repository 。具有此前缀的表包含静态信息,例如流程定义和流程资源(图像,规则等)。
ACT_RU_ *:RU 代表runtime 。这些是运⾏时表,其中包含流程实例,⽤户任务,变量,作业等的运⾏时数据。Activiti 仅在流程实例执⾏期间存储运⾏时数据,并在流程实例结束时删除记录。这样可以使运⾏时表较⼩⽽⼜快速。一本一道
初次使⽤中使⽤到的表格(后续继续补充)
类型
表格名称存储的数据备注⽣成
ACT_GE_BYTEARRAY 存储部署的bpmn 相关⽂件re
ACT_RE_DEPLOYMENT 发布的流程数据re act_re_procdef 存储流程分解数据
runtime ACT_RU_TASK 正在运⾏的任务
runtime ACT_RU_VARIABLE ⽤于存储流程流转中的字段
PROC_INST_ID_ 对应ACT_RU_TASK 中的EXECUTION_ID_ TASK_ID_ 对应 ACT_RU_TASK 中的ID_runtime ACT_RU_EXECUTION 运⾏时流程执⾏实例礼仪规范
history act_hi_taskinst 流程历史步骤数据
history act_hi_variable 历史步骤流程中转字段
history act_hi_procinst 已经发起的流程实例已经结束的流程任务END_ACT_ID_不为空ACT_ID_ *:ID 代表identity 。这些表包含⾝份信息,例如⽤户,组等。
ACT_HI_ *:HI 代表history 。这些表包含历史数据,例如过去的流程实例,变量,任务等。ACT_GE_ *:general 数据,⽤于各种⽤例中

本文发布于:2023-07-05 20:28:28,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1080463.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:流程   操作   数据   任务
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图