activiti流程部署管理

2020-05-26  本文已影响0人  lv_shun

ProcessEngineConfiguration.buildProcessEngine

创建ProcessEngine实例。

ProcessEngine

ProcessEngine是一个接口,实例代表一个流程引擎,实现类为ProcessEngineImpl。通过ProcessEngineConfiguration.buildProcessEngine获取时,创建ProcessEngineImpl实例,在构造中,将从ProcessEngineConfiguration获取各种服务,然后将自身保存在ProcessEngines中,其实是个Map中,key为ProcessEngine名称。
ProcessEngine包括的服务:

RepositoryService

负责对流程文件的部署和流程的定义进行管理。这些流程文件会保存到ACT_GE_BYTEARRAY表中,对应的实体ResourceEntityImpl。

Deployment对象

Deployment是个接口,一个Deployment实例对应ACT_RE_DEPLOYMENT表的数据.Deployment子接口为DeploymentEntity,实现类DeploymentEntityImpl。如果要对属性进行修改,需要调用DeploymentBuilder提供的方法,DeploymentEntity只提供get方法。
DeploymentEntityImpl对应属性:

DeploymentBuilder对象

获取方式

RepositoryService repositoryService = processEngine.getRepositoryService();
        DeploymentBuilder deploymentBuider = repositoryService.createDeployment();

包含多个addXXX方法,可以用于部署添加资源,方法列举:

修改部署对象信息

 RepositoryService repositoryService = processEngine.getRepositoryService();
        DeploymentBuilder deployment = repositoryService.createDeployment();
        deployment.name("name").category("xxx").key("key").tenantId("tenantid");

检测是否重复部署

 DeploymentBuilder deployment = repositoryService.createDeployment();
        deployment.addClasspathResource("my_Resource.bpmn");
        deployment.name("name").category("xxx").key("key").tenantId("tenantid");
        deployment.enableDuplicateFiltering();  //检测是否重复部署 对比最后一条部署是否所有属性都相同
        processEngine.getName();

取消部署时的验证

 DeploymentBuilder deployment = repositoryService.createDeployment();
        deployment.addClasspathResource("my_Resource.xml");
        deployment.disableBpmnValidation(); //文件不符合规范过滤
        deployment.disableSchemaValidation(); //定义的流程不规范过滤
        deployment.deploy();

流程定义管理

RepositoryService提供的一系列对流程定义的控制,包括中止流程定义、激活流程定义、设置流程权限等

ProcessDefinition对象

ProcessDefinition是一个接口,一个ProcessDefinition实例对应一条流程定义数据.实现类为ProcessDefinitionEntityImpl,对应的数据类为ACT_RE_PROCDEF.
ProcessDefinition方法:

流程图自动生成

如果我们在部署时不提供流程图,但在流程定义的xml文件中保存了bpmn流程图的元素,则activiti会自动创建流程图,并保存在资源表中.如果我们不希望自动生成流程图,则可以在流程引擎配置中添加一下配置:

<property name="createDiagramOnDeploy" value="false"/>

中断和激活流程定义

RepositoryService提供了多个中断和激活流程定义的方法:

设置流程定义权限

 repositoryService.addCandidateStarterUser(deploy.getId(),"user1");//设置权限
        repositoryService.addCandidateStarterGroup(deploy.getId(),"group1");//设置权限组

IdentityLink对象

一个IdentityLink实例表示一种身份数据与流程数据绑定的关系,此处所说的身份包括用户和用户组,流程数据包括流程定义、流程任务等数据. IdentityLink对应实体类IdentityLinkEntityImpl,对应数据库表ACT_RU_IDENTITYLINK.包含属性:

流程定义中IdentityLink的获取:

ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult();
List<IdentityLink> identityLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());

查询流程文件

InputStream processModel = repositoryService.getProcessModel(processDefinition.getId());

查询流程资源名

List<String> names = repositoryService.getDeploymentResourceNames(processDefinition.getId());

删除部署资源

repositoryService.deleteDeployment(deploy.getId());
repositoryService.deleteDeployment(deploy.getId(),true);//集联删除对应流程实例数据.

DeploymentQuery对象

DeploymentQuery部署查询对象
相关方法:

ProcessDefinitionQuery对象

和DeploymentQuery相似,针对流程定义数据查询.

上一篇下一篇

猜你喜欢

热点阅读